"use client"; import { X } from "lucide-react"; import { useEffect, type ReactNode } from "react"; type ModalProps = { open: boolean; onClose: () => void; title: string; children: ReactNode; footer?: ReactNode; widthClassName?: string; }; export function Modal({ open, onClose, title, children, footer, widthClassName = "max-w-lg" }: ModalProps) { useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [open, onClose]); if (!open) return null; return ( // Bottom-aligned on a phone (thumb reach, and it clears the keyboard when // a field is focused), centred from sm up.

{title}

{children}
{footer && (
{footer}
)}
); }