From a9475a8d0e03e5f03e489b14e91975987ee23752 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Thu, 4 Jun 2026 11:45:20 +0000 Subject: [PATCH] Deploy --- src/components/ui/Modal.tsx | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 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..96bb894 --- /dev/null +++ b/src/components/ui/Modal.tsx @@ -0,0 +1,73 @@ +'use client' + +import { cn } from "@/lib/utils" +import { X } from 'lucide-react' +import React, { useEffect, useRef } from "react" + +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) + + useEffect(() => { + if (open) { + document.body.style.overflow = "hidden" + } else { + document.body.style.overflow = "" + } + return () => { + document.body.style.overflow = "" + } + }, [open]) + + useEffect(() => { + const handleEscape = (e: KeyboardEvent) => { + if (e.key === "Escape") onClose() + } + if (open) { + document.addEventListener("keydown", handleEscape) + } + return () => document.removeEventListener("keydown", handleEscape) + }, [open, onClose]) + + const handleOverlayClick = (e: React.MouseEvent) => { + if (e.target === overlayRef.current) onClose() + } + + if (!open) return null + + return ( +
+
+ + {title && ( +

{title}

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