import React, { ReactNode, useEffect } from 'react'; import { X } from 'lucide-react'; interface ModalProps { isOpen: boolean; onClose: () => void; title: string; subtitle?: string; children: ReactNode; maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'; } export const Modal: React.FC = ({ isOpen, onClose, title, subtitle, children, maxWidth = 'lg', }) => { useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; if (isOpen) { document.body.style.overflow = 'hidden'; window.addEventListener('keydown', handleKeyDown); } return () => { document.body.style.overflow = 'unset'; window.removeEventListener('keydown', handleKeyDown); }; }, [isOpen, onClose]); if (!isOpen) return null; const maxWidthClass = { sm: 'max-w-sm', md: 'max-w-md', lg: 'max-w-lg', xl: 'max-w-xl', '2xl': 'max-w-2xl', }[maxWidth]; return (
e.stopPropagation()} >

{title}

{subtitle &&

{subtitle}

}
{children}
); };