import { cn } from '@/lib/utils'; import React, { useEffect } from 'react'; import { Button } from './Button'; import { Icon } from './Icon'; export interface ModalProps { isOpen: boolean; onClose: () => void; title: string; children: React.ReactNode; footer?: React.ReactNode; maxWidth?: 'xs' | 'sm' | 'md' | 'lg'; } export const Modal: React.FC = ({ isOpen, onClose, title, children, footer, maxWidth = 'md', }) => { useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape' && isOpen) { onClose(); } }; if (isOpen) { document.body.style.overflow = 'hidden'; window.addEventListener('keydown', handleKeyDown); } return () => { document.body.style.overflow = ''; window.removeEventListener('keydown', handleKeyDown); }; }, [isOpen, onClose]); if (!isOpen) return null; const maxWidthStyles = { xs: 'max-w-[380px]', sm: 'max-w-[420px]', md: 'max-w-[540px]', lg: 'max-w-[680px]', }; return (

{title}

{children}
{footer && (
{footer}
)}
); }; export default Modal;