import React, { useEffect } from 'react'; import { X } from 'lucide-react'; import { SectionSubtitle } from './Typography'; interface ModalProps { isOpen: boolean; onClose: () => void; title: string; children: React.ReactNode; size?: 'sm' | 'md' | 'lg' | 'xl'; showCloseButton?: boolean; actions?: React.ReactNode; } export const Modal = ({ isOpen, onClose, title, children, size = 'md', showCloseButton = true, actions }: ModalProps) => { useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } }; if (isOpen) { document.addEventListener('keydown', handleEscape); document.body.style.overflow = 'hidden'; } return () => { document.removeEventListener('keydown', handleEscape); document.body.style.overflow = 'unset'; }; }, [isOpen, onClose]); if (!isOpen) return null; const sizeClasses = { sm: 'max-w-md', md: 'max-w-lg', lg: 'max-w-2xl', xl: 'max-w-4xl' }; return (
{title} {showCloseButton && ( )}
{children}
{actions && (
{actions}
)}
); };