basalt-ui 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/MIGRATING.md +291 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +10 -23
- package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
- package/agent/skills/basalt-design/references/catalogue.md +48 -0
- package/agent/skills/basalt-design/references/concept.md +36 -0
- package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
- package/agent/skills/basalt-design/references/stat-tile.md +24 -0
- package/agent/templates/AGENTS-block.md.tpl +3 -3
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +34 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +33 -4
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +37 -11
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +13 -1
- package/dist/charts/Heatmap.js +1 -1
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +137 -18
- package/dist/charts/box.d.ts +2 -0
- package/dist/charts/box.d.ts.map +1 -1
- package/dist/charts/box.js +2 -0
- package/dist/charts/chart-box.module.css +30 -0
- package/dist/charts/chart-box.module.css.d.ts +1 -0
- package/dist/charts/chart-card.module.css +47 -0
- package/dist/charts/chart-card.module.css.d.ts +7 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +35 -8
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +2 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/sparkline.module.css +59 -0
- package/dist/charts/sparkline.module.css.d.ts +13 -0
- package/dist/charts/state.d.ts +5 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +34 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +3 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -2
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +27 -15
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +6 -1
- package/dist/cli/shot/detect.d.ts +51 -0
- package/dist/cli/shot/detect.d.ts.map +1 -0
- package/dist/cli/shot/detect.js +396 -0
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +7 -4
- package/dist/cli/shot/measure.d.ts +2 -0
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +2 -0
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/common/retry-button.d.ts +12 -0
- package/dist/common/retry-button.d.ts.map +1 -0
- package/dist/common/retry-button.js +22 -0
- package/dist/common/retry-button.module.css +58 -0
- package/dist/common/retry-button.module.css.d.ts +8 -0
- package/dist/controls/sync-button.d.ts +3 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/dashboard/bar-list.d.ts +18 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +39 -15
- package/dist/dashboard/bar-list.module.css +77 -2
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +53 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +62 -14
- package/dist/dashboard/meter-parts.d.ts +5 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +140 -68
- package/dist/dashboard/meter.d.ts +29 -4
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +8 -1
- package/dist/dashboard/meter.module.css +74 -43
- package/dist/dashboard/meter.module.css.d.ts +4 -4
- package/dist/dashboard/query-state.d.ts +1 -1
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +16 -10
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +1 -1
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +5 -7
- package/dist/dashboard/stat-card.module.css +15 -7
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +67 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +115 -0
- package/dist/dashboard/stat-strip.module.css +291 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +32 -0
- package/dist/dashboard/visual-slot.d.ts +2 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +5 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.module.css +10 -6
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +16 -3
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +15 -1
- package/dist/guard/palette.d.ts +51 -0
- package/dist/guard/palette.d.ts.map +1 -0
- package/dist/guard/palette.js +190 -0
- package/dist/guard/series-file.d.ts +15 -0
- package/dist/guard/series-file.d.ts.map +1 -0
- package/dist/guard/series-file.js +29 -0
- package/dist/guard/types.d.ts +3 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/styles.css +6 -0
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/controls.module.css +13 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +41 -0
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +3 -2
- package/dist/theme/status-dot.d.ts.map +1 -1
- package/dist/theme/status-dot.js +12 -3
- package/dist/theme/status-verdict.d.ts +3 -2
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +3 -2
- package/dist/theme/status-verdict.module.css +4 -2
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/llms.txt +33 -7
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +79 -5
- package/src/charts/Donut.tsx +9 -1
- package/src/charts/Heatmap.tsx +1 -1
- package/src/charts/Sparkline.tsx +180 -18
- package/src/charts/box.tsx +2 -0
- package/src/charts/chart-box.module.css +30 -0
- package/src/charts/chart-box.module.css.d.ts +1 -0
- package/src/charts/chart-card.module.css +47 -0
- package/src/charts/chart-card.module.css.d.ts +7 -0
- package/src/charts/compile.ts +42 -9
- package/src/charts/host.tsx +6 -3
- package/src/charts/index.ts +1 -1
- package/src/charts/sparkline.module.css +59 -0
- package/src/charts/sparkline.module.css.d.ts +13 -0
- package/src/charts/state.tsx +53 -4
- package/src/charts/types.ts +6 -0
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +2 -1
- package/src/cli/shot/capture.ts +15 -2
- package/src/cli/shot/detect.ts +533 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/types.ts +5 -1
- package/src/cli/sync.ts +4 -2
- package/src/common/retry-button.module.css +58 -0
- package/src/common/retry-button.module.css.d.ts +8 -0
- package/src/common/retry-button.tsx +29 -0
- package/src/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +77 -2
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +89 -18
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +126 -20
- package/src/dashboard/meter-parts.tsx +224 -88
- package/src/dashboard/meter.module.css +74 -43
- package/src/dashboard/meter.module.css.d.ts +4 -4
- package/src/dashboard/meter.tsx +39 -5
- package/src/dashboard/query-state.tsx +26 -20
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +15 -7
- package/src/dashboard/stat-card.tsx +9 -9
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +291 -0
- package/src/dashboard/stat-strip.module.css.d.ts +32 -0
- package/src/dashboard/stat-strip.tsx +263 -0
- package/src/dashboard/visual-slot.ts +8 -0
- package/src/dashboard/widget-header.module.css +10 -6
- package/src/dashboard/widget-header.tsx +3 -3
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +17 -5
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +202 -24
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/controls.module.css +13 -0
- package/src/theme/index.ts +56 -0
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.tsx +17 -5
- package/src/theme/status-verdict.module.css +4 -2
- package/src/theme/status-verdict.tsx +9 -4
- package/src/tokens/oklab.ts +97 -0
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: basalt-design
|
|
3
|
-
description: Build or restyle dashboards and metric UIs in a basalt-ui app —
|
|
3
|
+
description: Build or restyle dashboards and metric UIs in a basalt-ui app — concept first, then encoding, build, then rounds of screenshots scored by a reviewer subagent.
|
|
4
4
|
when_to_use: User is building or restyling dashboards, charts or metric UIs; tuning a palette; or says a UI looks inconsistent, over-colored or "AI default". Entry point for "make this look professional".
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Method only; the law is `.claude/rules/basalt-*.md` and `./DESIGN.md`.
|
|
7
|
+
Method only; the law is `.claude/rules/basalt-*.md` and `./DESIGN.md`. Each step loads its reference on demand.
|
|
8
8
|
|
|
9
9
|
## Steps
|
|
10
10
|
|
|
11
|
-
1.
|
|
12
|
-
2. **Scenario
|
|
13
|
-
3. **
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| ----------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
17
|
-
| Single value with a trend | figure, text delta, `qualifier`, axis-less sparkline (end dot) along the card's bottom | `StatCard` + `sparkline` slot (`Sparkline`) |
|
|
18
|
-
| Value over time | line or stacked area | `Lines` / `StackedArea` in a `ChartCard` |
|
|
19
|
-
| Compare categories | bars | `Bars layout="grouped"` |
|
|
20
|
-
| Part of a whole, 2–6 parts | one segmented (stacked) bar, parts in order — not a donut plus a total card, not a row of N `StatCard`s | `Bars` (stacked, the default) |
|
|
21
|
-
| Distribution | small axis-less histogram | `Bars` in a `ChartCard` |
|
|
22
|
-
| Status over time | band strip; a heat grid for daily data | `BandStrip` / `Heatmap` |
|
|
23
|
-
| Many rows, several attributes | table, right-aligned mono figures | `BasaltDataTable` |
|
|
24
|
-
| Nothing yet / failed | why + what to do | `EmptyState` / the component's own state |
|
|
25
|
-
|
|
26
|
-
No row fits the data → say so; never default to a number in a box.
|
|
27
|
-
|
|
28
|
-
4. Build with Mantine primitives and the composites; every color from `VX.*` or a series token. Tune by eye in the theme lab (`dev.theme` Spotlight command, dev only) in both schemes, then bake values into the `derive` knobs of `createBasaltTheme` and series colors into `src/lib/series.ts`.
|
|
29
|
-
5. **Mark up for the board.** Tag each scored component `data-shot="<name>"`; hover and tooltip targets inside it get `data-shot-hover` / `data-shot-tooltip`; when the target's centre paints no readout (a donut's hole), add `data-shot-at="x,y"` (fractions of its box, e.g. `0.25,0.2`) and the shot hovers there. Declare supported states with `data-shot-states="empty loading error"` and render them when the `shot-state` URL param asks.
|
|
11
|
+
1. **Concept — mandatory, gating.** Nothing is built before the concept exists: write `docs/design/<screen>.md` (the user's question, the decision, datasets and chosen encodings, layout at 1440 and 390, copy, pass criteria) before any component code. Template: `references/concept.md`. Also read `./DESIGN.md` and the rules `basalt-tokens.md`, `basalt-mantine.md`, `basalt-controls.md`, `basalt-charts.md`; no `DESIGN.md`: run `/basalt-app` first.
|
|
12
|
+
2. **Scenario.** Realistic fixture data. Decide which metrics earn a hue (trend, status, separation; the rest neutral), the one primary action per view, each control's home (a `SettingsRow` preference via `createLocalStore`, never `useState`).
|
|
13
|
+
3. **Encoding: is it even a chart?** Run the router, then pick each encoding from the data's shape, then the shipped composite. A gap is reported, not routed around; no row fits the data → say so, never default to a number in a box. `references/catalogue.md`. A metric tile follows the slot contract in `references/stat-tile.md`.
|
|
14
|
+
4. **Build** with Mantine primitives and the composites; every color from `VX.*` or a series token. Chart kinds and `ChartCard` import from `basalt-ui/charts`, `BasaltDataTable` from `basalt-ui/table`, `FilterSet` and the other filters from `basalt-ui/controls`, the rest from `basalt-ui`. Hold the encoding law (`references/encoding-rules.md`: axes, color, tooltips, refetch, filters, number typography) and avoid the dashboard tells (`references/anti-defaults.md`: fact-only copy, uniform cards, one radius). Tune by eye in the theme lab (`dev.theme` Spotlight command, dev only) in both schemes, then bake values into the `derive` knobs of `createBasaltTheme` and series colors into `src/lib/series.ts`.
|
|
15
|
+
5. **Mark up for the board.** Tag each scored component `data-shot="<name>"`; hover and tooltip targets inside it get `data-shot-hover` / `data-shot-tooltip`; when the target's centre paints no readout (a donut's hole), add `data-shot-at="x,y"` (fractions of its box, e.g. `0.25,0.2`) and the shot hovers there. Declare supported states with `data-shot-states="empty loading error"` and render them when the `shot-state` URL param asks. An anchor legitimately absent in some states declares them with `data-shot-absent="empty error"`.
|
|
30
16
|
6. **Rounds, at least three.** Playwright is the app's dev dependency: `bun add -d playwright && bunx playwright install chromium`. Then:
|
|
31
17
|
- `basalt-ui shot <routes> --dist <built app>` (or `--base <url>` for a running server); a real, signed-in app (live data, no `data-shot` yet): `basalt-ui shot /overview --dist dist --api /api=https://app.example.com --local-storage auth-token=@env:APP_TOKEN --auto-anchors` seeds the token (app origin only; `@env:`/`@file:`, never inline), proxies GET/HEAD under `/api` (writes get 405 unless `--api-allow-writes`) and crops every large Card, Paper and table. One `--header authorization=@env:NAME` goes to EVERY `--api` origin (https required for any secret), never on a navigation. A redirect, 401/403/404, 5xx or dead API fails every shot of that page; a key the app already holds is never overwritten. These shots reach the reviewer subagent's model provider, the session's own: an app holding third parties' data should point `--api` at staging or synthetic data;
|
|
32
|
-
- hand the out dir (`.basalt/shots`) to the `basalt-design-reviewer` subagent by name; it reads each component's contact sheet (`png/*__sheet.png`) and every page shot;
|
|
18
|
+
- review with TWO isolated passes: (A) hand the out dir (`.basalt/shots`) to the `basalt-design-reviewer` subagent by name; it reads each component's contact sheet (`png/*__sheet.png`) and every page shot; (B) run the deterministic detector `basalt-ui shot detect` on the same out dir (exit 0 clean / 2 findings / 1 scan failure). A review the builder runs inline instead of the subagent starts with a `DEGRADED` banner and does not count as done;
|
|
19
|
+
- judge content first, then layout, then style; rank findings P0–P3;
|
|
33
20
|
- revise every failing item at its source, rebuild, and shoot again.
|
|
34
21
|
Boards stay local (gitignored); the scored verdict and notes are worth committing.
|
|
35
|
-
7. **Done** only when the reviewer passes every component, and never before round three: a pass earlier does not end the loop. After five failed rounds stop and show the owner the boards and the failing items.
|
|
22
|
+
7. **Done** only when both passes are clean (the reviewer passes every component, `basalt-ui shot detect` exits 0), and never before round three: a pass earlier does not end the loop. After five failed rounds stop and show the owner the boards and the failing items.
|
|
36
23
|
8. Run the repo's own gate (e.g. `make check`); fix every finding at its source. `shot` captures desktop (1440) and mobile (390) in both schemes; check both.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Anti-defaults
|
|
2
|
+
|
|
3
|
+
## Fact-only copy
|
|
4
|
+
|
|
5
|
+
- The banned-filler list lives in the `basalt-design-reviewer` subagent; do not duplicate it, write to it.
|
|
6
|
+
- A page summary sentence carries at least one live number ("12 tickets open, 3 past SLA."); a summary with none is cut.
|
|
7
|
+
- Titles are precise nouns with their scope ("Ride distance, 7 days"). Empty states say why and what to do.
|
|
8
|
+
|
|
9
|
+
## Dashboard tells
|
|
10
|
+
|
|
11
|
+
| Tell | Do instead |
|
|
12
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| Equal-width rounded cards in a uniform grid | Pair cards by what they answer; let the lead card span; `StatGroup variant="strip"` for KPIs about one record |
|
|
14
|
+
| One radius everywhere, regardless of hierarchy | Use the theme radius steps; nested surfaces step down by at least 3 px |
|
|
15
|
+
| The same soft shadow under every tile | Let `StatCard`, `ChartCard` and `Section` own their surface; add none |
|
|
16
|
+
| A delta with no period | `deltaPeriod` / `DeltaBadge` `period` ("vs last week") |
|
|
17
|
+
| A coloured left edge for status | `StatCard` `tone` (status dot plus a word) |
|
|
18
|
+
| Filler-question subtitles ("How is my training going?") | A number or fact line, or nothing |
|
|
19
|
+
| A big number in a box with no history, target or parts | Add a `sparkline` slot (`Sparkline`, or `Meter` with `target`); if there is none, it belongs in a strip cell |
|
|
20
|
+
| Columns ending unbalanced, a dead void beside a short card | Pair cards of similar height in a row, or let the short card span or move |
|
|
21
|
+
| Heavy filled bar slabs with labels inside | `BarList`'s default rows: a thin track carries the same data; avoid the slab look |
|
|
22
|
+
| A marker that restates the headline value | Mark the target or the limit, not the reading |
|
|
23
|
+
| Unlabelled marks with no axis or scale | Direct-label the end points, or add an axis; or use a table (`BasaltDataTable`) |
|
|
24
|
+
| Three rows of KPI cards | One strip, then the chart or list that explains it |
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Encoding catalogue
|
|
2
|
+
|
|
3
|
+
Shipped composites: `StatCard`, `ChartCard`, `Section`, `WidgetHeader`, `BasaltDataTable`, `EmptyState`. Imports: chart kinds and `ChartCard` from `basalt-ui/charts`, `BasaltDataTable` from `basalt-ui/table`, the rest from `basalt-ui`. A gap is reported, never hand-rolled. The reviewer cites this file for Expression 1: the data's shape and the encoding used must match a row here.
|
|
4
|
+
|
|
5
|
+
## 1. Is it even a chart?
|
|
6
|
+
|
|
7
|
+
Run this first. A "yes, chart" answer sends you to § 2.
|
|
8
|
+
|
|
9
|
+
| The data is | Not this | Use |
|
|
10
|
+
| ------------------------------- | ---------------- | ------------------------------------------------------- |
|
|
11
|
+
| One current value | A one-bar chart | `StatCard` (`stat-tile.md`) |
|
|
12
|
+
| A handful of headline numbers | A grouped bar | `StatGroup variant="strip"` or a row of `StatCard` |
|
|
13
|
+
| One ratio against a limit | A two-slice pie | `Meter` with a target tick |
|
|
14
|
+
| More than ~7 meaningful classes | More colours | `BasaltDataTable` |
|
|
15
|
+
| Fewer than 4 points | A line | `StatCard` |
|
|
16
|
+
| 3–10 target-vs-actual metrics | A bar per metric | A grid of `Meter`s with `target` (basalt's bullet form) |
|
|
17
|
+
|
|
18
|
+
## 2. Data shape to expression
|
|
19
|
+
|
|
20
|
+
| Data shape | Encoding | basalt export (import path) | Not this |
|
|
21
|
+
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------ |
|
|
22
|
+
| Single value with a trend | Figure, text delta, `qualifier`, axis-less sparkline with end dot along the bottom | `StatCard` (`basalt-ui`) + `sparkline` slot with `Sparkline` (`basalt-ui/charts`) | A bare number in a box |
|
|
23
|
+
| Progress to a target | Filled track, target tick, end captions; extra cut-offs as `ticks` | `Meter` (`basalt-ui`) with `target`, `ticks` | A hand-rolled progress bar |
|
|
24
|
+
| Committed vs forecast | Two segments, the forecast lighter, a tick and a caption at the boundary | `Meter` `segments`, `forecastCaption` | Two cards |
|
|
25
|
+
| Headline ratio where the shape is the message | Ring, value centred, one per row | `Meter shape="ring"` | A donut plus a total card |
|
|
26
|
+
| Reading in named bands (low / ok / high) | Zoned bar with the reading as a marker; `ticks` mark cut-offs or a window mean | `Meter` `zones`, `ticks` | Colour-only thresholds |
|
|
27
|
+
| Part of a whole, 2–6 parts | One segmented bar, parts in order, captions under the segments | `Meter` `segments`; `Bars` stacked | A row of N `StatCard`s; a donut |
|
|
28
|
+
| Part of a whole when the parts are the page's subject | Donut | `Donut` (`basalt-ui/charts`) | Donut beside a total card |
|
|
29
|
+
| Ranked list, top N (5–10) | Label, bar on a shared scale, right-aligned value | `BarList` (`basalt-ui`), its default thin-track rows | A table with a `%` column |
|
|
30
|
+
| Value over time | Line; stacked area for parts of a total | `Lines` / `StackedArea` in a `ChartCard` | A bar per day |
|
|
31
|
+
| Compare categories | Bars | `Bars layout="grouped"` in a `ChartCard` | A pie |
|
|
32
|
+
| Distribution as a slot micro-visual (`StatCard`, strip cell) | Small axis-less histogram | `Bars`, no axes, in the slot | A mean alone |
|
|
33
|
+
| Distribution as a card's subject | One bar per bin, x labelled with the bin range ("€0–50"), y axis optional | `Bars` in a `ChartCard` | A mean alone; an axis-less histogram |
|
|
34
|
+
| Status over time | Band strip; heat grid for daily data | `BandStrip` / `Heatmap` (`basalt-ui/charts`) | A table of dates |
|
|
35
|
+
| A set of KPIs about one record | One joined surface, cells split by hairlines | `StatGroup variant="strip"` | N unrelated cards |
|
|
36
|
+
| Many rows, several attributes | Table, right-aligned figures | `BasaltDataTable` (`basalt-ui/table`) | Cards per row |
|
|
37
|
+
| Nothing yet / failed | Why and what to do | `EmptyState`, or the component's own `query` state | "No data" |
|
|
38
|
+
|
|
39
|
+
## Not shipped — report the gap, don't hand-roll
|
|
40
|
+
|
|
41
|
+
| Shape | Missing |
|
|
42
|
+
| -------------------------------------------------------------------- | -------------- |
|
|
43
|
+
| Event sequence (day groups, time pinned right) | `EventList` |
|
|
44
|
+
| Work items by status (columns with counts) | `Board` |
|
|
45
|
+
| Record page (header, facts line, strip, events) and list-row recipes | recipes only |
|
|
46
|
+
| Bounded score inside a row | tick meter |
|
|
47
|
+
| Daily data over months with month labels | calendar grid |
|
|
48
|
+
| Gapless histogram with bin-edge ticks | histogram kind |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Concept doc — template
|
|
2
|
+
|
|
3
|
+
Write `docs/design/<screen>.md` before any component code. One doc per screen. The reviewer reads it as the contract; its pass criteria are what the shot rounds try to fail.
|
|
4
|
+
|
|
5
|
+
## Sections
|
|
6
|
+
|
|
7
|
+
| Section | Holds | Fails when |
|
|
8
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
|
|
9
|
+
| Question and decision | One sentence each: what the user asks of this screen, what they decide after reading it | The decision is "monitor" or "stay informed" |
|
|
10
|
+
| Datasets | One row per dataset: `dataset \| source \| shape \| chosen encoding \| basalt export \| reason` | A row has no shape from `catalogue.md`, or "default" as the reason |
|
|
11
|
+
| Layout at 1440 | Row by row: which cards pair, which span, what sits above the fold | Equal-width cards in a uniform grid with no stated reason |
|
|
12
|
+
| Layout at 390 | The single-column order; what collapses, what moves behind a disclosure | "Stacks" with no order |
|
|
13
|
+
| Copy | Page title, summary sentence (carries a live number), card titles, captions, facts lines, tooltips, empty and error text | Any line from the banned filler list, or a title that is a category |
|
|
14
|
+
| Pass criteria | Checkable sentences, numbered, each one a reviewer can fail on a crop | "Looks clean", "feels balanced" |
|
|
15
|
+
|
|
16
|
+
Add a baseline verdict (what the current screen gets wrong) when restyling. Append each round's verdict to the doc.
|
|
17
|
+
|
|
18
|
+
## Mini example — a support inbox
|
|
19
|
+
|
|
20
|
+
```md
|
|
21
|
+
# Support inbox — concept
|
|
22
|
+
|
|
23
|
+
Question: is the queue draining faster than it fills, and what needs me now?
|
|
24
|
+
Decision: reassign, escalate, or leave each aging ticket.
|
|
25
|
+
|
|
26
|
+
| dataset | source | shape | chosen encoding | basalt export | reason |
|
|
27
|
+
| ------------------- | ------------ | ----------------------------- | ------------------------------------- | ------------------------ | ----------------------------- |
|
|
28
|
+
| Open tickets by age | GET /tickets | ranked list, top N | rows with a bar on a shared scale | `BarList` | length ranks before reading |
|
|
29
|
+
| First-reply time | GET /stats | single value with a trend | figure, delta vs last week, sparkline | `StatCard` + `Sparkline` | history says if 4 h is normal |
|
|
30
|
+
| SLA budget used | GET /stats | one ratio against a limit | meter with a tick at the limit | `Meter` | the limit is visible |
|
|
31
|
+
| All tickets | GET /tickets | many rows, several attributes | table | `BasaltDataTable` | scanned by column |
|
|
32
|
+
|
|
33
|
+
Layout 1440: summary line; strip of 3 stat cells; BarList beside the SLA meter; table. 390: summary, strip (one column), meter, BarList, table.
|
|
34
|
+
Copy: "12 tickets open, 3 past SLA." Captions "First reply · 7 days". Empty: "No open tickets — the queue is clear."
|
|
35
|
+
Pass: 1. the summary carries a count. 2. every delta names its period. 3. the SLA meter shows the limit tick. 4. no card has an empty lower 40 %.
|
|
36
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Encoding rules
|
|
2
|
+
|
|
3
|
+
Checkable sentences. Each one is a reviewer fail.
|
|
4
|
+
|
|
5
|
+
## Nine non-negotiables
|
|
6
|
+
|
|
7
|
+
1. One axis per chart; never a dual axis.
|
|
8
|
+
2. Colour follows the entity, never its rank.
|
|
9
|
+
3. Categorical colours come in fixed order and never cycle; the ninth series folds into "Other".
|
|
10
|
+
4. Sequential scales are one hue, light to dark.
|
|
11
|
+
5. Diverging scales are two hues with a neutral grey midpoint.
|
|
12
|
+
6. Never a rainbow.
|
|
13
|
+
7. Status colours are reserved for status, and always paired with an icon or word, never colour alone.
|
|
14
|
+
8. Text wears text tokens (`VX.*`), never the series colour.
|
|
15
|
+
9. Markers are at least 8 px; hit areas at least 24 px.
|
|
16
|
+
|
|
17
|
+
## Tooltips enhance, never gate
|
|
18
|
+
|
|
19
|
+
- Every value is reachable without hover: direct labels, a caption under the segments, or a `BasaltDataTable` alongside.
|
|
20
|
+
- A tooltip shows the same content on keyboard focus as on hover.
|
|
21
|
+
- One tooltip for all series at a point (`chartCursor` on lines, the mark itself as hit target on bars).
|
|
22
|
+
- Values lead, labels follow ("12.4 K sessions", not "Sessions: 12.4 K").
|
|
23
|
+
- Label text is set as text, never as HTML.
|
|
24
|
+
|
|
25
|
+
## A refetch keeps the frame
|
|
26
|
+
|
|
27
|
+
- On refetch hold the previous render (React Query `placeholderData: keepPreviousData`); dim it, do not blank it.
|
|
28
|
+
- Skeletons are for the first load only, at the final footprint; there is no layout jump when data arrives or refreshes.
|
|
29
|
+
- A refetch that fails over existing data keeps the data and flags the failure (the `query` prop of `StatCard`, `Section` and `BasaltDataTable` branches this way); only no-data-and-failed shows the error.
|
|
30
|
+
- `StatStripCell` `stale` dims a cell while placeholder data shows.
|
|
31
|
+
|
|
32
|
+
## Filter grammar
|
|
33
|
+
|
|
34
|
+
- One left-aligned filter row above what it scopes (`PageBar` `filters` from `basalt-ui`; `FilterSet` (`basalt-ui/controls`), `RangeFilter` (`basalt-ui/controls`)).
|
|
35
|
+
- Date range comes first.
|
|
36
|
+
- Filters scope everything below them; never a filter inside one chart.
|
|
37
|
+
- A filter that empties a view offers "clear filters" in the `EmptyState`.
|
|
38
|
+
|
|
39
|
+
## Number typography
|
|
40
|
+
|
|
41
|
+
- Hero values, row labels and body text: proportional sans, lining figures.
|
|
42
|
+
- `tabular-nums` only in table columns and axis ticks.
|
|
43
|
+
- Mono only for UPPERCASE micro-captions, times and code.
|
|
44
|
+
- Ticks compact from 1,000: `0 / 1K / 2K`; values compact as `1,284 / 12.9K / $4.2M`.
|
|
45
|
+
- Every number carries its unit inline; a rate or total carries its period.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Stat tile — slot contract
|
|
2
|
+
|
|
3
|
+
A metric tile is `StatCard` (separate card) or a cell of `StatGroup variant="strip"` (joined surface). Read top to bottom; the reviewer fails a tile slot by slot.
|
|
4
|
+
|
|
5
|
+
| Slot | Prop (`StatCard`) | Required | The reviewer fails |
|
|
6
|
+
| ------------ | ----------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| Caption | `title` | Yes | Title case, a trailing colon, a category noun ("Metrics"), a label that restates the value |
|
|
8
|
+
| Qualifier | `qualifier` | When the figure has a period, target or source | A rate or total with no period anywhere on the tile |
|
|
9
|
+
| Value | `value` | Yes | A monospace or tabular figure (the hero is proportional sans, lining); a long number not compacted (`12.9K`, `$4.2M`); `0` or `n/a` for a missing reading (use `—`) |
|
|
10
|
+
| Unit | `unit` | When the figure has one | Unit spelled out at length; unit in the caption instead of beside the figure |
|
|
11
|
+
| Delta | `delta` + `deltaPeriod` (`DeltaBadge` `period`) | Optional | No named period ("▲ 4.2%" alone); a fill, pill or border on the delta; colour not following direction × whether up is good (`polarity="up-bad"` for latency, errors); a leading "+" |
|
|
12
|
+
| Micro-visual | `sparkline` | Whenever the number has history, a target or parts | A visual that restates the headline; one that encodes neither a target/limit nor the history; axes or gridlines; an empty lower 40 % |
|
|
13
|
+
| Footer | `subtitle` | Optional | A restatement of the caption; a raw key or parameter dump |
|
|
14
|
+
| Verdict | `tone` | Only when the number crossed a threshold | A coloured left edge instead; a tint on a reading with no verdict |
|
|
15
|
+
| Info tooltip | `info` | Only where the definition, period or source is not on the surface | A tooltip on a plain count of visible items; a definition that is the only place the period appears |
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
- Exactly three type sizes: micro (caption, qualifier, delta period), sm (unit, delta, footer), the hero.
|
|
20
|
+
- Delta colour is text, never a fill. Zero is faint with no glyph.
|
|
21
|
+
- A micro-visual encodes a target or limit (`Meter` with `target`, `Sparkline` with a reference line) or the history (`Sparkline` with its end dot). Anything else is decoration.
|
|
22
|
+
- A tile with no visual is allowed only when the number has no history, target or parts.
|
|
23
|
+
- In a strip cell the same slots apply (`caption`, `qualifier`, `value`, `unit`, `delta`, `visual`, `footer`, `info`); a cell with `null` value prints `—`.
|
|
24
|
+
- A pending query shows the tile's own skeleton, never a spinner; the caption row stays put.
|
|
@@ -21,7 +21,7 @@ under the depending package; `basalt-ui doctor` prints where; a fresh worktree n
|
|
|
21
21
|
**Skills and subagent** (installed in `.claude/`; invoke by name):
|
|
22
22
|
|
|
23
23
|
- `/basalt-app`: scaffold, wire, upgrade or verify the app (`init`, `doctor`, `sync`).
|
|
24
|
-
- `/basalt-design`: build or restyle a screen — scenario, `basalt-ui shot` rounds, review, revise.
|
|
24
|
+
- `/basalt-design`: build or restyle a screen — scenario, `basalt-ui shot` rounds, review, revise; routes to its `references/` on demand.
|
|
25
25
|
- `/basalt-charts`: add or extend a chart, register its series colors.
|
|
26
26
|
- `basalt-design-reviewer` (subagent): scores a `basalt-ui shot` out dir per component; run it after every shot round, never on your own work.
|
|
27
27
|
|
|
@@ -31,7 +31,7 @@ under the depending package; `basalt-ui doctor` prints where; a fresh worktree n
|
|
|
31
31
|
surface: no "bold aesthetic direction", gradient meshes, grain or dramatic motion. Neutral by default,
|
|
32
32
|
the single accent spent only when earned.
|
|
33
33
|
|
|
34
|
-
**Chart override.**
|
|
35
|
-
`CartesianChart`.
|
|
34
|
+
**Chart override.** `/basalt-design`, `/basalt-charts` and the `basalt-charts` rule supersede any global chart rule and
|
|
35
|
+
the bundled `/dataviz` skill (its palette, marks, forms yield to basalt's tokens, catalogue, guards): compose `CartesianChart`.
|
|
36
36
|
|
|
37
37
|
<!-- basalt:end -->
|
|
@@ -13,7 +13,7 @@ theme's config knobs (see the `basalt-tokens` rule) — so nothing here restates
|
|
|
13
13
|
|
|
14
14
|
- **Accent hue:** {{ACCENT_HUE}} (default: the shipped seed; a single-series mark stays neutral)
|
|
15
15
|
- **Theme knobs:** _(none — `createBasaltTheme()` bare)_ · record any non-zero `derive`/`fonts`/
|
|
16
|
-
`radius`/`density` level here, with its reason.
|
|
16
|
+
`radius`/`density` level or `--basalt-font-numeral` override here, with its reason.
|
|
17
17
|
|
|
18
18
|
## Series dictionary
|
|
19
19
|
|
package/configs/oxlint-plugin.js
CHANGED
|
@@ -183,6 +183,7 @@ export const KNOWN_RULE_IDS = new Set([
|
|
|
183
183
|
'raw-selection-control',
|
|
184
184
|
'raw-media-query',
|
|
185
185
|
'unknown-vx-token',
|
|
186
|
+
'series-palette',
|
|
186
187
|
// Retired guard kinds — no longer in GUARD_RULES, but a `theme-allow` naming one must still
|
|
187
188
|
// parse as a real (dead) waiver rather than an unknown-id typo. See RETIRED_RULE_IDS above.
|
|
188
189
|
...RETIRED_RULE_IDS,
|
|
@@ -588,15 +589,21 @@ const rawSizeLiteral = {
|
|
|
588
589
|
|
|
589
590
|
const CARD_TAGS = new Set(['Card', 'Paper'])
|
|
590
591
|
|
|
591
|
-
// The
|
|
592
|
-
// `
|
|
593
|
-
//
|
|
594
|
-
//
|
|
592
|
+
// The THEME owns the inset (Wave 35): a bare Card/Paper resolves to the level-0 12/16 pair
|
|
593
|
+
// (`cardInsetY`/`cardInsetX` = `SPACE_SCALE.sm`/`.md`; `tokens/space-scale.test.ts` pins that), so
|
|
594
|
+
// the idiom is to write nothing. The pair spelled out (`py="sm" px="md"`) is therefore REDUNDANT, any
|
|
595
|
+
// other explicit inset/radius is off-idiom, and flush is `variant="flush"` (whole card) or
|
|
596
|
+
// `Card.Section` (a full-bleed region of a padded card). `p`/`padding` take one value, so no
|
|
597
|
+
// uniform form can equal the 12/16 pair — they are always off-idiom.
|
|
595
598
|
export const CARD_INSET_PY = 'sm'
|
|
596
599
|
export const CARD_INSET_PX = 'md'
|
|
597
600
|
const CARD_INSET_MESSAGE =
|
|
598
|
-
'Card/Paper is off the card idiom —
|
|
599
|
-
|
|
601
|
+
'Card/Paper is off the card idiom — the theme owns the 12/16 inset and radius, so write no ' +
|
|
602
|
+
'p/padding/py/px/radius. Flush whole card: variant="flush"; full-bleed region in a padded card: ' +
|
|
603
|
+
'<Card.Section>; a deliberate exception: {/* theme-allow card-inset — reason */}. (basalt/card-inset)'
|
|
604
|
+
const CARD_INSET_REDUNDANT_MESSAGE =
|
|
605
|
+
'Card/Paper inset is redundant — the theme owns it (12/16, density-scaled); delete ' +
|
|
606
|
+
'py="sm" px="md". (basalt/card-inset)'
|
|
600
607
|
|
|
601
608
|
function isStringLiteral(node) {
|
|
602
609
|
return node !== null && node.type === 'Literal' && typeof node.value === 'string'
|
|
@@ -606,7 +613,7 @@ function attrValue(attr) {
|
|
|
606
613
|
return unwrapExpressionContainer(attr.value)
|
|
607
614
|
}
|
|
608
615
|
|
|
609
|
-
// Ships: warn (grace → 2.
|
|
616
|
+
// Ships: warn (grace → 2.26.0)
|
|
610
617
|
const cardInset = {
|
|
611
618
|
meta: {
|
|
612
619
|
type: 'suggestion',
|
|
@@ -639,16 +646,24 @@ const cardInset = {
|
|
|
639
646
|
for (const name of ['p', 'padding', 'radius']) {
|
|
640
647
|
if (attrs.has(name)) offenders.push(attrs.get(name))
|
|
641
648
|
}
|
|
642
|
-
// The
|
|
643
|
-
//
|
|
644
|
-
const
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
649
|
+
// The theme's own pair, restated, is redundant; any other py/px (or a lone half) is
|
|
650
|
+
// off-idiom.
|
|
651
|
+
const isThemePair = isExactly(py, CARD_INSET_PY) && isExactly(px, CARD_INSET_PX)
|
|
652
|
+
const redundant = []
|
|
653
|
+
if (isThemePair) redundant.push(py, px)
|
|
654
|
+
else {
|
|
655
|
+
if (py) offenders.push(py)
|
|
656
|
+
if (px) offenders.push(px)
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
for (const [list, message] of [
|
|
660
|
+
[offenders, CARD_INSET_MESSAGE],
|
|
661
|
+
[redundant, CARD_INSET_REDUNDANT_MESSAGE],
|
|
662
|
+
]) {
|
|
663
|
+
for (const attr of list) {
|
|
664
|
+
if (hasThemeAllow(context, attr, 'card-inset')) continue
|
|
665
|
+
context.report({ node: attr, message })
|
|
666
|
+
}
|
|
652
667
|
}
|
|
653
668
|
},
|
|
654
669
|
}
|
|
@@ -4224,8 +4239,8 @@ const routeViewTransition = {
|
|
|
4224
4239
|
export const PLUGIN_RULE_GRACE = {
|
|
4225
4240
|
'card-inset': {
|
|
4226
4241
|
since: '2.16.0',
|
|
4227
|
-
promote: '2.
|
|
4228
|
-
why: 'Tightened in 2.16.0: only py="sm" px="md" together (or neither)
|
|
4242
|
+
promote: '2.26.0',
|
|
4243
|
+
why: 'Tightened in 2.16.0: only py="sm" px="md" together (or neither) passed. Inverted in 2.20.0 (Wave 35): the theme owns the 12/16 inset, so the pair is now a "redundant" finding and "neither" is the idiom; flush is variant="flush" or Card.Section. The redundant pair is a NEW finding class first shipping in 2.20.0, so consumers get the full grace again: promote moved 2.24.0 → 2.26.0.',
|
|
4229
4244
|
},
|
|
4230
4245
|
}
|
|
4231
4246
|
|
|
@@ -249,14 +249,44 @@ describe('basalt/card-inset', () => {
|
|
|
249
249
|
})
|
|
250
250
|
|
|
251
251
|
it.each([
|
|
252
|
-
['the sm/md pair', '<Paper py="sm" px="md" />'],
|
|
253
|
-
['the pair in either order', '<Card px="md" py="sm" />'],
|
|
254
252
|
['no padding at all', '<Card />'],
|
|
253
|
+
['a bare Paper', '<Paper />'],
|
|
254
|
+
['the flush Card', '<Card variant="flush" />'],
|
|
255
|
+
['the flush Paper', '<Paper variant="flush" />'],
|
|
256
|
+
['a full-bleed Card.Section in a padded card', '<Card><Card.Section /></Card>'],
|
|
257
|
+
[
|
|
258
|
+
'an explicit inset with a waiver',
|
|
259
|
+
'<div>\n{/* theme-allow card-inset — hero map */}\n<Card p={0} />\n</div>',
|
|
260
|
+
],
|
|
255
261
|
])('does NOT flag %s', (_name, jsx) => {
|
|
256
262
|
const { rules } = run(`export const C = () => ${jsx}\n`)
|
|
257
263
|
expect(rules).not.toContain('card-inset')
|
|
258
264
|
})
|
|
259
265
|
|
|
266
|
+
// The theme owns the 12/16 inset (Wave 35), so restating it is noise that drifts.
|
|
267
|
+
it.each([
|
|
268
|
+
['the sm/md pair', '<Paper py="sm" px="md" />'],
|
|
269
|
+
['the pair in either order', '<Card px="md" py="sm" />'],
|
|
270
|
+
['the pair in expression containers', '<Card py={"sm"} px={"md"} />'],
|
|
271
|
+
])('flags %s as redundant', (_name, jsx) => {
|
|
272
|
+
const { rules, output } = run(`export const C = () => ${jsx}\n`)
|
|
273
|
+
expect(rules).toContain('card-inset')
|
|
274
|
+
expect(output).toContain('redundant')
|
|
275
|
+
expect(output).toContain('theme owns')
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
it('names the flush idiom on any other explicit inset, and not "redundant"', () => {
|
|
279
|
+
const { output } = run(`export const C = () => <Card py={0} px={0} />\n`)
|
|
280
|
+
expect(output).toContain('variant="flush"')
|
|
281
|
+
expect(output).toContain('Card.Section')
|
|
282
|
+
expect(output).not.toContain('redundant')
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
it('flush does not excuse an explicit padding next to it', () => {
|
|
286
|
+
const { rules } = run(`export const C = () => <Card variant="flush" p="lg" />\n`)
|
|
287
|
+
expect(rules).toContain('card-inset')
|
|
288
|
+
})
|
|
289
|
+
|
|
260
290
|
it('ships warn through its grace minor, so a flagged card does not fail the run', () => {
|
|
261
291
|
const { code, rules } = run(`export const C = () => <Card p="lg" />\n`)
|
|
262
292
|
// The fixture config sets the rule to error; the SHIPPED level is pinned by the ledger tests.
|
|
@@ -2,12 +2,22 @@ import type { ReactElement, ReactNode } from 'react';
|
|
|
2
2
|
import type { BasaltProps, SlotStylesProps } from '../common/props.js';
|
|
3
3
|
import type { DeltaPolarity } from '../dashboard/delta-badge.js';
|
|
4
4
|
import type { ChartState, ResponsiveChartHeight } from './types.js';
|
|
5
|
+
/** One headline figure: the value is the hero, then its unit, a comparison node and the period. */
|
|
6
|
+
export type ChartFact = {
|
|
7
|
+
value: ReactNode;
|
|
8
|
+
unit?: string | undefined;
|
|
9
|
+
/** Usually a `DeltaBadge`. */
|
|
10
|
+
comparison?: ReactNode;
|
|
11
|
+
/** Plain text the figure covers, e.g. `last 30 d`. */
|
|
12
|
+
period?: string | undefined;
|
|
13
|
+
};
|
|
5
14
|
/** The three boxes a `ChartCard` paints. */
|
|
6
15
|
export type ChartCardSlot = 'root' | 'header' | 'body';
|
|
7
|
-
|
|
16
|
+
type ChartCardBaseProps = BasaltProps & SlotStylesProps<ChartCardSlot> & {
|
|
8
17
|
title?: string | undefined;
|
|
9
18
|
icon?: ReactNode;
|
|
10
|
-
/** A muted line below the title row; does not by itself render the header.
|
|
19
|
+
/** A muted line below the title row; does not by itself render the header. With `facts` it is the
|
|
20
|
+
* basis/as-of line after the facts row (always visible, never folded into the info glyph). */
|
|
11
21
|
subtitle?: string | undefined;
|
|
12
22
|
/** `WidgetHeader`'s info glyph beside the title. */
|
|
13
23
|
info?: string | undefined;
|
|
@@ -26,9 +36,28 @@ export type ChartCardProps = BasaltProps & SlotStylesProps<ChartCardSlot> & {
|
|
|
26
36
|
* unsized chart takes — pass the chart's own `height` when it states one, so a `<Suspense
|
|
27
37
|
* fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size. */
|
|
28
38
|
placeholderHeight?: number | ResponsiveChartHeight | undefined;
|
|
29
|
-
/**
|
|
39
|
+
/** An errored `state` shows the shared Retry button (the one `ErrorState` renders). */
|
|
40
|
+
onRetry?: (() => void) | undefined;
|
|
41
|
+
/** A refetch is in flight: Retry is inert and marked busy. */
|
|
42
|
+
retrying?: boolean | undefined;
|
|
43
|
+
/** Any other action under the placeholder, e.g. a "clear filters" link; after Retry. */
|
|
30
44
|
stateAction?: ReactNode;
|
|
31
45
|
children?: ReactNode;
|
|
32
46
|
};
|
|
33
|
-
|
|
47
|
+
/**
|
|
48
|
+
* `facts` replaces the legacy `value`/`delta` hero: the two are mutually exclusive in the type. The
|
|
49
|
+
* facts show only at rest: while `state` is pending, errored or empty the figure would sit above a
|
|
50
|
+
* skeleton or a placeholder that contradicts it, so the header keeps its title row alone.
|
|
51
|
+
*/
|
|
52
|
+
export type ChartCardProps = ChartCardBaseProps & ({
|
|
53
|
+
/** The headline figure(s) under the title: value, unit, comparison, period. Wraps at half
|
|
54
|
+
* width, never clips. Replaces `value`/`delta`. */
|
|
55
|
+
facts: ChartFact | readonly ChartFact[];
|
|
56
|
+
value?: undefined;
|
|
57
|
+
delta?: undefined;
|
|
58
|
+
} | {
|
|
59
|
+
facts?: undefined;
|
|
60
|
+
});
|
|
61
|
+
export declare function ChartCard({ actions, state, placeholderHeight, stateAction, onRetry, retrying, className, classNames, style, children, facts, ...header }: ChartCardProps): ReactElement;
|
|
62
|
+
export {};
|
|
34
63
|
//# sourceMappingURL=ChartCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartCard.d.ts","sourceRoot":"","sources":["../../src/charts/ChartCard.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGnE,OAA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.js
CHANGED
|
@@ -57,20 +57,41 @@ const bodyClipStyle = {
|
|
|
57
57
|
};
|
|
58
58
|
const definedOnly = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
|
|
59
59
|
const HEADER_TRIGGERS = ["title", "info", "value", "icon", "count"];
|
|
60
|
+
function Facts({
|
|
61
|
+
facts,
|
|
62
|
+
basis
|
|
63
|
+
}) {
|
|
64
|
+
const list = Array.isArray(facts) ? facts : [facts];
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", { "data-basalt-facts": "", className: classes.facts, children: [
|
|
66
|
+
/* @__PURE__ */ jsx("div", { className: classes.factsRow, children: list.map((f, i) => /* @__PURE__ */ jsxs("span", { "data-basalt-fact": "", className: classes.fact, children: [
|
|
67
|
+
/* @__PURE__ */ jsx("span", { "data-basalt-fact-value": "", className: classes.factValue, children: f.value }),
|
|
68
|
+
f.unit !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.factUnit, children: f.unit }),
|
|
69
|
+
f.comparison,
|
|
70
|
+
f.period !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.factPeriod, children: f.period })
|
|
71
|
+
] }, i)) }),
|
|
72
|
+
basis !== void 0 && /* @__PURE__ */ jsx("p", { "data-basalt-facts-basis": "", className: classes.factsBasis, children: basis })
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
60
75
|
function ChartCard({
|
|
61
76
|
actions,
|
|
62
77
|
state,
|
|
63
78
|
placeholderHeight,
|
|
64
79
|
stateAction,
|
|
80
|
+
onRetry,
|
|
81
|
+
retrying,
|
|
65
82
|
className,
|
|
66
83
|
classNames,
|
|
67
84
|
style,
|
|
68
85
|
children,
|
|
86
|
+
facts,
|
|
69
87
|
...header
|
|
70
88
|
}) {
|
|
71
89
|
const { ref, short } = useShortCard();
|
|
72
90
|
const resolved = resolveChartState(state);
|
|
73
|
-
const
|
|
91
|
+
const showFacts = facts !== void 0 && resolved === null;
|
|
92
|
+
const hasHeader = actions !== void 0 || showFacts || HEADER_TRIGGERS.some((k) => header[k] !== void 0);
|
|
93
|
+
const { subtitle, ...rest } = header;
|
|
94
|
+
const headerProps = facts === void 0 ? header : rest;
|
|
74
95
|
return /* @__PURE__ */ jsx(ChartCardContext.Provider, { value: true, children: /* @__PURE__ */ jsxs(
|
|
75
96
|
"div",
|
|
76
97
|
{
|
|
@@ -81,17 +102,20 @@ function ChartCard({
|
|
|
81
102
|
...resolved === "pending" && { "aria-busy": "true" },
|
|
82
103
|
...short && { "data-basalt-card-short": "" },
|
|
83
104
|
children: [
|
|
84
|
-
hasHeader && /* @__PURE__ */
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
actions
|
|
105
|
+
hasHeader && /* @__PURE__ */ jsxs("div", { className: cx(classes.header, classNames?.header), children: [
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
WidgetHeader,
|
|
108
|
+
{
|
|
109
|
+
tier: "widget",
|
|
110
|
+
...definedOnly(headerProps),
|
|
111
|
+
title: header.title ?? "",
|
|
112
|
+
...actions !== void 0 && {
|
|
113
|
+
actions: /* @__PURE__ */ jsx("span", { "data-basalt-tier": "widget", children: actions })
|
|
114
|
+
}
|
|
92
115
|
}
|
|
93
|
-
|
|
94
|
-
|
|
116
|
+
),
|
|
117
|
+
showFacts && /* @__PURE__ */ jsx(Facts, { facts, basis: subtitle })
|
|
118
|
+
] }),
|
|
95
119
|
/* @__PURE__ */ jsx(
|
|
96
120
|
"div",
|
|
97
121
|
{
|
|
@@ -102,6 +126,8 @@ function ChartCard({
|
|
|
102
126
|
{
|
|
103
127
|
state,
|
|
104
128
|
...placeholderHeight !== void 0 && { height: placeholderHeight },
|
|
129
|
+
...onRetry !== void 0 && { onRetry },
|
|
130
|
+
...retrying !== void 0 && { retrying },
|
|
105
131
|
action: stateAction
|
|
106
132
|
}
|
|
107
133
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Donut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@__PURE__ */ jsx(ChartPlaceholder, { state, height: "fill" }),
|
|
177
177
|
resolved === null && (centerLabel !== void 0 || centerSubLabel !== void 0) && /* @__PURE__ */ jsxs("div", { style: centerStyle, children: [
|
|
178
|
-
centerLabel !== void 0 && /* @__PURE__ */ jsx(
|
|
178
|
+
centerLabel !== void 0 && /* @__PURE__ */ jsx(
|
|
179
|
+
"span",
|
|
180
|
+
{
|
|
181
|
+
style: {
|
|
182
|
+
color: VX.ink,
|
|
183
|
+
fontFamily: "var(--basalt-font-numeral, var(--basalt-font-sans))",
|
|
184
|
+
fontVariantNumeric: "lining-nums",
|
|
185
|
+
fontSize: VX.text.lg,
|
|
186
|
+
fontWeight: 600
|
|
187
|
+
},
|
|
188
|
+
children: centerLabel
|
|
189
|
+
}
|
|
190
|
+
),
|
|
179
191
|
centerSubLabel !== void 0 && /* @__PURE__ */ jsx("span", { style: { color: VX.axis, fontSize: VX.text.micro }, children: centerSubLabel })
|
|
180
192
|
] })
|
|
181
193
|
]
|
package/dist/charts/Heatmap.js
CHANGED
|
@@ -132,7 +132,7 @@ function Heatmap(props) {
|
|
|
132
132
|
const ticks = { line: false, size: 0 };
|
|
133
133
|
const cls = resolveContainerClass(width);
|
|
134
134
|
const tickLabels = {
|
|
135
|
-
fontSize:
|
|
135
|
+
fontSize: VX.text.micro,
|
|
136
136
|
opacity: 1,
|
|
137
137
|
thin: true
|
|
138
138
|
};
|