2022-11-29 16:45:00 +00:00
|
|
|
import classNames from 'classnames'
|
|
|
|
import { ReactNode } from 'react'
|
|
|
|
|
|
|
|
import Card from 'components/Card'
|
|
|
|
import CloseIcon from 'components/Icons/close.svg'
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
children?: ReactNode | string
|
|
|
|
content?: ReactNode | string
|
|
|
|
className?: string
|
|
|
|
open: boolean
|
2022-12-06 09:20:22 +00:00
|
|
|
setOpen?: (open: boolean) => void
|
2022-11-29 16:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Modal = ({ children, content, className, open, setOpen }: Props) => {
|
|
|
|
const onClickAway = () => {
|
2022-12-06 09:20:22 +00:00
|
|
|
if (setOpen) setOpen(false)
|
2022-11-29 16:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return open ? (
|
2022-12-06 09:20:22 +00:00
|
|
|
<div className='fixed top-0 left-0 z-20 h-screen w-screen'>
|
|
|
|
<div className='relative flex h-full w-full items-center justify-center'>
|
|
|
|
<Card className={classNames('relative z-40 w-[790px] max-w-full p-0', className)}>
|
|
|
|
{setOpen && (
|
|
|
|
<span
|
|
|
|
className='absolute top-4 right-4 z-50 w-[32px] text-white opacity-60 hover:cursor-pointer hover:opacity-100'
|
|
|
|
onClick={onClickAway}
|
|
|
|
role='button'
|
|
|
|
>
|
|
|
|
<CloseIcon />
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{children ? children : content}
|
|
|
|
</Card>
|
|
|
|
<div
|
|
|
|
className='fixed top-0 left-0 z-30 block h-full w-full bg-black/70 backdrop-blur hover:cursor-pointer'
|
2022-11-29 16:45:00 +00:00
|
|
|
onClick={onClickAway}
|
|
|
|
role='button'
|
2022-12-06 09:20:22 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-29 16:45:00 +00:00
|
|
|
) : null
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Modal
|