import React, { useEffect } from 'react'; import { FiX } from 'react-icons/fi'; const Modal = ({ open, onClose, title, subtitle, children, size = 'md' }) => { useEffect(() => { if (!open) return; const handler = (e) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', handler); document.body.style.overflow = 'hidden'; return () => { window.removeEventListener('keydown', handler); document.body.style.overflow = ''; }; }, [open, onClose]); if (!open) return null; const widths = { sm: 'max-w-md', md: 'max-w-2xl', lg: 'max-w-4xl', }; // Note: clicking the backdrop does NOT close the modal anymore. // Use the X button or the Escape key instead. This avoids accidental // dismissal when the user is in the middle of editing settings. return (
{subtitle}
}