Hero Evaluation
A large illustrative hero SVG for evaluation-metrics explainers — a good ROC curve builds step-by-step with its AUC area filling and a counter ticking up, a worse model overlays for dramatic contrast, and a TP/FP/FN/TN confusion-matrix legend pops in. Theme-driven via currentColor + configurable accentColor and warnColor props; reduced-motion users see the final state instead of the loop.
Customize
Hero illustration
400px
accent
Installation
npx shadcn@latest add https://craftbits.dev/r/hero-evaluation.jsonUsage
import { HeroEvaluation } from "@craft-bits/core/svg/hero-evaluation";
<HeroEvaluation size={400} />
// Tint via the parent text color (drives the good curve / AUC fill).
<div className="text-cb-accent">
<HeroEvaluation />
</div>Understanding the component
- Continuous storyboard. A single
useEffectschedules the full ~9s cycle: axes + diagonal baseline, good ROC curve draws, AUC area fills, good AUC counter ticks up to 0.92, worse model curve + fill overlay, worse AUC counter ticks up to 0.61, confusion-matrix legend pops in (staggered), good fill pulse, fade out, reset, loop. Every timer is cleaned up on unmount and when reduced-motion changes. - Motion values, not re-renders. Curve
pathLength, fill opacity, readout opacity, and per-cell legend opacity are all driven bymotion'suseMotionValue+useSpringso the React tree never re-renders during the loop. Springs come from@craft-bits/core/motion(SPRINGS.smooth,SPRINGS.slow,SPRINGS.bouncy,SPRINGS.snap). - Theme-driven color. Axes, baseline, tick marks, axis labels, and caption all use
currentColor, so anytext-cb-*utility tints the chrome. TheaccentColorprop tints the good ROC curve, its AUC fill, and its readout; thewarnColorprop tints the worse curve and its readout — both accept any CSS color (includingvar(--color-accent-500)). - Reduced-motion safe. When
prefers-reduced-motion: reduceis set, the loop short-circuits to the static end state — both curves drawn, both AUC readouts visible (0.92 and 0.61), confusion-matrix legend filled in. No timers, noanimate()calls.
Variants / Examples
// Compact thumbnail.
<HeroEvaluation size={200} />
// Explicit accent + warn colors.
<HeroEvaluation
size={480}
accentColor="var(--color-accent-300)"
warnColor="var(--color-warn-500)"
/>
// Custom hex.
<HeroEvaluation accentColor="#8b5cf6" warnColor="#ef4444" />Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | number | 400 | Pixel width. Height is computed from the 400×280 aspect ratio. |
accentColor | string | 'currentColor' | Any CSS color. Tints the good ROC curve, AUC fill, and AUC readout. |
warnColor | string | '#f59e0b' | Any CSS color. Tints the worse ROC curve, its AUC fill, and AUC readout. |
className | string | — | Extra classes merged onto the root <svg>. |
...rest | SVGAttributes<SVGSVGElement> | — | Other SVG props forwarded to the root. |
Accessibility
- The root
<svg>carriesaria-hidden="true"— the illustration is decorative; pair it with a visible heading or caption in its surrounding context. - Motion respects
prefers-reduced-motion: reduce: the loop short-circuits and renders the final state. - Chrome flows from
currentColor, so contrast tracks the consumer's text tokens — no hardcoded hex values for chrome.
Credits
- Extracted from:
craftingattention(app/src/lessons/primitives/chrome/icons/heroes/HeroEvaluation.tsx). - Inspiration: classic ROC + AUC illustrations — "know whether you are actually better."