import { Show, onMount, onCleanup, type JSX } from "solid-js"; import { Portal } from "solid-js/web"; import Xmark from "~/components/icons/Xmark"; export interface ModalProps { /** Controls modal visibility */ open: boolean; /** Callback when modal should close */ onClose: () => void; /** Modal title (optional) */ title?: string | JSX.Element; /** Modal content */ children: JSX.Element; /** Action buttons (optional) */ actions?: JSX.Element; /** Additional CSS classes for modal container */ class?: string; } export default function Modal(props: ModalProps) { const handleBackdropClick = (e: MouseEvent) => { if (e.target === e.currentTarget) { props.onClose(); } }; const handleEscapeKey = (e: KeyboardEvent) => { if (e.key === "Escape") { props.onClose(); } }; onMount(() => { if (props.open && typeof document !== "undefined") { document.addEventListener("keydown", handleEscapeKey); } }); onCleanup(() => { if (typeof document !== "undefined") { document.removeEventListener("keydown", handleEscapeKey); } }); return ( ); } export { Modal };