/** * @file ImageLightbox.tsx * @description One image shown full size over the whole page; a click or * Escape closes it. Rendered into `document.body`, so no pane, its stacking * layer or a header drawn over a pane can cover it — opened from inside a * pane's Chat view, a `fixed` overlay would otherwise stay in that pane's * layer, under anything stacked above it. `useDialog` takes the focus while it * is open and gives it back, and its Escape closes only this, the top dialog. * @author Nguyễn Ngọc Trí Vĩ */ import { useRef } from "react"; import { createPortal } from "react-dom"; import { useDialog } from "../hooks/useDialog"; export function ImageLightbox({ src, alt, onClose, }: { src: string; alt: string; onClose: () => void; }) { const panel = useRef(null); useDialog(true, panel, onClose); return createPortal(
{alt}
, document.body ); }