import { useEffect } from "react"; import Button from "./Button"; interface Props { open: boolean; onClose: () => void; title: string; children: React.ReactNode; actions?: React.ReactNode; wide?: boolean; } export default function Modal({ open, onClose, title, children, actions, wide, }: Props) { useEffect(() => { const handleEsc = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; if (open) { document.addEventListener("keydown", handleEsc); document.body.style.overflow = "hidden"; } return () => { document.removeEventListener("keydown", handleEsc); document.body.style.overflow = ""; }; }, [open, onClose]); if (!open) return null; return (
e.stopPropagation()} >
Dashboard

{title}

{children}
{actions ?? ( )}
); }