basalt-ui 2.20.0 → 2.22.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 +72 -0
- package/MIGRATING.md +394 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-tokens.md +3 -3
- 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 +49 -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/configs/oxlint-plugin.js +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +27 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +5 -0
- package/dist/charts/CartesianChart.d.ts +8 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +17 -4
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +33 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +39 -14
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +20 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +9 -0
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +17 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +145 -74
- package/dist/charts/labels.d.ts +15 -4
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +34 -10
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +26 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +63 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +10 -11
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +7 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +4 -1
- package/dist/charts/types.d.ts +14 -5
- 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/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -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 +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +71 -6
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +200 -33
- 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 +409 -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/playwright.d.ts +5 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/types.d.ts +6 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +4 -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/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts +5 -2
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +9 -10
- package/dist/dashboard/bar-list.module.css +53 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +108 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +123 -19
- package/dist/dashboard/meter-parts.d.ts +8 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +345 -146
- package/dist/dashboard/meter.d.ts +50 -63
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +24 -3
- package/dist/dashboard/meter.module.css +79 -65
- package/dist/dashboard/meter.module.css.d.ts +7 -7
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- 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 +3 -2
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -4
- package/dist/dashboard/stat-card.module.css +17 -0
- package/dist/dashboard/stat-strip.d.ts +24 -1
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +97 -39
- package/dist/dashboard/stat-strip.module.css +147 -17
- package/dist/dashboard/stat-strip.module.css.d.ts +8 -0
- package/dist/dashboard/visual-slot.d.ts +8 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +7 -0
- package/dist/guard/index.d.ts +15 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +14 -0
- 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/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +34 -2
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +33 -0
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +11 -5
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- 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/dist/tokens/palette.d.ts +4 -0
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +4 -0
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +43 -23
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +33 -3
- package/src/charts/Bars.tsx +6 -0
- package/src/charts/CartesianChart.tsx +16 -3
- package/src/charts/ChartCard.tsx +43 -7
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +50 -13
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +31 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +210 -85
- package/src/charts/labels.ts +48 -14
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +104 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +10 -11
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +12 -1
- package/src/charts/types.ts +14 -5
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +102 -4
- package/src/cli/shot/capture.ts +266 -34
- package/src/cli/shot/detect.ts +550 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/playwright.ts +2 -2
- package/src/cli/shot/types.ts +8 -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/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +53 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +88 -76
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +265 -28
- package/src/dashboard/meter-parts.tsx +424 -163
- package/src/dashboard/meter.module.css +79 -65
- package/src/dashboard/meter.module.css.d.ts +7 -7
- package/src/dashboard/meter.tsx +77 -17
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/query-state.tsx +4 -7
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +17 -0
- package/src/dashboard/stat-card.tsx +14 -5
- package/src/dashboard/stat-strip.module.css +147 -17
- package/src/dashboard/stat-strip.module.css.d.ts +8 -0
- package/src/dashboard/stat-strip.tsx +182 -56
- package/src/dashboard/visual-slot.ts +17 -0
- package/src/guard/index.ts +16 -4
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +34 -2
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +220 -60
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +33 -0
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +18 -5
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/oklab.ts +97 -0
- package/src/tokens/palette.ts +4 -0
- package/src/tokens/status-text.ts +2 -0
|
@@ -7,7 +7,7 @@ paths:
|
|
|
7
7
|
|
|
8
8
|
<!-- basalt:coverage -->
|
|
9
9
|
<!-- GENERATED from src/surfaces.ts — `bun scripts/check-coverage.ts --write`. Do not hand-edit. -->
|
|
10
|
-
<!-- backed by: guard kinds — css-raw-surface, inline-font-size, off-identity-accent, off-system-surface-var, raw-color-fn, raw-font-family, raw-hex, raw-radius, raw-surface, surface-shadow-override, theme-allow-unscoped, unknown-vx-token · oxlint rules — basalt/no-raw-font-size, basalt/raw-size-literal -->
|
|
10
|
+
<!-- backed by: guard kinds — css-raw-surface, inline-font-size, off-identity-accent, off-system-surface-var, raw-color-fn, raw-font-family, raw-hex, raw-radius, raw-surface, series-palette, surface-shadow-override, theme-allow-unscoped, unknown-vx-token · oxlint rules — basalt/no-raw-font-size, basalt/raw-size-literal -->
|
|
11
11
|
<!-- not guarded: — -->
|
|
12
12
|
<!-- /basalt:coverage -->
|
|
13
13
|
|
|
@@ -24,12 +24,12 @@ Every value is a `VX.*` reference or a theme prop; the palette is derived, never
|
|
|
24
24
|
- Never read a raw ramp var (`--mantine-color-gray-N`); use `VX.surface.*`. [check-theme off-system-surface-var]
|
|
25
25
|
- Fill a control with `VX.accentFill` labelled `VX.onAccent`, never `VX.accent` (that is ink). [type VX]
|
|
26
26
|
- Name only `--vx-*` vars that basalt emits. [check-theme unknown-vx-token]
|
|
27
|
-
- Series color is app data: `defineSeries` → `seriesTokens`/`groupTokens`, each entry a `{ light, dark }` pair, in one file that `check-theme` exempts. [type defineSeries]
|
|
27
|
+
- Series color is app data: `defineSeries` → `seriesTokens`/`groupTokens`, each entry a `{ light, dark }` pair, in one file that `check-theme` exempts from the hex scan but judges for lightness, chroma, CVD separation and contrast. [type defineSeries] [check-theme series-palette]
|
|
28
28
|
- `groupTokens` returns the group to pass to `buildPaletteCss` or `BasaltProvider` `paletteOptions`; never retype its key. [type groupTokens]
|
|
29
29
|
|
|
30
30
|
## Surfaces, radius, depth
|
|
31
31
|
|
|
32
|
-
- Surfaces are `VX.surface.{bg,panel,panelHover,elevated,subtle,overlay,field,border,hairline}`; the seam between shell regions is `VX.divider`. [type VX]
|
|
32
|
+
- Surfaces are `VX.surface.{bg,panel,panelHover,rowHover,rowSelected,elevated,subtle,overlay,field,border,hairline}`; the seam between shell regions is `VX.divider`. [type VX]
|
|
33
33
|
- Never set border, radius or shadow on a card; the theme owns them (`VX.shadowCard`, `VX.radiusCard`). [check-theme raw-surface]
|
|
34
34
|
- Never replace a surface's shadow with your own `boxShadow`; compose with the depth token. [check-theme surface-shadow-override]
|
|
35
35
|
- In CSS, corners and depth are `var(--vx-radius-card)` (cards) or `var(--vx-radius-ctrl)` (controls) and `var(--vx-shadow-card)`. [check-theme css-raw-surface]
|
|
@@ -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 tabular 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; a route declaring none is a P1 (`craft-7/no-declared-states`). 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 (`PageSummary`, one sentence plus a facts line) 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,49 @@
|
|
|
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
|
+
| Categorical status per cell (up, degraded, down) | Flat status fills; a glyph on warn and bad, never hue alone | `Heatmap` `states` with a `tone` each, no hex; `BandStrip` `glyph` | A hue-only grid |
|
|
36
|
+
| A set of KPIs about one record | One joined surface, cells split by hairlines | `StatGroup variant="strip"` | N unrelated cards |
|
|
37
|
+
| Many rows, several attributes | Table, right-aligned figures | `BasaltDataTable` (`basalt-ui/table`) | Cards per row |
|
|
38
|
+
| Nothing yet / failed | Why and what to do | `EmptyState`, or the component's own `query` state | "No data" |
|
|
39
|
+
|
|
40
|
+
## Not shipped — report the gap, don't hand-roll
|
|
41
|
+
|
|
42
|
+
| Shape | Missing |
|
|
43
|
+
| -------------------------------------------------------------------- | -------------- |
|
|
44
|
+
| Event sequence (day groups, time pinned right) | `EventList` |
|
|
45
|
+
| Work items by status (columns with counts) | `Board` |
|
|
46
|
+
| Record page (header, facts line, strip, events) and list-row recipes | recipes only |
|
|
47
|
+
| Bounded score inside a row | tick meter |
|
|
48
|
+
| Daily data over months with month labels | calendar grid |
|
|
49
|
+
| 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 -->
|
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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BandStrip.d.ts","sourceRoot":"","sources":["../../src/charts/BandStrip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BandStrip.d.ts","sourceRoot":"","sources":["../../src/charts/BandStrip.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAMzC,OAAO,KAAK,EAAS,eAAe,EAAE,MAAM,aAAa,CAAA;AAGzD,OAAO,KAAK,EAEV,mBAAmB,EAGnB,MAAM,EAGP,MAAM,SAAS,CAAA;AAEhB,gGAAgG;AAChG,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,eAAe,GAAG;IACjD;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,CAAA;CACpD,CAAA;AAED,2DAA2D;AAC3D,MAAM,MAAM,QAAQ,GAAG;IACrB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAA;IACb,oGAAoG;IACpG,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC;;;OAGG;IACH,MAAM,CAAC,EACH;QACE,0CAA0C;QAC1C,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B,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@tanstack/charts/mark/decorative";
|
|
4
4
|
import { rect } from "@tanstack/charts/rect";
|
|
5
|
+
import { text } from "@tanstack/charts/text";
|
|
5
6
|
import { useCallback, useMemo } from "react";
|
|
6
7
|
import { oneOf, requiredProp } from "../common/errors.js";
|
|
7
8
|
import { NON_FINITE } from "../format/shared.js";
|
|
8
9
|
import { VX, alpha } from "../tokens/index.js";
|
|
9
10
|
import { CartesianRung } from "./CartesianChart.js";
|
|
10
|
-
import { groupsOf, resolveNamedState } from "./band-fold.js";
|
|
11
|
+
import { GLYPH_MIN_PX, glyphOf, groupsOf, resolveNamedState } from "./band-fold.js";
|
|
11
12
|
import { emphasis } from "./marks.js";
|
|
12
13
|
import { rowX } from "./types.js";
|
|
13
14
|
const DEFAULT_MIN_BAND_PX = 3;
|
|
@@ -93,12 +94,19 @@ function layoutBands(input) {
|
|
|
93
94
|
absentKey
|
|
94
95
|
};
|
|
95
96
|
const hits = [];
|
|
97
|
+
const glyphs = [];
|
|
96
98
|
for (const g of groups) {
|
|
97
99
|
const datum = fold && g.items.length > 1 ? fold.merge(g.items) : g.items[0];
|
|
98
100
|
if (datum === void 0) continue;
|
|
99
101
|
const span = getBand(datum);
|
|
100
102
|
const cell = { f0: g.start / data.length, f1: (g.start + g.items.length) / data.length };
|
|
101
103
|
const answers = paintSpan(ctx, span, cell);
|
|
104
|
+
const named = input.states.get(span.state);
|
|
105
|
+
const glyph = named && glyphOf(named);
|
|
106
|
+
if (answers.primary && glyph && (cell.f1 - cell.f0) * input.width >= GLYPH_MIN_PX) {
|
|
107
|
+
const share = absentShareOf(span, absentKey);
|
|
108
|
+
glyphs.push({ f: cell.f0 + (cell.f1 - cell.f0) * (1 - share) / 2, glyph });
|
|
109
|
+
}
|
|
102
110
|
g.items.forEach((source, i) => {
|
|
103
111
|
const slot = g.start + i;
|
|
104
112
|
if (answers.primary) hits.push({ slot, source, state: span.state, datum });
|
|
@@ -106,7 +114,7 @@ function layoutBands(input) {
|
|
|
106
114
|
hits.push({ slot, source, state: absentKey, datum });
|
|
107
115
|
});
|
|
108
116
|
}
|
|
109
|
-
return { base: [...ctx.base.values()], markers: [...ctx.markers.values()], hits };
|
|
117
|
+
return { base: [...ctx.base.values()], markers: [...ctx.markers.values()], hits, glyphs };
|
|
110
118
|
}
|
|
111
119
|
function BandStrip(props) {
|
|
112
120
|
const {
|
|
@@ -147,7 +155,7 @@ function BandStrip(props) {
|
|
|
147
155
|
);
|
|
148
156
|
const marks = useCallback(
|
|
149
157
|
(plot) => {
|
|
150
|
-
const { base, markers, hits } = layoutBands({
|
|
158
|
+
const { base, markers, hits, glyphs } = layoutBands({
|
|
151
159
|
data,
|
|
152
160
|
getBand,
|
|
153
161
|
fold,
|
|
@@ -180,6 +188,21 @@ function BandStrip(props) {
|
|
|
180
188
|
})
|
|
181
189
|
)
|
|
182
190
|
),
|
|
191
|
+
...glyphs.length > 0 ? [
|
|
192
|
+
decorative(
|
|
193
|
+
text(glyphs, {
|
|
194
|
+
id: "band-glyphs",
|
|
195
|
+
x: "f",
|
|
196
|
+
y: () => 0.5,
|
|
197
|
+
xScale: "zx",
|
|
198
|
+
text: "glyph",
|
|
199
|
+
fill: VX.surface.panel,
|
|
200
|
+
fontSize: VX.text.xs,
|
|
201
|
+
fontWeight: 600,
|
|
202
|
+
anchor: "middle"
|
|
203
|
+
})
|
|
204
|
+
)
|
|
205
|
+
] : [],
|
|
183
206
|
...rows.length > 0 ? [
|
|
184
207
|
barY(rows, {
|
|
185
208
|
id: "hit",
|
|
@@ -228,6 +251,7 @@ function BandStrip(props) {
|
|
|
228
251
|
series,
|
|
229
252
|
marks,
|
|
230
253
|
band: true,
|
|
254
|
+
tooltipBelow: true,
|
|
231
255
|
y: STRIP_AXIS,
|
|
232
256
|
xZones: ZX_ANCHOR,
|
|
233
257
|
cursorResolution,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bars.d.ts","sourceRoot":"","sources":["../../src/charts/Bars.tsx"],"names":[],"mappings":"AAU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SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAA;IACzD,6JAA6J;IAC7J,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;CACzD,CAAA;AAoBD,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CA2EvF"}
|
package/dist/charts/Bars.js
CHANGED
|
@@ -40,6 +40,7 @@ function Bars(props) {
|
|
|
40
40
|
const byKey = new Map(bars.map((b) => [b.key, b]));
|
|
41
41
|
const rows = visibleBars.flatMap((s) => plot.rows(s.key));
|
|
42
42
|
const h = plot.highlighted;
|
|
43
|
+
const solid = ({ datum }) => byKey.get(datum.series)?.color ?? "transparent";
|
|
43
44
|
const fill = (row) => {
|
|
44
45
|
const bar = byKey.get(row.series);
|
|
45
46
|
if (!bar) return "transparent";
|
|
@@ -56,6 +57,9 @@ function Bars(props) {
|
|
|
56
57
|
y: "y",
|
|
57
58
|
z: "series",
|
|
58
59
|
fill,
|
|
60
|
+
// The hovered x is its own highlight: the bar reads at full strength (no dimming, no
|
|
61
|
+
// point marker, no crosshair rule: that is line-chart chrome).
|
|
62
|
+
states: [{ when: { focus: "x" }, style: { fill: solid } }],
|
|
59
63
|
layout: layout === "grouped" ? group({ padding: 0.1 }) : stack({ order, ...layout === "normalized" && { offset: "normalize" } })
|
|
60
64
|
})
|
|
61
65
|
);
|
|
@@ -74,6 +78,7 @@ function Bars(props) {
|
|
|
74
78
|
series,
|
|
75
79
|
marks,
|
|
76
80
|
band: true,
|
|
81
|
+
crosshair: false,
|
|
77
82
|
reverseRows: layout !== "grouped",
|
|
78
83
|
...layout !== "grouped" && { stack: layout }
|
|
79
84
|
}
|
|
@@ -10,6 +10,12 @@ export type RungOptions = {
|
|
|
10
10
|
reverseRows?: boolean;
|
|
11
11
|
/** How the bar series combine for the auto domain. */
|
|
12
12
|
stack?: 'stacked' | 'normalized';
|
|
13
|
+
/** The tooltip opens below the chart (a strip of cells), above only when there is no room. */
|
|
14
|
+
tooltipBelow?: boolean;
|
|
15
|
+
/** No vertical rule under the cursor (a bar kind's hover is the bar itself). */
|
|
16
|
+
crosshair?: boolean;
|
|
17
|
+
/** The legend goes from the wide class up, where `Lines`' end labels name the series. */
|
|
18
|
+
hideLegendAtWide?: boolean;
|
|
13
19
|
};
|
|
14
20
|
/** What a chart's definition is compiled from, besides its own props: the chrome's live state. */
|
|
15
21
|
export type ShellContext = {
|
|
@@ -33,6 +39,8 @@ export type ChartShellProps<T> = Pick<CartesianChartProps<T, ChartX>, 'ariaLabel
|
|
|
33
39
|
compile: (ctx: ShellContext) => CartesianDefinition;
|
|
34
40
|
/** Recompile when the measured width changes (default: it is not an input). */
|
|
35
41
|
byWidth?: boolean;
|
|
42
|
+
/** `auto` legend only: hidden from the wide class up (CSS). */
|
|
43
|
+
hideLegendAtWide?: boolean;
|
|
36
44
|
};
|
|
37
45
|
/**
|
|
38
46
|
* The chrome around every chart: size, the `hidden`/`highlighted` legend state, the derived legend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../src/charts/CartesianChart.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAiB,YAAY,EAAa,MAAM,OAAO,CAAA;AAGnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvE,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG;IACxB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,yDAAyD;IACzD,WAAW,CA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mB,CAAC,CAAC,EAAE,MAAM,CAAC,EAC9B,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CACpE,GAAG;IACF,qCAAqC;IACrC,MAAM,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IACjC,6FAA6F;IAC7F,OAAO,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,mBAAmB,CAAA;IACnD,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,YAAY,CAkFrE;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAC/C,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,GAC7C,YAAY,CA0Bd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAChD,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC/B,YAAY,CAEd"}
|
|
@@ -28,6 +28,7 @@ function useShallowStable(next) {
|
|
|
28
28
|
}
|
|
29
29
|
function ChartShell(props) {
|
|
30
30
|
const { ariaLabel, legend, height, state, className, style, series, compile, byWidth } = props;
|
|
31
|
+
const { hideLegendAtWide } = props;
|
|
31
32
|
const chartId = useId();
|
|
32
33
|
const inCard = useInChartCard();
|
|
33
34
|
const { ref, width: measured, coarse } = useChartSize();
|
|
@@ -42,8 +43,8 @@ function ChartShell(props) {
|
|
|
42
43
|
() => compile({ chartId, hidden, highlighted, coarse, width, plot }),
|
|
43
44
|
[compile, chartId, hidden, highlighted, coarse, width, plot]
|
|
44
45
|
);
|
|
45
|
-
const config = legend === false ? null : legend ?? {};
|
|
46
46
|
const entryCount = legendEntries(series, false)[0]?.length ?? 0;
|
|
47
|
+
const config = legend === false ? null : legend ?? (entryCount > 1 ? {} : null);
|
|
47
48
|
const shown = config !== null && entryCount > 0;
|
|
48
49
|
const toggle = config?.toggle ?? entryCount >= 2;
|
|
49
50
|
const onToggle = useCallback((key) => {
|
|
@@ -65,10 +66,11 @@ function ChartShell(props) {
|
|
|
65
66
|
toggle,
|
|
66
67
|
onToggle,
|
|
67
68
|
onHighlight: setHighlighted,
|
|
68
|
-
concealed: resolved !== null
|
|
69
|
+
concealed: resolved !== null,
|
|
70
|
+
hideAtWide: hideLegendAtWide === true
|
|
69
71
|
}
|
|
70
72
|
) : null,
|
|
71
|
-
[shown, series, hidden, config?.groups, toggle, onToggle, resolved]
|
|
73
|
+
[shown, series, hidden, config?.groups, toggle, onToggle, resolved, hideLegendAtWide]
|
|
72
74
|
);
|
|
73
75
|
const atTop = config?.placement === "top" || config?.placement === "header";
|
|
74
76
|
const asHeaderRow = config?.placement === "header" && inCard;
|
|
@@ -98,7 +100,7 @@ function ChartShell(props) {
|
|
|
98
100
|
);
|
|
99
101
|
}
|
|
100
102
|
function CartesianRung(props) {
|
|
101
|
-
const { ariaLabel, legend, height, state, className, style, series, ...spec } = props;
|
|
103
|
+
const { ariaLabel, legend, height, state, className, style, series, hideLegendAtWide, ...spec } = props;
|
|
102
104
|
const stable = useShallowStable({ ...spec, series });
|
|
103
105
|
const compile = useCallback(
|
|
104
106
|
(ctx) => compileCartesian({ ...stable, ...ctx }),
|
|
@@ -118,7 +120,8 @@ function CartesianRung(props) {
|
|
|
118
120
|
...height !== void 0 && { height },
|
|
119
121
|
...state !== void 0 && { state },
|
|
120
122
|
...className !== void 0 && { className },
|
|
121
|
-
...style !== void 0 && { style }
|
|
123
|
+
...style !== void 0 && { style },
|
|
124
|
+
...hideLegendAtWide && { hideLegendAtWide }
|
|
122
125
|
}
|
|
123
126
|
);
|
|
124
127
|
}
|
|
@@ -8,9 +8,14 @@ export type ChartFact = {
|
|
|
8
8
|
unit?: string | undefined;
|
|
9
9
|
/** Usually a `DeltaBadge`. */
|
|
10
10
|
comparison?: ReactNode;
|
|
11
|
-
/** Plain text the figure covers, e.g. `last 30 d`.
|
|
12
|
-
|
|
11
|
+
/** Plain text the figure covers, e.g. `last 30 d`. A list is joined by ` · ` (`['last entry 3 d
|
|
12
|
+
* ago', '12 entries']`). */
|
|
13
|
+
period?: string | readonly string[] | undefined;
|
|
14
|
+
/** Ink for the whole fact (text only, never a fill): a stale or off-target figure reads `warn`. */
|
|
15
|
+
tone?: ChartFactTone | undefined;
|
|
13
16
|
};
|
|
17
|
+
/** The status inks a fact can take, plus the muted one. */
|
|
18
|
+
export type ChartFactTone = 'good' | 'warn' | 'bad' | 'muted';
|
|
14
19
|
/** The three boxes a `ChartCard` paints. */
|
|
15
20
|
export type ChartCardSlot = 'root' | 'header' | 'body';
|
|
16
21
|
type ChartCardBaseProps = BasaltProps & SlotStylesProps<ChartCardSlot> & {
|
|
@@ -36,7 +41,15 @@ type ChartCardBaseProps = BasaltProps & SlotStylesProps<ChartCardSlot> & {
|
|
|
36
41
|
* unsized chart takes — pass the chart's own `height` when it states one, so a `<Suspense
|
|
37
42
|
* fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size. */
|
|
38
43
|
placeholderHeight?: number | ResponsiveChartHeight | undefined;
|
|
39
|
-
/**
|
|
44
|
+
/** Placeholder data is showing: the facts row dims with the plot (a strip cell's `stale`). */
|
|
45
|
+
stale?: boolean | undefined;
|
|
46
|
+
/** What an errored `state` names: "Could not load {stateNoun}". Default: no noun. */
|
|
47
|
+
stateNoun?: string | undefined;
|
|
48
|
+
/** An errored `state` shows the shared Retry button (the one `ErrorState` renders). */
|
|
49
|
+
onRetry?: (() => void) | undefined;
|
|
50
|
+
/** A refetch is in flight: Retry is inert and marked busy. */
|
|
51
|
+
retrying?: boolean | undefined;
|
|
52
|
+
/** Any other action under the placeholder, e.g. a "clear filters" link; after Retry. */
|
|
40
53
|
stateAction?: ReactNode;
|
|
41
54
|
children?: ReactNode;
|
|
42
55
|
};
|
|
@@ -54,6 +67,6 @@ export type ChartCardProps = ChartCardBaseProps & ({
|
|
|
54
67
|
} | {
|
|
55
68
|
facts?: undefined;
|
|
56
69
|
});
|
|
57
|
-
export declare function ChartCard({ actions, state, placeholderHeight, stateAction, className, classNames, style, children, facts, ...header }: ChartCardProps): ReactElement;
|
|
70
|
+
export declare function ChartCard({ actions, state, placeholderHeight, stateAction, stale, stateNoun, onRetry, retrying, className, classNames, style, children, facts, ...header }: ChartCardProps): ReactElement;
|
|
58
71
|
export {};
|
|
59
72
|
//# 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,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAM7D,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAoEhE,mGAAmG;AACnG,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,8BAA8B;IAC9B,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB
|
|
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,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,KAA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