import { useEffect } from 'react'; import { XIcon } from './icons'; // Fullscreen image viewer. Backdrop click + Esc close. Originally lived // inside AttachmentImage.tsx as a file-private component; extracted here // so other surfaces (settings avatar preview, future profile popover, // etc.) can reuse the exact same dialog without duplicating the chrome. // // The image itself stops click propagation so a click on the picture // keeps the lightbox open — only the backdrop or the explicit close // button dismisses. export function Lightbox({ url, onClose }: { url: string; onClose: () => void }) { useEffect(() => { function onKey(e: KeyboardEvent) { if (e.key === 'Escape') onClose(); } document.addEventListener('keydown', onKey); const prevOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.removeEventListener('keydown', onKey); document.body.style.overflow = prevOverflow; }; }, [onClose]); return (
e.stopPropagation()} className="max-h-[92vh] max-w-[92vw] rounded-xl object-contain shadow-2xl" />
); }