index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { Fragment, type ReactNode } from 'react'
  2. import { Transition } 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 w-full h-full z-20 p-2 box-border"
  21. >
  22. <Transition.Child
  23. as={Fragment}
  24. enter="ease-out duration-300"
  25. enterFrom="opacity-0"
  26. enterTo="opacity-100"
  27. leave="ease-in duration-200"
  28. leaveFrom="opacity-100"
  29. leaveTo="opacity-0"
  30. >
  31. <div
  32. className="absolute left-0 inset-0 w-full bg-app-detail-overlay-bg"
  33. onClick={onClose}
  34. />
  35. </Transition.Child>
  36. <Transition.Child
  37. as={Fragment}
  38. enter="transform transition ease-out duration-300"
  39. enterFrom="-translate-x-full"
  40. enterTo="translate-x-0"
  41. leave="transform transition ease-in duration-200"
  42. leaveFrom="translate-x-0"
  43. leaveTo="-translate-x-full"
  44. >
  45. <div className={classNames(
  46. 'absolute left-0 w-full bg-app-detail-bg border-r border-divider-burn',
  47. className,
  48. )}>
  49. {children}
  50. </div>
  51. </Transition.Child>
  52. </Transition>
  53. )
  54. }
  55. export default ContentDialog