import { useState, useEffect, useCallback } from 'react'; import { X } from 'lucide-react'; interface ImageBlockProps { src: string; alt?: string; } function Lightbox({ src, alt, onClose }: ImageBlockProps & { onClose: () => void }) { const handleKey = useCallback((e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }, [onClose]); useEffect(() => { document.addEventListener('keydown', handleKey); return () => document.removeEventListener('keydown', handleKey); }, [handleKey]); return (
{alt e.stopPropagation()} />
); } export function ImageBlock({ src, alt }: ImageBlockProps) { const [lightbox, setLightbox] = useState(false); return ( <>
{lightbox && setLightbox(false)} />} ); } // buildImageSrc moved to ../lib/image.ts