'use client' import { useEffect, useRef, useState } from 'react' import TagSelector from '@/components/tags/TagSelector' interface Props { url: string name: string onClose: () => void onPrev?: () => void onNext?: () => void itemKey?: string onTagsChanged?: () => void } export default function ImageLightbox({ url, name, onClose, onPrev, onNext, itemKey, onTagsChanged }: Props) { const overlayRef = useRef(null) const [showTags, setShowTags] = useState( () => !!itemKey && typeof window !== 'undefined' && window.innerWidth >= 1280 ) useEffect(() => { const handleKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() if (e.key === 'ArrowLeft') onPrev?.() if (e.key === 'ArrowRight') onNext?.() } document.addEventListener('keydown', handleKey) document.body.style.overflow = 'hidden' return () => { document.removeEventListener('keydown', handleKey) document.body.style.overflow = '' } }, [onClose, onPrev, onNext]) const handleOverlayClick = (e: React.MouseEvent) => { if (e.target === overlayRef.current) onClose() } return (
{/* Toolbar */}
{name}
{itemKey && ( )}
{showTags ? (
{/* Image */}
{/* eslint-disable-next-line @next/next/no-img-element */} {name} e.stopPropagation()} /> {onPrev && ( )} {onNext && ( )}
{/* Tag panel */}
e.stopPropagation()} >

Tags

) : (
{/* eslint-disable-next-line @next/next/no-img-element */} {name} e.stopPropagation()} /> {onPrev && ( )} {onNext && ( )}
)}
) }