"use client" import { useEffect } from "react" import Image from "next/image" import { X } from "lucide-react" interface ImageLightboxProps { src: string alt: string isOpen: boolean onClose: () => void } export default function ImageLightbox({ src, alt, isOpen, onClose }: ImageLightboxProps) { useEffect(() => { if (isOpen) { document.body.style.overflow = "hidden" } else { document.body.style.overflow = "unset" } return () => { document.body.style.overflow = "unset" } }, [isOpen]) useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === "Escape") { onClose() } } if (isOpen) { document.addEventListener("keydown", handleEscape) } return () => { document.removeEventListener("keydown", handleEscape) } }, [isOpen, onClose]) if (!isOpen) return null return (
e.stopPropagation()}> {alt}
) }