"use client"; import Image from "next/image"; import { useCallback, useEffect, useState } from "react"; import { Reveal } from "@/components/Reveal"; function ChevronIcon({ direction, className }: { direction: "next" | "prev"; className?: string }) { const d = direction === "next" ? "M19 12H5m0 0 6-6m-6 6 6 6" : "M5 12h14m0 0-6-6m6 6-6 6"; return ( ); } /** * The grid stays exactly as before; clicking a thumbnail opens it full-size * with prev/next controls — a lightbox/slideshow over the same image list. */ export function ProjectGalleryLightbox({ images, alt }: { images: string[]; alt: string }) { const [openIndex, setOpenIndex] = useState(null); const close = useCallback(() => setOpenIndex(null), []); const showNext = useCallback( () => setOpenIndex((i) => (i === null ? null : (i + 1) % images.length)), [images.length], ); const showPrev = useCallback( () => setOpenIndex((i) => (i === null ? null : (i - 1 + images.length) % images.length)), [images.length], ); useEffect(() => { if (openIndex === null) return; document.body.style.overflow = "hidden"; const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") close(); if (e.key === "ArrowRight") showPrev(); // RTL: right arrow moves to the previous item if (e.key === "ArrowLeft") showNext(); }; window.addEventListener("keydown", onKey); return () => { document.body.style.overflow = ""; window.removeEventListener("keydown", onKey); }; }, [openIndex, close, showNext, showPrev]); return ( <> {openIndex !== null && (
{openIndex + 1} / {images.length} {images.length > 1 && ( <> )}
e.stopPropagation()} > {`${alt}
)} ); }