'use client'; import * as React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { X } from 'lucide-react'; import { useEffect } from 'react'; import { cn } from '../utils/cn'; export interface ModalProps { isOpen: boolean; onClose: () => void; children: React.ReactNode; maxWidth?: string; showClose?: boolean; variant?: 'default' | 'glass'; } export function Modal({ isOpen, onClose, children, maxWidth = 'max-w-4xl', showClose = true, variant = 'glass', }: ModalProps) { // Prevent scrolling when modal is open useEffect(() => { if (isOpen) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = 'unset'; } return () => { document.body.style.overflow = 'unset'; }; }, [isOpen]); // Close on escape key useEffect(() => { const handleEsc = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', handleEsc); return () => window.removeEventListener('keydown', handleEsc); }, [onClose]); return ( {isOpen && (
{/* Backdrop */} {/* Modal Content */} {/* Close Button */} {showClose && ( )}
{children}
)}
); }