3.0 KiB
3.0 KiB
Stat And Metric Cards
- Status:
completed - Owner:
codex - Date:
2026-03-25
Goal
Add two dashboard-oriented composition components to @ai-ui/ui: a compact StatCard
for the common label/value/delta/description KPI pattern, and a richer MetricCard
that extends the same pattern with media, footer, and action regions for analytics
panels.
Scope
- In scope:
- add
StatCardandMetricCardcomponent source, variants, exports, tests, and docs - expose stable slot and state metadata consistent with the repo contract
- refactor the new revenue dashboard scene to consume the components where they fit
- add
- Out of scope:
- introducing a full dashboard layout system
- replacing all existing card-based compositions across the repo
- expanding the chart system beyond what already exists
Constraints
- Follow the active Material-inspired design direction in
DESIGN.md. - Keep the API small and slot-oriented rather than introducing a single oversized props surface.
- Reuse existing card tokens and motion recipes instead of creating a parallel styling layer.
- Preserve enough flexibility that richer panels can still compose custom chart and footer content.
Affected Surfaces
packages/ui/src/componentspackages/ui/src/index.tsapps/docs/src/componentsapps/docs/src/revenue-dashboard.stories.tsxdocs/exec-plans
Plan
- Implement
StatCardas a compact KPI card with semantic slots for eyebrow, label, value, delta, and description. - Implement
MetricCardon the same visual and slot contract, adding media, footer, and actions regions plus layout variants. - Add focused tests and Storybook stories that document the standard usage, anatomy, and review guidance.
- Refactor the revenue dashboard scene to consume the new components for representative panels.
- Run focused validation and record any unrelated repository issues that remain.
Validation
pnpm --filter @ai-ui/ui typecheckpnpm --filter @ai-ui/ui testpnpm build:docs
Orchestration Task Sketch
T1: implementStatCardandMetricCardsource plus exportsT2 -> T1: add stories/tests and refactor the revenue dashboard sceneT3 -> T2: run focused validation and document residual issues
Status Log
2026-03-25 16:16started the stat/metric card slice after confirming the current dashboard scene still relies on repeated KPI glue code2026-03-25 16:27implementedStatCardandMetricCard, exported them from@ai-ui/ui, added tests and Storybook stories, and refactored representative revenue-dashboard panels onto the new components2026-03-25 16:31validatedpnpm --filter @ai-ui/ui typecheck,pnpm --filter @ai-ui/ui test,pnpm build, andpnpm build:docs2026-03-25 16:33noted that the running Storybook dev session still carries unrelated development noise from other in-flight docs slices (progress.stories.tsxindex warnings and anInputGroupruntime export mismatch on the dashboard iframe), but the package build and Storybook production build both pass