From d009009d4c2134ec54d1d381f974e0065ad82689 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Sun, 26 Jul 2026 16:56:18 +0000 Subject: [PATCH] Deploy --- src/components/ui/Modal.tsx | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/components/ui/Modal.tsx diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx new file mode 100644 index 0000000..82c618c --- /dev/null +++ b/src/components/ui/Modal.tsx @@ -0,0 +1,68 @@ +'use client' + +import { useEffect, useRef, useCallback } from "react" +import { X } from 'lucide-react' +import { cn } from "@/lib/utils" + +interface ModalProps { + open: boolean + onClose: () => void + title?: string + children: React.ReactNode + className?: string +} + +export default function Modal({ open, onClose, title, children, className }: ModalProps) { + const overlayRef = useRef(null) + + const handleKeyDown = useCallback( + (e: KeyboardEvent) => { + if (e.key === "Escape") onClose() + }, + [onClose] + ) + + useEffect(() => { + if (open) { + document.addEventListener("keydown", handleKeyDown) + document.body.style.overflow = "hidden" + } else { + document.body.style.overflow = "" + } + return () => { + document.removeEventListener("keydown", handleKeyDown) + document.body.style.overflow = "" + } + }, [open, handleKeyDown]) + + if (!open) return null + + return ( +
{ + if (e.target === overlayRef.current) onClose() + }} + > +
+
+ {title &&

{title}

} + +
+ {children} +
+
+ ) +} \ No newline at end of file