import React, { useEffect, useState } from 'react'; import ReactDOM from 'react-dom'; import { motion, AnimatePresence } from 'motion/react'; import { X } from 'lucide-react'; export interface ModalProps { isOpen: boolean; onClose: () => void; title?: string; children: React.ReactNode; footer?: React.ReactNode; size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'; } export function Modal({ isOpen, onClose, title, children, footer, size = 'md' }: ModalProps) { const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); if (isOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; }; }, [isOpen]); if (!mounted) return null; const sizeClasses = { sm: 'max-w-md', md: 'max-w-xl', lg: 'max-w-3xl', xl: 'max-w-5xl', full: 'max-w-[95vw] h-[95vh]', }; const modalContent = ( {isOpen && (
{title && (

{title}

)}
{children}
{footer && (
{footer}
)}
)}
); const rootElement = document.getElementById('shell-modal-root') || document.body; return ReactDOM.createPortal(modalContent, rootElement); }