StealThis .dev

Science — Figure + Numbered Caption

A reusable scientific figure-block primitive for journal-style web articles. Each block pairs an inline-SVG chart with a bold numbered label, a descriptive caption, and a source line; an on-hover toolbar lets readers expand the figure to a focus-trapped lightbox, copy a formatted citation, or download the underlying vector as standalone SVG. Ships three layout variants — full-width, half-width, and a labelled multi-panel grid — built with vanilla JS, no charting libraries, and tuned for AA contrast and 360px screens.

Open in Lab
html css vanilla-js
Targets: JS HTML

Code

Figure + Numbered Caption

A small but disciplined building block for research-grade web articles: a <figure> that always carries a bold “Figure N.” label, a descriptive caption, and a muted source line set in Inter — the typographic conventions readers expect from a journal. The chart artwork is drawn entirely with inline SVG and CSS (line series with a bootstrap confidence band, a bar chart with error whiskers, a JS-generated correlation heatmap, and a three-panel grid), so there is no dependency on KaTeX, Chart.js, or any runtime library.

Every figure exposes a compact toolbar that fades in on hover or keyboard focus. Expand clones the figure into a focus-trapped lightbox overlay (Escape or backdrop click to close, focus returned to the trigger). Cite writes a fully formatted citation — fictional authors, arXiv ID, and DOI — to the clipboard with a graceful execCommand fallback. Download serializes the chart’s SVG to a Blob and saves it as figure-N.svg. A single delegated click handler and a reusable toast() helper keep the script tiny.

The page demonstrates three reusable variants — full-width, two half-width side by side, and a multi-panel block with (a)(b)(c) sub-labels and per-panel captions. Variables are set in serif italics and all numbers, units, and DOIs use JetBrains Mono. Everything collapses to a single column and keeps the toolbar visible below 640px, with horizontal scroll for charts on the narrowest screens.

Illustrative UI only — fictional authors, data, and figures; not real scientific results.