You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

access-control-dialog.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Fragment, useCallback } from 'react'
  2. import type { ReactNode } from 'react'
  3. import { Dialog, Transition } from '@headlessui/react'
  4. import { RiCloseLine } from '@remixicon/react'
  5. import cn from '@/utils/classnames'
  6. type DialogProps = {
  7. className?: string
  8. children: ReactNode
  9. show: boolean
  10. onClose?: () => void
  11. }
  12. const AccessControlDialog = ({
  13. className,
  14. children,
  15. show,
  16. onClose,
  17. }: DialogProps) => {
  18. const close = useCallback(() => {
  19. onClose?.()
  20. }, [onClose])
  21. return (
  22. <Transition appear show={show} as={Fragment}>
  23. <Dialog as="div" open={true} className="relative z-20" onClose={() => null}>
  24. <Transition.Child
  25. as={Fragment}
  26. enter="ease-out duration-300"
  27. enterFrom="opacity-0"
  28. enterTo="opacity-100"
  29. leave="ease-in duration-200"
  30. leaveFrom="opacity-100"
  31. leaveTo="opacity-0"
  32. >
  33. <div className="bg-background-overlay/25 fixed inset-0" />
  34. </Transition.Child>
  35. <div className="fixed inset-0 flex items-center justify-center">
  36. <Transition.Child
  37. as={Fragment}
  38. enter="ease-out duration-300"
  39. enterFrom="opacity-0 scale-95"
  40. enterTo="opacity-100 scale-100"
  41. leave="ease-in duration-200"
  42. leaveFrom="opacity-100 scale-100"
  43. leaveTo="opacity-0 scale-95"
  44. >
  45. <Dialog.Panel className={cn('relative h-auto min-h-[323px] w-[600px] overflow-y-auto rounded-2xl bg-components-panel-bg p-0 shadow-xl transition-all', className)}>
  46. <div onClick={() => close()} className="absolute right-5 top-5 z-10 flex h-8 w-8 cursor-pointer items-center justify-center">
  47. <RiCloseLine className='h-5 w-5 text-text-tertiary' />
  48. </div>
  49. {children}
  50. </Dialog.Panel>
  51. </Transition.Child>
  52. </div>
  53. </Dialog>
  54. </Transition >
  55. )
  56. }
  57. export default AccessControlDialog