2025-02-22 17:14:33 +08:00
|
|
|
import {
|
|
|
|
|
Description,
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogBackdrop,
|
|
|
|
|
DialogPanel,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
} from '@headlessui/react'
|
2025-02-21 20:47:15 +07:00
|
|
|
import type { ReactNode } from 'react'
|
|
|
|
|
|
2025-02-22 21:17:56 +07:00
|
|
|
import { LeftArrow } from '~/components/icons/left-arrow'
|
2025-02-22 17:14:33 +08:00
|
|
|
import { APP } from '~/data/meta'
|
|
|
|
|
|
2025-02-22 15:15:04 +07:00
|
|
|
type ModalProperties = {
|
2025-02-21 20:47:15 +07:00
|
|
|
isOpen: boolean
|
|
|
|
|
onClose: () => void
|
|
|
|
|
children: ReactNode
|
2025-02-22 17:14:33 +08:00
|
|
|
description?: string
|
2025-02-21 20:47:15 +07:00
|
|
|
}
|
|
|
|
|
|
2025-02-22 17:14:33 +08:00
|
|
|
export const PopupModal = ({
|
2025-02-21 20:47:15 +07:00
|
|
|
isOpen,
|
|
|
|
|
onClose,
|
|
|
|
|
children,
|
2025-02-22 17:14:33 +08:00
|
|
|
description,
|
|
|
|
|
}: ModalProperties) => {
|
2025-02-21 20:47:15 +07:00
|
|
|
if (!isOpen) return
|
|
|
|
|
return (
|
2025-02-22 15:15:04 +07:00
|
|
|
<Dialog
|
|
|
|
|
open={isOpen}
|
|
|
|
|
onClose={onClose}
|
2025-02-22 15:17:46 +08:00
|
|
|
className="relative z-50"
|
2025-02-22 16:08:40 +08:00
|
|
|
transition
|
2025-02-22 15:15:04 +07:00
|
|
|
>
|
2025-02-22 16:08:40 +08:00
|
|
|
<DialogBackdrop
|
|
|
|
|
className="fixed inset-0 bg-black/50 duration-300 ease-out data-[closed]:opacity-0"
|
|
|
|
|
transition
|
|
|
|
|
/>
|
2025-02-22 21:34:09 +07:00
|
|
|
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto p-4 max-sm:bg-white sm:items-center">
|
2025-02-22 21:17:56 +07:00
|
|
|
<DialogPanel className="max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg">
|
2025-02-23 14:59:26 +07:00
|
|
|
<DialogTitle className="relative flex justify-center">
|
|
|
|
|
<button
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
className="absolute top-0 left-0 items-center lg:hidden"
|
|
|
|
|
>
|
|
|
|
|
<LeftArrow
|
|
|
|
|
width={50}
|
|
|
|
|
height={50}
|
|
|
|
|
/>
|
|
|
|
|
</button>
|
2025-02-22 17:14:33 +08:00
|
|
|
<img
|
|
|
|
|
src={APP.logo}
|
|
|
|
|
alt={APP.title}
|
|
|
|
|
className="h-[80px]"
|
|
|
|
|
/>
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
{description && (
|
|
|
|
|
<Description className="text-center text-[#565658]">
|
|
|
|
|
{description}
|
|
|
|
|
</Description>
|
|
|
|
|
)}
|
2025-02-22 15:17:46 +08:00
|
|
|
<div className="relative">{children}</div>
|
|
|
|
|
</DialogPanel>
|
2025-02-21 20:47:15 +07:00
|
|
|
</div>
|
2025-02-22 15:15:04 +07:00
|
|
|
</Dialog>
|
2025-02-21 20:47:15 +07:00
|
|
|
)
|
|
|
|
|
}
|