No.409 · Stats
Then / Now Stats
Stats that show the change, not just the value: each number carries a ghost of where it was, and a small bracket draws from then to now with the difference on it.
The prompt
The design brief behind this component — reuse it to regenerate, remix, or explain it.
Build a stats row that shows change rather than just values. Four cells in one rounded container with 1px gaps as dividers. Each cell: a mono uppercase label; the current value in large serif tabular figures (with a small unit); beneath it a 'rail' — the previous value in mono with a strike-through on the left, a thin bracket drawn across the middle (an SVG path, pathLength 1, stroke-dashoffset 1 → 0 over 1.2s), and a delta pill on the right ('▲ 42.0%'); and a muted sentence saying what the comparison is. When the row scrolls 40% into view, each value counts from its old value to its new one (1.4s, ease-out quart), the bracket draws (staggered 120ms per cell), and the delta pill fades up after it. Whether a change is good depends on the metric (`better: 'up' | 'down'`): good deltas use the accent, bad ones rose. Each cell has hidden text reading the whole comparison. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Scroll it into view — the numbers travel from then to now. Motion: 1.4s count with ease-out quart; bracket draw 1.2s; delta pill 500–600ms, staggered 120ms per cell. Accessibility: A <dl> of term/definition pairs with a full sentence per stat for screen readers; decorative rails are aria-hidden. Reduced motion shows final values immediately. Responsive behavior: auto-fit grid, minimum 13rem per cell. Touch: No interaction required. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Scroll it into view — the numbers travel from then to now.
- Motion
- 1.4s count with ease-out quart; bracket draw 1.2s; delta pill 500–600ms, staggered 120ms per cell.
- Accessibility
- A <dl> of term/definition pairs with a full sentence per stat for screen readers; decorative rails are aria-hidden. Reduced motion shows final values immediately.
- Responsive
- auto-fit grid, minimum 13rem per cell.
- On touch
- No interaction required.