import React, { useEffect } from 'react'; import { XMarkIcon } from '@heroicons/react/24/outline'; type ModalSize = 'sm' | 'md' | 'lg' | 'xl'; const sizeMap: Record = { sm: 'max-w-sm', md: 'max-w-lg', lg: 'max-w-2xl', xl: 'max-w-4xl', }; interface Props { open: boolean; title: string; size?: ModalSize; onClose: () => void; children: React.ReactNode; footer?: React.ReactNode; } export default function Modal({ open, title, size = 'md', onClose, children, footer }: Props) { useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; document.addEventListener('keydown', onKey); return () => document.removeEventListener('keydown', onKey); }, [open, onClose]); if (!open) return null; return (
{/* Backdrop */}
{/* Panel */}
{/* Header */}

{title}

{/* Body */}
{children}
{/* Footer */} {footer && (
{footer}
)}
); }