import { useEffect } from 'react' import { imgUrl } from '../api' export default function Lightbox({ photos, index, onClose, onNav, footer }) { const photo = photos[index] useEffect(() => { const onKey = (e) => { if (e.key === 'Escape') onClose() if (e.key === 'ArrowRight' && index < photos.length - 1) onNav(index + 1) if (e.key === 'ArrowLeft' && index > 0) onNav(index - 1) } window.addEventListener('keydown', onKey) return () => window.removeEventListener('keydown', onKey) }, [index, photos.length, onClose, onNav]) useEffect(() => { document.body.style.overflow = 'hidden' return () => { document.body.style.overflow = '' } }, []) if (!photo) return null return (