import { useEffect } from 'react'; import { createPortal } from 'react-dom'; import './PaintingLightbox.css'; interface Props { src: string; alt: string; title?: string; subtitle?: string; closeHint?: string; onClose: () => void; onDetails?: () => void; } export default function PaintingLightbox({ src, alt, title, subtitle, closeHint = 'Click anywhere to close', onClose, onDetails, }: Props) { useEffect(() => { const prevOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); return () => { document.body.style.overflow = prevOverflow; window.removeEventListener('keydown', onKey); }; }, [onClose]); return createPortal(