diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx new file mode 100644 index 0000000..024d333 --- /dev/null +++ b/src/components/ui/Modal.tsx @@ -0,0 +1,79 @@ +'use client' + +import { useEffect } from 'react' +import { X } from 'lucide-react' +import { cn } from "@/lib/utils" + +interface ModalProps { + isOpen: boolean + onClose: () => void + title?: string + description?: string + className?: string + children: React.ReactNode +} + +export default function Modal({ + isOpen, + onClose, + title, + description, + className, + children +}: ModalProps) { + useEffect(() => { + if (!isOpen) return + const handleKey = (event: KeyboardEvent) => { + if (event.key === 'Escape') onClose() + } + document.body.style.overflow = 'hidden' + window.addEventListener('keydown', handleKey) + return () => { + document.body.style.overflow = '' + window.removeEventListener('keydown', handleKey) + } + }, [isOpen, onClose]) + + if (!isOpen) return null + + return ( +
+ + ) +} \ No newline at end of file