index.tsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react'
  2. import { RiCloseLargeLine } from '@remixicon/react'
  3. import classNames from '@/utils/classnames'
  4. type IModal = {
  5. className?: string
  6. wrapperClassName?: string
  7. open: boolean
  8. onClose?: () => void
  9. title?: React.ReactNode
  10. description?: React.ReactNode
  11. children?: React.ReactNode
  12. closable?: boolean
  13. overflowVisible?: boolean
  14. }
  15. export default function FullScreenModal({
  16. className,
  17. wrapperClassName,
  18. open,
  19. onClose = () => { },
  20. children,
  21. closable = false,
  22. overflowVisible = false,
  23. }: IModal) {
  24. return (
  25. <Transition show={open} appear>
  26. <Dialog as="div" className={classNames('modal-dialog', wrapperClassName)} onClose={onClose}>
  27. <TransitionChild>
  28. <div className={classNames(
  29. 'fixed inset-0 bg-background-overlay-backdrop backdrop-blur-[6px]',
  30. 'duration-300 ease-in data-[closed]:opacity-0',
  31. 'data-[enter]:opacity-100',
  32. 'data-[leave]:opacity-0',
  33. )} />
  34. </TransitionChild>
  35. <div
  36. className="fixed inset-0 h-screen w-screen p-4"
  37. onClick={(e) => {
  38. e.preventDefault()
  39. e.stopPropagation()
  40. }}
  41. >
  42. <div className="relative h-full w-full rounded-2xl border border-effects-highlight bg-background-default-subtle">
  43. <TransitionChild>
  44. <DialogPanel className={classNames(
  45. 'h-full',
  46. overflowVisible ? 'overflow-visible' : 'overflow-hidden',
  47. 'duration-100 ease-in data-[closed]:opacity-0 data-[closed]:scale-95',
  48. 'data-[enter]:opacity-100 data-[enter]:scale-100',
  49. 'data-[leave]:opacity-0 data-[enter]:scale-95',
  50. className,
  51. )}>
  52. {closable
  53. && <div
  54. className='absolute right-3 top-3 z-50 flex h-9 w-9 cursor-pointer items-center justify-center
  55. rounded-[10px] bg-components-button-tertiary-bg hover:bg-components-button-tertiary-bg-hover'
  56. onClick={(e) => {
  57. e.stopPropagation()
  58. onClose()
  59. }}>
  60. <RiCloseLargeLine className='h-3.5 w-3.5 text-components-button-tertiary-text' />
  61. </div>}
  62. {children}
  63. </DialogPanel>
  64. </TransitionChild>
  65. </div>
  66. </div>
  67. </Dialog>
  68. </Transition>
  69. )
  70. }