Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.tsx 2.5KB

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