From 6b84c19659cdb88a345f142406aeb15207dc6777 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Wed, 29 Jul 2026 18:15:25 +0000 Subject: [PATCH] Deploy --- src/components/ui/Modal.tsx | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 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..5e92172 --- /dev/null +++ b/src/components/ui/Modal.tsx @@ -0,0 +1,69 @@ +'use client' + +import { cn } from "@/lib/utils" +import { X } from 'lucide-react' +import React, { useEffect, useRef } from "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) + + useEffect(() => { + const handleEscape = (e: KeyboardEvent) => { + if (e.key === "Escape") onClose() + } + if (isOpen) { + document.addEventListener("keydown", handleEscape) + document.body.style.overflow = "hidden" + } else { + document.body.style.overflow = "" + } + return () => { + document.removeEventListener("keydown", handleEscape) + document.body.style.overflow = "" + } + }, [isOpen, onClose]) + + if (!isOpen) return null + + return ( +
{ + if (e.target === overlayRef.current) onClose() + }} + > +
+ + {title && ( + + )} + {children} +
+
+ ) +} \ No newline at end of file