index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import type { ReactNode } from 'react'
  2. import { Transition, TransitionChild } from '@headlessui/react'
  3. import classNames from '@/utils/classnames'
  4. type ContentDialogProps = {
  5. className?: string
  6. show: boolean
  7. onClose?: () => void
  8. children: ReactNode
  9. }
  10. const ContentDialog = ({
  11. className,
  12. show,
  13. onClose,
  14. children,
  15. }: ContentDialogProps) => {
  16. return (
  17. <Transition
  18. show={show}
  19. as="div"
  20. className="absolute left-0 top-0 z-20 box-border h-full w-full p-2"
  21. >
  22. <TransitionChild>
  23. <div
  24. className={classNames(
  25. 'absolute left-0 inset-0 w-full bg-app-detail-overlay-bg',
  26. 'duration-300 ease-in data-[closed]:opacity-0',
  27. 'data-[enter]:opacity-100',
  28. 'data-[leave]:opacity-0',
  29. )}
  30. onClick={onClose}
  31. />
  32. </TransitionChild>
  33. <TransitionChild>
  34. <div className={classNames(
  35. 'absolute left-0 w-full bg-app-detail-bg border-r border-divider-burn',
  36. 'duration-100 ease-in data-[closed]:-translate-x-full',
  37. 'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:translate-x-0',
  38. 'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:-translate-x-full',
  39. className,
  40. )}>
  41. {children}
  42. </div>
  43. </TransitionChild>
  44. </Transition>
  45. )
  46. }
  47. export default ContentDialog