"use client"; import { useEffect } from "react"; interface Props { open: boolean; onClose: () => void; children: React.ReactNode; } export default function Modal({ open, onClose, children }: Props) { // ESC-Taste schließen useEffect(() => { function handleEsc(e: KeyboardEvent) { if (e.key === "Escape") onClose(); } if (open) { window.addEventListener("keydown", handleEsc); } return () => window.removeEventListener("keydown", handleEsc); }, [open, onClose]); if (!open) return null; return (
e.stopPropagation()}> {children}
); } const overlayStyle = { position: "fixed" as const, inset: 0, backgroundColor: "rgba(0,0,0,0.5)", display: "flex", justifyContent: "center", alignItems: "center", }; const modalStyle = { backgroundColor: "white", padding: "20px", borderRadius: "8px", minWidth: "300px", };