mars-v2-frontend/components/Modal.tsx

46 lines
1.3 KiB
TypeScript
Raw Normal View History

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
setOpen?: (open: boolean) => void
}
const Modal = ({ children, content, className, open, setOpen }: Props) => {
const onClickAway = () => {
if (setOpen) setOpen(false)
}
return open ? (
<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'
onClick={onClickAway}
role='button'
/>
</div>
</div>
) : null
}
export default Modal