import classNames from 'classnames'; import { motion } from 'framer-motion'; import type { ReactNode } from 'react'; import { useMemo } from 'react'; import { useKeyPressEvent } from 'react-use'; import { Overlay } from '../Overlay'; import { Heading } from './Heading'; import { IconButton } from './IconButton'; export interface DialogProps { children: ReactNode; open: boolean; onClose: () => void; title?: ReactNode; description?: ReactNode; className?: string; size?: 'sm' | 'md' | 'full' | 'dynamic'; hideX?: boolean; } export function Dialog({ children, className, size = 'full', open, onClose, title, description, hideX, }: DialogProps) { const titleId = useMemo(() => Math.random().toString(36).slice(2), []); const descriptionId = useMemo( () => (description ? Math.random().toString(36).slice(2) : undefined), [description], ); useKeyPressEvent('Escape', (e) => { e.preventDefault(); onClose(); }); return (
{title ? ( {title} ) : ( )} {description &&

{description}

}
{children}
{/*Put close at the end so that it's the last thing to be tabbed to*/} {!hideX && ( )}
); }