import React, { useEffect } from 'react'; export default function Lightbox({ images, currentIndex, onClose, onNext, onPrev }) { useEffect(() => { const handleKeyDown = (e) => { if (e.key === 'Escape') { onClose(); } else if (e.key === 'ArrowRight') { onNext(); } else if (e.key === 'ArrowLeft') { onPrev(); } }; document.addEventListener('keydown', handleKeyDown); return () => { document.removeEventListener('keydown', handleKeyDown); }; }, [onClose, onNext, onPrev]); if (!images || images.length === 0) return null; return (
e.stopPropagation()}> {/* Prevent closing when clicking on image */} {`Gallery {/* Close Button */} {/* Navigation Buttons */} {images.length > 1 && ( <> )} {/* Image Counter */}
{currentIndex + 1} / {images.length}
); }