diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx new file mode 100644 index 0000000..644b789 --- /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, useCallback } 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 handleEscape = useCallback( + (e: KeyboardEvent) => { + if (e.key === "Escape") onClose() + }, + [onClose] + ) + + useEffect(() => { + if (open) { + document.addEventListener("keydown", handleEscape) + document.body.style.overflow = "hidden" + } + return () => { + document.removeEventListener("keydown", handleEscape) + document.body.style.overflow = "" + } + }, [open, handleEscape]) + + if (!open) return null + + return ( +
+ {/* Backdrop */} + + ) +} \ No newline at end of file