From d32c440c976bb8bcca5366c4da0f169050d38e92 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Tue, 14 Jul 2026 19:12:51 +0000 Subject: [PATCH] Deploy --- src/components/ui/Modal.tsx | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 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..65c77f9 --- /dev/null +++ b/src/components/ui/Modal.tsx @@ -0,0 +1,67 @@ +'use client' + +import React, { useEffect, useRef } from 'react' +import { X } from 'lucide-react' +import { cn } from '@/lib/utils' + +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 handleEsc = (e: KeyboardEvent) => { + if (e.key === 'Escape') onClose() + } + if (isOpen) { + document.addEventListener('keydown', handleEsc) + document.body.style.overflow = 'hidden' + } + return () => { + document.removeEventListener('keydown', handleEsc) + 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