/** * ImageView shows a workspace image (png, jpeg, gif, webp, svg, bmp, ico, * avif) at its natural size, capped to the pane width, over a checkerboard * that reveals transparency. The bytes stream from GET /api/raw, and the * natural dimensions appear once the browser has decoded the image. * * @example * */ import { useState } from "react"; import { rawFileUrl } from "../api"; export function ImageView({ path }: { path: string }) { const [size, setSize] = useState<{ width: number; height: number } | null>( null, ); const [failed, setFailed] = useState(false); if (failed) { return

the image could not be loaded

; } return (
{path.split("/").pop() { const img = event.currentTarget; setSize({ width: img.naturalWidth, height: img.naturalHeight }); }} onError={() => setFailed(true)} />
{size ? `${size.width} × ${size.height} px` : "loading…"}
); }