import { useEffect } from 'react'; import styles from './ImageLightbox.module.css'; interface Props { src: string | null; onClose: () => void; } export function ImageLightbox({ src, onClose }: Props) { useEffect(() => { if (!src) return; const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', handler); return () => window.removeEventListener('keydown', handler); }, [src, onClose]); if (!src) return null; return (
{ if (e.target === e.currentTarget) onClose(); }}>
); }