"use client"; import { useEffect } from "react"; import { createPortal } from "react-dom"; import { X } from "lucide-react"; import { cn } from "@/lib/utils"; import { Button } from "./Button"; export function Dialog({ open, onClose, title, description, children, className, size = "md", }: { open: boolean; onClose: () => void; title: string; description?: string; children: React.ReactNode; className?: string; size?: "sm" | "md" | "lg" | "xl"; }) { 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 || typeof document === "undefined") return null; const widths = { sm: "max-w-md", md: "max-w-lg", lg: "max-w-2xl", xl: "max-w-4xl", }; return createPortal(
{description}
) : null}