From a3bc6bb77707ecde4e498059426b30f781182e46 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Mon, 27 Jul 2026 18:06:18 +0000 Subject: [PATCH] Deploy --- src/components/ui/Modal.tsx | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 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..ba1b06e --- /dev/null +++ b/src/components/ui/Modal.tsx @@ -0,0 +1,72 @@ +'use client' + +import { useEffect, useCallback, useRef } from "react" +import { cn } from "@/lib/utils" +import { X } from 'lucide-react' + +interface ModalProps { + isOpen: boolean + onClose: () => void + title?: string + children: React.ReactNode + className?: string +} + +export default function Modal({ isOpen, onClose, title, children, className }: ModalProps) { + const overlayRef = useRef(null) + const contentRef = useRef(null) + + const handleKeyDown = useCallback( + (e: KeyboardEvent) => { + if (e.key === "Escape") onClose() + }, + [onClose] + ) + + useEffect(() => { + if (isOpen) { + document.addEventListener("keydown", handleKeyDown) + document.body.style.overflow = "hidden" + } + return () => { + document.removeEventListener("keydown", handleKeyDown) + document.body.style.overflow = "unset" + } + }, [isOpen, handleKeyDown]) + + const handleOverlayClick = (e: React.MouseEvent) => { + if (e.target === overlayRef.current) onClose() + } + + if (!isOpen) return null + + return ( +
+
+ + {title && ( +

{title}

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