import { Fragment, useCallback } from 'react' import type { ElementType, ReactNode } from 'react' import { Dialog, Transition } from '@headlessui/react' import classNames from '@/utils/classnames' // https://headlessui.com/react/dialog type DialogProps = { className?: string titleClassName?: string bodyClassName?: string footerClassName?: string titleAs?: ElementType title?: ReactNode children: ReactNode footer?: ReactNode show: boolean onClose?: () => void } const CustomDialog = ({ className, titleClassName, bodyClassName, footerClassName, titleAs, title, children, footer, show, onClose, }: DialogProps) => { const close = useCallback(() => onClose?.(), [onClose]) return (
{Boolean(title) && ( {title} )}
{children}
{Boolean(footer) && (
{footer}
)}
) } export default CustomDialog