This commit is contained in:
2025-12-01 17:21:38 +08:00
parent 32fee2b8ab
commit fab8c13cb3
7511 changed files with 996300 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
import type { Meta, StoryObj } from '@storybook/nextjs'
import { useState } from 'react'
import FullScreenModal from '.'
const meta = {
title: 'Base/Feedback/FullScreenModal',
component: FullScreenModal,
parameters: {
layout: 'fullscreen',
docs: {
description: {
component: 'Backdrop-blurred fullscreen modal. Supports close button, custom content, and optional overflow visibility.',
},
},
},
tags: ['autodocs'],
} satisfies Meta<typeof FullScreenModal>
export default meta
type Story = StoryObj<typeof meta>
const ModalDemo = (props: React.ComponentProps<typeof FullScreenModal>) => {
const [open, setOpen] = useState(false)
return (
<div className="flex h-[360px] items-center justify-center bg-background-default-subtle">
<button
type="button"
className="rounded-md bg-primary-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-primary-700"
onClick={() => setOpen(true)}
>
Launch full-screen modal
</button>
<FullScreenModal
{...props}
open={open}
onClose={() => setOpen(false)}
closable
>
<div className="flex h-full flex-col bg-background-default-subtle">
<div className="flex h-16 items-center justify-center border-b border-divider-subtle text-lg font-semibold text-text-primary">
Full-screen experience
</div>
<div className="flex flex-1 items-center justify-center text-sm text-text-secondary">
Place dashboards, flow builders, or immersive previews here.
</div>
</div>
</FullScreenModal>
</div>
)
}
export const Playground: Story = {
render: args => <ModalDemo {...args} />,
args: {
open: false,
},
}

View File

@@ -0,0 +1,74 @@
import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react'
import { RiCloseLargeLine } from '@remixicon/react'
import classNames from '@/utils/classnames'
import { noop } from 'lodash-es'
type IModal = {
className?: string
wrapperClassName?: string
open: boolean
onClose?: () => void
title?: React.ReactNode
description?: React.ReactNode
children?: React.ReactNode
closable?: boolean
overflowVisible?: boolean
}
export default function FullScreenModal({
className,
wrapperClassName,
open,
onClose = noop,
children,
closable = false,
overflowVisible = false,
}: IModal) {
return (
<Transition show={open} appear>
<Dialog as="div" className={classNames('modal-dialog', wrapperClassName)} onClose={onClose}>
<TransitionChild>
<div className={classNames(
'fixed inset-0 bg-background-overlay-backdrop backdrop-blur-[6px]',
'duration-300 ease-in data-[closed]:opacity-0',
'data-[enter]:opacity-100',
'data-[leave]:opacity-0',
)} />
</TransitionChild>
<div
className="fixed inset-0 h-screen w-screen p-4"
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
}}
>
<div className="relative h-full w-full rounded-2xl border border-effects-highlight bg-background-default-subtle">
<TransitionChild>
<DialogPanel className={classNames(
'h-full',
overflowVisible ? 'overflow-visible' : 'overflow-hidden',
'duration-100 ease-in data-[closed]:scale-95 data-[closed]:opacity-0',
'data-[enter]:scale-100 data-[enter]:opacity-100',
'data-[enter]:scale-95 data-[leave]:opacity-0',
className,
)}>
{closable
&& <div
className='absolute right-3 top-3 z-50 flex h-9 w-9 cursor-pointer items-center justify-center
rounded-[10px] bg-components-button-tertiary-bg hover:bg-components-button-tertiary-bg-hover'
onClick={(e) => {
e.stopPropagation()
onClose()
}}>
<RiCloseLargeLine className='h-3.5 w-3.5 text-components-button-tertiary-text' />
</div>}
{children}
</DialogPanel>
</TransitionChild>
</div>
</div>
</Dialog>
</Transition>
)
}