"use client"; import { X } from "lucide-react"; import { useId, useRef, type ReactNode } from "react"; import { Button } from "./Button"; import { useDialogFocus } from "./useDialogFocus"; 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) { const dialogRef = useRef(null); const titleId = useId(); useDialogFocus(open, onClose, dialogRef); 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}
)}
); }