import { useState } from 'react' import Lightbox from 'react-image-lightbox' import 'react-image-lightbox/style.css' import Image from './Image' const PhotoGallery = (props) => { const { title, data } = props const [isOpen, setIsOpen] = useState(false) const [photoIndex, setPhotoIndex] = useState(0) return (
{data.length ? data.map((d: string, index: number) => ( {title} { setPhotoIndex(index) setIsOpen(true) }} src={d} className="w-1/4 cursor-pointer object-cover" width="300px" height="300px" /> )) : null} {isOpen && ( setIsOpen(false)} onMovePrevRequest={() => setPhotoIndex((photoIndex + data.length - 1) % data.length)} onMoveNextRequest={() => setPhotoIndex((photoIndex + 1) % data.length)} /> )}
) } export default PhotoGallery