basalt-ui 2.20.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/MIGRATING.md +129 -12
  3. package/agent/agents/basalt-design-reviewer.md +22 -5
  4. package/agent/rules/basalt-tokens.md +2 -2
  5. package/agent/skills/basalt-design/SKILL.md +10 -23
  6. package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
  7. package/agent/skills/basalt-design/references/catalogue.md +48 -0
  8. package/agent/skills/basalt-design/references/concept.md +36 -0
  9. package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
  10. package/agent/skills/basalt-design/references/stat-tile.md +24 -0
  11. package/agent/templates/AGENTS-block.md.tpl +3 -3
  12. package/configs/oxlint-plugin.js +1 -0
  13. package/dist/charts/ChartCard.d.ts +6 -2
  14. package/dist/charts/ChartCard.d.ts.map +1 -1
  15. package/dist/charts/ChartCard.js +4 -0
  16. package/dist/charts/state.d.ts +5 -0
  17. package/dist/charts/state.d.ts.map +1 -1
  18. package/dist/charts/state.js +2 -0
  19. package/dist/cli/check-theme.d.ts.map +1 -1
  20. package/dist/cli/check-theme.js +3 -0
  21. package/dist/cli/help.d.ts.map +1 -1
  22. package/dist/cli/help.js +3 -2
  23. package/dist/cli/index.d.ts +4 -2
  24. package/dist/cli/index.d.ts.map +1 -1
  25. package/dist/cli/index.js +27 -15
  26. package/dist/cli/init.d.ts.map +1 -1
  27. package/dist/cli/init.js +3 -2
  28. package/dist/cli/shot/capture.d.ts.map +1 -1
  29. package/dist/cli/shot/capture.js +6 -1
  30. package/dist/cli/shot/detect.d.ts +51 -0
  31. package/dist/cli/shot/detect.d.ts.map +1 -0
  32. package/dist/cli/shot/detect.js +396 -0
  33. package/dist/cli/shot/index.d.ts.map +1 -1
  34. package/dist/cli/shot/index.js +7 -4
  35. package/dist/cli/shot/measure.d.ts +2 -0
  36. package/dist/cli/shot/measure.d.ts.map +1 -1
  37. package/dist/cli/shot/measure.js +2 -0
  38. package/dist/cli/shot/types.d.ts +4 -1
  39. package/dist/cli/shot/types.d.ts.map +1 -1
  40. package/dist/cli/shot/types.js +2 -0
  41. package/dist/cli/sync.d.ts +2 -0
  42. package/dist/cli/sync.d.ts.map +1 -1
  43. package/dist/cli/sync.js +2 -2
  44. package/dist/common/retry-button.d.ts +12 -0
  45. package/dist/common/retry-button.d.ts.map +1 -0
  46. package/dist/common/retry-button.js +22 -0
  47. package/dist/common/retry-button.module.css +58 -0
  48. package/dist/common/retry-button.module.css.d.ts +8 -0
  49. package/dist/dashboard/bar-list.d.ts +5 -2
  50. package/dist/dashboard/bar-list.d.ts.map +1 -1
  51. package/dist/dashboard/bar-list.js +2 -2
  52. package/dist/dashboard/meter-model.d.ts +34 -6
  53. package/dist/dashboard/meter-model.d.ts.map +1 -1
  54. package/dist/dashboard/meter-model.js +44 -13
  55. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  56. package/dist/dashboard/meter-parts.js +167 -135
  57. package/dist/dashboard/meter.d.ts +11 -7
  58. package/dist/dashboard/meter.d.ts.map +1 -1
  59. package/dist/dashboard/meter.js +5 -1
  60. package/dist/dashboard/meter.module.css +18 -65
  61. package/dist/dashboard/meter.module.css.d.ts +2 -7
  62. package/dist/dashboard/query-state.d.ts +1 -1
  63. package/dist/dashboard/query-state.d.ts.map +1 -1
  64. package/dist/dashboard/query-state.js +3 -2
  65. package/dist/dashboard/stat-card.d.ts.map +1 -1
  66. package/dist/dashboard/stat-card.js +2 -1
  67. package/dist/dashboard/stat-strip.d.ts +17 -0
  68. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  69. package/dist/dashboard/stat-strip.js +35 -5
  70. package/dist/dashboard/stat-strip.module.css +97 -14
  71. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  72. package/dist/dashboard/visual-slot.d.ts +2 -0
  73. package/dist/dashboard/visual-slot.d.ts.map +1 -0
  74. package/dist/dashboard/visual-slot.js +5 -0
  75. package/dist/guard/index.d.ts +15 -2
  76. package/dist/guard/index.d.ts.map +1 -1
  77. package/dist/guard/index.js +14 -0
  78. package/dist/guard/palette.d.ts +51 -0
  79. package/dist/guard/palette.d.ts.map +1 -0
  80. package/dist/guard/palette.js +190 -0
  81. package/dist/guard/series-file.d.ts +15 -0
  82. package/dist/guard/series-file.d.ts.map +1 -0
  83. package/dist/guard/series-file.js +29 -0
  84. package/dist/guard/types.d.ts +3 -3
  85. package/dist/guard/types.d.ts.map +1 -1
  86. package/dist/surfaces.d.ts +1 -1
  87. package/dist/surfaces.d.ts.map +1 -1
  88. package/dist/surfaces.js +2 -0
  89. package/dist/theme/controls.module.css +10 -0
  90. package/dist/theme/index.d.ts.map +1 -1
  91. package/dist/theme/index.js +18 -0
  92. package/dist/tokens/oklab.d.ts +28 -0
  93. package/dist/tokens/oklab.d.ts.map +1 -0
  94. package/dist/tokens/oklab.js +73 -0
  95. package/llms.txt +7 -5
  96. package/package.json +1 -1
  97. package/src/charts/ChartCard.tsx +9 -1
  98. package/src/charts/state.tsx +9 -0
  99. package/src/cli/check-theme.ts +3 -0
  100. package/src/cli/help.ts +18 -1
  101. package/src/cli/index.ts +48 -17
  102. package/src/cli/init.ts +2 -1
  103. package/src/cli/shot/capture.ts +15 -2
  104. package/src/cli/shot/detect.ts +533 -0
  105. package/src/cli/shot/index.ts +8 -4
  106. package/src/cli/shot/measure.ts +4 -0
  107. package/src/cli/shot/types.ts +5 -1
  108. package/src/cli/sync.ts +4 -2
  109. package/src/common/retry-button.module.css +58 -0
  110. package/src/common/retry-button.module.css.d.ts +8 -0
  111. package/src/common/retry-button.tsx +29 -0
  112. package/src/dashboard/bar-list.tsx +11 -8
  113. package/src/dashboard/meter-model.ts +91 -20
  114. package/src/dashboard/meter-parts.tsx +155 -115
  115. package/src/dashboard/meter.module.css +18 -65
  116. package/src/dashboard/meter.module.css.d.ts +2 -7
  117. package/src/dashboard/meter.tsx +18 -8
  118. package/src/dashboard/query-state.tsx +4 -7
  119. package/src/dashboard/stat-card.tsx +4 -1
  120. package/src/dashboard/stat-strip.module.css +97 -14
  121. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  122. package/src/dashboard/stat-strip.tsx +85 -5
  123. package/src/dashboard/visual-slot.ts +8 -0
  124. package/src/guard/index.ts +16 -4
  125. package/src/guard/palette.ts +261 -0
  126. package/src/guard/series-file.ts +51 -0
  127. package/src/guard/types.ts +3 -2
  128. package/src/surfaces.ts +2 -0
  129. package/src/theme/__snapshots__/plain-theme.test.ts.snap +82 -48
  130. package/src/theme/controls.module.css +10 -0
  131. package/src/theme/index.ts +26 -0
  132. package/src/tokens/oklab.ts +97 -0
@@ -14,10 +14,6 @@
14
14
  --basalt-meter-caption: var(--vx-text-micro);
15
15
  }
16
16
 
17
- .root.zoned {
18
- position: relative;
19
- }
20
-
21
17
  .track {
22
18
  position: relative;
23
19
  display: flex;
@@ -57,13 +53,15 @@
57
53
  }
58
54
 
59
55
  /*
60
- * Zone names under the band: absolutely placed at each band start so they stay on the band. When
61
- * they would collide the band collapses (hidden but still laid out, so it can be re-measured) and the
62
- * same names wrap as a list. The holding zone is ink, the rest muted.
56
+ * The one label row under (or, for a plain tick Meter, above) the track: zone names centred on their
57
+ * spans, labelled ticks hugging their marks, all absolutely placed on one baseline. A label that does
58
+ * not fit is hidden but stays laid out, so a resize can measure it again.
63
59
  */
64
- .zoneBand {
60
+ .labelRow {
61
+ --basalt-reading-dir: 1;
65
62
  position: relative;
66
- /* Labels are absolutely placed, so the row needs its own line height. */
63
+ /* A hidden name keeps its box (so it can be measured again) and may sit past the row's end. */
64
+ overflow-x: clip;
67
65
  height: 1.25em;
68
66
  font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
69
67
  font-variant-numeric: lining-nums;
@@ -71,42 +69,28 @@
71
69
  color: var(--vx-muted);
72
70
  }
73
71
 
74
- /*
75
- * Hidden but laid out, so a resize can measure it again. Absolute against `.root.zoned`, which has
76
- * no inline padding, so `inset-inline: 0` gives the band the same width as when it was in flow.
77
- */
78
- .zoneBand[data-collapsed] {
79
- position: absolute;
80
- top: 0;
81
- inset-inline: 0;
82
- visibility: hidden;
83
- pointer-events: none;
72
+ .labelRow:dir(rtl) {
73
+ --basalt-reading-dir: -1;
84
74
  }
85
75
 
86
- .zoneLabel {
76
+ .rowLabel {
87
77
  position: absolute;
88
78
  top: 0;
89
79
  white-space: nowrap;
90
80
  }
91
81
 
92
- .zoneLabelHolding {
93
- font-weight: 500;
94
- color: var(--vx-ink);
82
+ .rowLabel[data-hidden] {
83
+ visibility: hidden;
95
84
  }
96
85
 
97
- .zoneList {
98
- display: flex;
99
- flex-wrap: wrap;
100
- gap: var(--vx-space-stack-xs) var(--vx-space-stack-sm);
101
- font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
102
- font-variant-numeric: lining-nums;
103
- font-size: var(--basalt-meter-caption);
104
- color: var(--vx-muted);
86
+ /* A zone name is centred on its span: the physical `translate` flips sign in RTL. */
87
+ .zoneLabel {
88
+ translate: calc(-50% * var(--basalt-reading-dir)) 0;
105
89
  }
106
90
 
107
- .zoneListItem {
108
- min-width: 0;
109
- overflow-wrap: anywhere;
91
+ .zoneLabelHolding {
92
+ font-weight: 500;
93
+ color: var(--vx-ink);
110
94
  }
111
95
 
112
96
  /* The reading under the band, centred on the marker. Clipped so it never widens the row before the first measure. */
@@ -295,37 +279,6 @@
295
279
  height: 5rem;
296
280
  }
297
281
 
298
- /* ── tick captions ───────────────────────────────────────────────────────────────────────────── */
299
-
300
- /* Above the track, so they never share a row with the zone names or the captions below it. */
301
- .tickLabels {
302
- position: relative;
303
- }
304
-
305
- .tickBand {
306
- position: relative;
307
- height: 1.25em;
308
- font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
309
- font-variant-numeric: lining-nums;
310
- font-size: var(--basalt-meter-caption);
311
- color: var(--vx-muted);
312
- }
313
-
314
- /* Hidden but laid out, so a resize can measure it again. */
315
- .tickBand[data-collapsed] {
316
- position: absolute;
317
- top: 0;
318
- inset-inline: 0;
319
- visibility: hidden;
320
- pointer-events: none;
321
- }
322
-
323
- .tickLabel {
324
- position: absolute;
325
- top: 0;
326
- white-space: nowrap;
327
- }
328
-
329
282
  /* ── size="row" ──────────────────────────────────────────────────────────────────────────────── */
330
283
 
331
284
  .row {
@@ -5,17 +5,15 @@
5
5
  declare const classes: {
6
6
  readonly root: string
7
7
  readonly summary: string
8
- readonly zoned: string
9
8
  readonly track: string
10
9
  readonly trackBox: string
11
10
  readonly fill: string
12
11
  readonly forecastFill: string
13
12
  readonly zone: string
14
- readonly zoneBand: string
13
+ readonly labelRow: string
14
+ readonly rowLabel: string
15
15
  readonly zoneLabel: string
16
16
  readonly zoneLabelHolding: string
17
- readonly zoneList: string
18
- readonly zoneListItem: string
19
17
  readonly zoneReadingRow: string
20
18
  readonly zoneReading: string
21
19
  readonly marker: string
@@ -36,9 +34,6 @@ declare const classes: {
36
34
  readonly ringArc: string
37
35
  readonly ringValue: string
38
36
  readonly skeletonRing: string
39
- readonly tickLabels: string
40
- readonly tickBand: string
41
- readonly tickLabel: string
42
37
  readonly row: string
43
38
  }
44
39
  export default classes
@@ -4,9 +4,10 @@
4
4
  * along is this against a limit"; choose `BarList` for a ranking and a chart for a trend. An HTML/CSS
5
5
  * primitive, not a chart kind (no scale, axis or tooltip).
6
6
  *
7
- * Colour law: the fill is neutral (`VX.line`). `color` is for a VERDICT only (over budget, below
8
- * target) and is a status colour the consumer passes; categorical `segments` take the consumer's
9
- * series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
7
+ * Colour law: a plain `value` bar's fill is neutral (`--vx-muted` at a strength that holds 3:1 on
8
+ * the track; `tone="ink"` for full ink); `segments` and `zones` keep their own fills. `color` is
9
+ * for a VERDICT only (over budget, below target) and is a status colour the consumer passes;
10
+ * categorical `segments` take the consumer's series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
10
11
  * tick marks the boundary and a caption names the forecast. A value past `max` clamps the fill at the
11
12
  * track end; the caption still states the real value.
12
13
  *
@@ -78,16 +79,19 @@ type BarCommon = Common & {
78
79
  target?: number
79
80
  /**
80
81
  * More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
81
- * above the track, wrapping to a list when two collide. A tick outside `[min, max]` is dropped, not
82
+ * above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends). A
83
+ * caption that would collide with another hides. A tick outside `[min, max]` is dropped, not
82
84
  * clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
83
85
  * and `target`.
84
86
  */
85
87
  ticks?: readonly MeterTick[]
86
88
  /**
87
- * `'muted'`: a non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds
88
- * 3:1 against the track in both schemes — the neutral fill is near-white in dark. A `color` wins.
89
+ * `'muted'` (default for a plain `value` bar; `segments` and `zones` keep their fills): a
90
+ * non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds 3:1 against
91
+ * the track in both schemes — the ink fill is near-white in dark. `'ink'` restores the full-ink
92
+ * `--vx-line` fill. A `color` wins over both.
89
93
  */
90
- tone?: 'muted'
94
+ tone?: 'muted' | 'ink'
91
95
  /**
92
96
  * `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
93
97
  * part, zone and tick captions). The label stays as `aria-label`; the described-by text keeps the
@@ -160,6 +164,12 @@ function warnInvalidTrack(min: number, max: number) {
160
164
  )
161
165
  }
162
166
 
167
+ /** Muted is the default for a plain `value` bar only; `segments`/`zones` keep their fills unless asked. */
168
+ function barTone(tone: 'muted' | 'ink' | undefined, plain: boolean): 'muted' | undefined {
169
+ if (tone === 'ink') return undefined
170
+ return tone === 'muted' || plain ? 'muted' : undefined
171
+ }
172
+
163
173
  export function Meter(props: MeterProps) {
164
174
  const { label, min = 0, max = 100, format = asText, className, style } = props
165
175
  const row = props.size === 'row'
@@ -188,7 +198,7 @@ export function Meter(props: MeterProps) {
188
198
  zones={props.zones}
189
199
  target={isReading(props.target) ? props.target : undefined}
190
200
  ticks={props.ticks}
191
- tone={props.tone}
201
+ tone={barTone(props.tone, props.segments === undefined && props.zones === undefined)}
192
202
  forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
193
203
  startCaption={props.startCaption}
194
204
  endCaption={props.endCaption}
@@ -14,10 +14,11 @@
14
14
  * the re-derivation this exists to delete. `LoadingState` / `ErrorState` ship alongside as the
15
15
  * escape hatch for a page that must place its branches in different DOM positions.
16
16
  */
17
- import { Button, Center, Group, Loader, Stack, Text } from '@mantine/core'
17
+ import { Center, Group, Loader, Stack, Text } from '@mantine/core'
18
18
  import type { CSSProperties, ReactNode } from 'react'
19
19
  import { toErrorMessage } from '../common/errors'
20
20
  import { cx } from '../common/props'
21
+ import { RetryButton } from '../common/retry-button'
21
22
  import type { BasaltProps, SlotStylesProps } from '../common/props'
22
23
  import { VX } from '../tokens'
23
24
  import { StatusDot } from '../theme/status-dot'
@@ -104,7 +105,7 @@ export type ErrorStateProps = BasaltProps & {
104
105
  /** Shown only when the server body carries no readable message. */
105
106
  fallback?: string
106
107
  onRetry?: () => void
107
- /** Disables/spins the retry button while a refetch is in flight. */
108
+ /** Disables the retry button while a refetch is in flight. */
108
109
  retrying?: boolean
109
110
  /** How loud this state is. Default `'page'`. */
110
111
  tier?: QueryStateTier
@@ -148,11 +149,7 @@ export function ErrorState({
148
149
  </Text>
149
150
  {(onRetry ?? action) !== undefined && (
150
151
  <Group gap="xs">
151
- {onRetry && (
152
- <Button size="xs" variant="default" loading={retrying} onClick={onRetry}>
153
- Retry
154
- </Button>
155
- )}
152
+ {onRetry && <RetryButton onClick={onRetry} retrying={retrying} />}
156
153
  {action}
157
154
  </Group>
158
155
  )}
@@ -112,6 +112,7 @@ import type { BasaltProps, SlotStylesProps, Tone } from '../common/props'
112
112
  import { ErrorState, QueryState, resolveQueryBranch } from './query-state'
113
113
  import type { QueryBranch, QueryStateLike } from './query-state'
114
114
  import classes from './stat-card.module.css'
115
+ import { VisualSlotContext } from './visual-slot'
115
116
 
116
117
  /**
117
118
  * The boxes `StatCard` paints, and the whole styling seam it offers (`common/props.ts`).
@@ -448,7 +449,9 @@ export function StatCard({
448
449
  >
449
450
  {/* A measured slot renders nothing on the first commit (width 0) — an SVG at width 0 is a
450
451
  visible 0-width box that then jumps, which is worse than one frame of nothing. */}
451
- {isRender ? measured.width > 0 && sparkline(measured) : sparkline}
452
+ <VisualSlotContext.Provider value>
453
+ {isRender ? measured.width > 0 && sparkline(measured) : sparkline}
454
+ </VisualSlotContext.Provider>
452
455
  </div>
453
456
  )
454
457
 
@@ -1,11 +1,12 @@
1
1
  /*
2
2
  * StatGroup `variant="strip"`: one joined surface, cells split by 1px hairlines.
3
3
  *
4
- * The hairlines are LEADING borders (inline-start + block-start) on every cell, and `.clip` hides
5
- * the ones that lead a row or the strip by pulling the grid 1px up/left inside an `overflow: hidden`
6
- * box. That is why the rail survives any column count and any wrap with no `nth-child` bookkeeping
7
- * (`stat-group.module.css` needs it because its cells are not clipped). No shadow per cell, no
8
- * coloured edge: the one surface is the Card's.
4
+ * The hairlines are LEADING edges (inline-start + block-start) drawn as outer box-shadows, so they
5
+ * take no layout space and every cell keeps the same `stack-md` inset. `.clip` hides the ones that
6
+ * lead a row or the strip by pulling the grid 1px up/left inside an `overflow: hidden` box. That is
7
+ * why the rail survives any column count and any wrap with no `nth-child` bookkeeping
8
+ * (`stat-group.module.css` needs it because its cells are not clipped). No coloured edge: the one
9
+ * surface is the Card's.
9
10
  *
10
11
  * The column law keys on the CONTAINER like `StatGroup`'s own: two columns at < 480px (the `regular` class boundary) with an odd
11
12
  * last cell spanning, never one; up to three below 800px; the full `cols` from 800px.
@@ -27,18 +28,67 @@
27
28
  }
28
29
 
29
30
  .cell {
30
- display: flex;
31
- flex-direction: column;
32
- gap: var(--vx-space-stack-sm);
31
+ display: grid;
32
+ grid-row: span 5;
33
+ grid-template-rows: subgrid;
33
34
  min-width: 0;
34
35
  padding: var(--vx-space-stack-md);
35
- border-inline-start: 1px solid var(--vx-divider);
36
+ box-shadow:
37
+ -1px 0 0 var(--vx-divider),
38
+ 0 -1px 0 var(--vx-divider);
36
39
  }
37
40
 
38
- /* The top line is adjacent-sibling: the first cell draws none (it leads the strip), every later one
39
- * draws its top edge, which is the rule between wrapped rows. */
40
- .cell + .cell {
41
- border-block-start: 1px solid var(--vx-divider);
41
+ /* Forced colors drop box-shadows, so the hairlines come back as CanvasText borders. Every cell takes
42
+ * both, so they stay level with each other; `.clip` still hides the leading ones. */
43
+ @media (forced-colors: active) {
44
+ .cell {
45
+ border-inline-start: 1px solid CanvasText;
46
+ border-block-start: 1px solid CanvasText;
47
+ }
48
+ }
49
+
50
+ /* Cells align by PART. Every cell spans the same five tracks of `.cells` (caption, hero, visual,
51
+ * rows, footer), so a row of cells shares one caption top and one value baseline, and a void opens
52
+ * only where a sibling's same part is taller. A part a cell lacks collapses its track (the spacing
53
+ * is a margin on the part, not a gap, so an empty track adds none). A cell without a visual keeps
54
+ * its rows (and a footer without rows) in the visual track, directly under its hero: short cells
55
+ * stay compact instead of stretching their footer to the row's bottom. A footer under a visual
56
+ * rides in the visual track with it (`.visualStack`), so it hugs its own visual; only a rows
57
+ * cell's footer uses the shared footer track. A hero-less cell (rows only) starts its rows in the
58
+ * visual track, so the hero track above them is the one void, and only as tall as a sibling's
59
+ * value. */
60
+ .cell > * {
61
+ grid-column: 1;
62
+ min-width: 0;
63
+ }
64
+
65
+ .cell > :not(.captionLine) {
66
+ margin-block-start: var(--vx-space-stack-sm);
67
+ }
68
+
69
+ .valueRow,
70
+ .skeletonValue,
71
+ .error {
72
+ grid-row: 2;
73
+ }
74
+
75
+ .cell > .visualStack,
76
+ .cell > .reason,
77
+ .cell > .rows,
78
+ .cell > .footer {
79
+ grid-row: 3;
80
+ }
81
+
82
+ .cell[data-strip-has-visual] > .rows {
83
+ grid-row: 4;
84
+ }
85
+
86
+ .cell[data-strip-has-rows] > .footer {
87
+ grid-row: 5;
88
+ }
89
+
90
+ .cell > .footer {
91
+ align-self: start;
42
92
  }
43
93
 
44
94
  @container basalt-grid (max-width: 479.9px) {
@@ -58,6 +108,7 @@
58
108
  }
59
109
 
60
110
  .captionLine {
111
+ grid-row: 1;
61
112
  display: flex;
62
113
  flex-wrap: wrap;
63
114
  align-items: center;
@@ -143,6 +194,10 @@
143
194
  min-width: 0;
144
195
  }
145
196
 
197
+ .visualStack > .footer {
198
+ margin-block-start: var(--vx-space-stack-sm);
199
+ }
200
+
146
201
  /* A Sparkline's hover readout takes this line above its plot (`charts/sparkline.module.css`). The
147
202
  * cell's own stack gap already sits above it; the slot reserves the rest, so the chip never covers
148
203
  * the value. */
@@ -154,8 +209,36 @@
154
209
  padding-top: max(0px, calc(var(--basalt-spark-readout-h) - var(--vx-space-stack-sm)));
155
210
  }
156
211
 
212
+ /* An empty cell's reason and an errored cell's message: one muted `sm` line, wrapping rather than
213
+ * clipping (a 390px two-column cell is ~170px wide). */
214
+ .reason {
215
+ margin: 0;
216
+ min-width: 0;
217
+ font-size: var(--vx-text-sm);
218
+ line-height: 1.3;
219
+ color: var(--vx-muted);
220
+ overflow-wrap: anywhere;
221
+ }
222
+
223
+ /* The compact error anatomy: dot + word, the message, Retry — a left-aligned stack in the cell. */
224
+ .error {
225
+ display: flex;
226
+ flex-direction: column;
227
+ align-items: flex-start;
228
+ gap: var(--vx-space-stack-xs);
229
+ min-width: 0;
230
+ }
231
+
232
+ .errorHead {
233
+ display: inline-flex;
234
+ align-items: center;
235
+ gap: var(--vx-space-stack-sm);
236
+ font-size: var(--vx-text-sm);
237
+ font-weight: 500;
238
+ color: var(--vx-ink);
239
+ }
240
+
157
241
  .footer {
158
- margin-top: auto;
159
242
  font-size: var(--vx-text-sm);
160
243
  color: var(--vx-muted);
161
244
  }
@@ -17,6 +17,10 @@ declare const classes: {
17
17
  readonly skeletonValue: string
18
18
  readonly skeletonRow: string
19
19
  readonly visual: string
20
+ readonly visualStack: string
21
+ readonly reason: string
22
+ readonly error: string
23
+ readonly errorHead: string
20
24
  readonly footer: string
21
25
  readonly rows: string
22
26
  readonly row: string
@@ -8,6 +8,14 @@
8
8
  * `tone` inks the VALUE only, for a verdict; a null reading is `—`. A cell may carry BOTH: the hero
9
9
  * (e.g. VO2max) with `rows` under it; omit `value` to render the rows alone.
10
10
  *
11
+ * `state` replaces the readings (hero, visual, rows, footer) with the cell's empty or error body, at
12
+ * the cell's size. Empty: `—` in the value position and the reason, muted. Error: the shared error
13
+ * anatomy compact — status dot, the word `Failed`, the message, the shared Retry. The caption stays.
14
+ * A `visual` is a hero host: a zoned `Meter` in it does not repeat the value at its marker.
15
+ *
16
+ * Alignment: cells of one row align by PART (caption, value, visual, rows, footer share tracks via
17
+ * subgrid), not by stretching; a cell without a visual keeps its footer directly under its content.
18
+ *
11
19
  * Anchors: each cell is `data-shot="strip-<key>"` and each footer cell
12
20
  * `data-shot="strip-footer-<key>"` (derived — a consumer cannot choose another name).
13
21
  *
@@ -18,11 +26,15 @@
18
26
  import { Card, Skeleton } from '@mantine/core'
19
27
  import { useId } from 'react'
20
28
  import type { CSSProperties, ReactNode } from 'react'
29
+ import { toErrorMessage } from '../common/errors'
21
30
  import { cx } from '../common/props'
22
31
  import type { BasaltProps, Tone } from '../common/props'
32
+ import { RetryButton } from '../common/retry-button'
33
+ import { StatusDot } from '../theme/status-dot'
23
34
  import { VX } from '../tokens'
24
35
  import { InfoGlyph } from './widget-header'
25
36
  import classes from './stat-strip.module.css'
37
+ import { VisualSlotContext } from './visual-slot'
26
38
 
27
39
  export type StatStripRow = {
28
40
  key: string
@@ -34,6 +46,23 @@ export type StatStripRow = {
34
46
  delta?: ReactNode
35
47
  }
36
48
 
49
+ /** What a cell shows instead of its readings. Mirrors `StatCard`'s `query` branches. */
50
+ type StatStripCellState =
51
+ | {
52
+ kind: 'empty'
53
+ /** Why there is no reading, one muted line (`'No sleep logged'`). */
54
+ reason?: string
55
+ }
56
+ | {
57
+ kind: 'error'
58
+ /** Whatever was thrown; decoded like `ErrorState`'s. */
59
+ error?: unknown
60
+ /** Renders the shared Retry button. */
61
+ onRetry?: () => void
62
+ /** A refetch is in flight: Retry is inert. */
63
+ retrying?: boolean
64
+ }
65
+
37
66
  export type StatStripCell = {
38
67
  key: string
39
68
  caption: string
@@ -58,6 +87,8 @@ export type StatStripCell = {
58
87
  loading?: boolean
59
88
  /** Dims the cell while placeholder data shows. */
60
89
  stale?: boolean
90
+ /** Empty or failed: replaces the readings; `loading` wins while pending. */
91
+ state?: StatStripCellState
61
92
  }
62
93
 
63
94
  export type StatStripProps = BasaltProps & {
@@ -72,16 +103,55 @@ export type StatStripProps = BasaltProps & {
72
103
 
73
104
  const EMPTY = '—'
74
105
 
106
+ function CellState({ state }: { state: StatStripCellState }) {
107
+ if (state.kind === 'empty') {
108
+ return (
109
+ <>
110
+ <div className={classes.valueRow}>
111
+ <span className={classes.value} data-strip-value>
112
+ {EMPTY}
113
+ </span>
114
+ </div>
115
+ {state.reason !== undefined && <p className={classes.reason}>{state.reason}</p>}
116
+ </>
117
+ )
118
+ }
119
+ const message = toErrorMessage(state.error, 'The request failed.')
120
+ return (
121
+ <div className={classes.error} role="alert" data-strip-state="error">
122
+ <span className={classes.errorHead}>
123
+ <StatusDot color={VX.status.bad} />
124
+ Failed
125
+ </span>
126
+ <p className={classes.reason}>{message}</p>
127
+ {state.onRetry !== undefined && (
128
+ <RetryButton onClick={state.onRetry} retrying={state.retrying ?? false} />
129
+ )}
130
+ </div>
131
+ )
132
+ }
133
+
75
134
  function StripCell({ cell }: { cell: StatStripCell }) {
76
135
  const captionId = useId()
77
136
  const { rows, loading } = cell
137
+ const state = loading ? undefined : cell.state
78
138
  const hasHero = cell.value !== undefined || rows === undefined
139
+ // A footer under a visual (and no rows) rides with it, so it hugs that visual instead of dropping
140
+ // to a taller sibling's; under rows, or with neither, it takes the row's shared footer track.
141
+ const ownFooter = cell.visual !== undefined && rows === undefined
142
+ const footerEl = cell.footer !== undefined && (
143
+ <div className={classes.footer} data-strip-footer>
144
+ {cell.footer}
145
+ </div>
146
+ )
79
147
  return (
80
148
  <article
81
149
  className={classes.cell}
82
150
  data-strip-cell={cell.key}
83
151
  data-shot={`strip-${cell.key}`}
84
152
  aria-labelledby={captionId}
153
+ {...(state === undefined && cell.visual !== undefined && { 'data-strip-has-visual': '' })}
154
+ {...(state === undefined && rows !== undefined && { 'data-strip-has-rows': '' })}
85
155
  {...(cell.stale && { 'data-stale': 'true' })}
86
156
  >
87
157
  <div className={classes.captionLine}>
@@ -96,7 +166,9 @@ function StripCell({ cell }: { cell: StatStripCell }) {
96
166
  <span className={classes.qualifier}>{cell.qualifier}</span>
97
167
  )}
98
168
  </div>
99
- {hasHero &&
169
+ {state !== undefined && <CellState state={state} />}
170
+ {state === undefined &&
171
+ hasHero &&
100
172
  (loading ? (
101
173
  <Skeleton className={classes.skeletonValue} radius="sm" />
102
174
  ) : (
@@ -114,8 +186,16 @@ function StripCell({ cell }: { cell: StatStripCell }) {
114
186
  {cell.delta}
115
187
  </div>
116
188
  ))}
117
- {cell.visual !== undefined && <div className={classes.visual}>{cell.visual}</div>}
118
- {rows !== undefined &&
189
+ {state === undefined && cell.visual !== undefined && (
190
+ <div className={classes.visualStack}>
191
+ <div className={classes.visual} data-strip-visual>
192
+ <VisualSlotContext.Provider value={hasHero}>{cell.visual}</VisualSlotContext.Provider>
193
+ </div>
194
+ {ownFooter && footerEl}
195
+ </div>
196
+ )}
197
+ {state === undefined &&
198
+ rows !== undefined &&
119
199
  (loading ? (
120
200
  <div className={classes.rows} aria-hidden="true">
121
201
  {rows.map((row) => (
@@ -123,7 +203,7 @@ function StripCell({ cell }: { cell: StatStripCell }) {
123
203
  ))}
124
204
  </div>
125
205
  ) : (
126
- <ul className={classes.rows}>
206
+ <ul className={classes.rows} data-strip-rows>
127
207
  {rows.map((row) => (
128
208
  <li key={row.key} className={classes.row} data-strip-row={row.key}>
129
209
  <span className={classes.rowLabel}>{row.label}</span>
@@ -134,7 +214,7 @@ function StripCell({ cell }: { cell: StatStripCell }) {
134
214
  ))}
135
215
  </ul>
136
216
  ))}
137
- {cell.footer !== undefined && <div className={classes.footer}>{cell.footer}</div>}
217
+ {state === undefined && !ownFooter && footerEl}
138
218
  </article>
139
219
  )
140
220
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Set by a host that already shows the reading as its hero (a `StatCard` sparkline slot, a strip
3
+ * cell's `visual`). A `Meter` in zones mode reads it and drops the reading it would draw at the
4
+ * marker, so the headline value is not printed twice. Internal: never exported.
5
+ */
6
+ import { createContext } from 'react'
7
+
8
+ export const VisualSlotContext = createContext(false)
@@ -3,7 +3,7 @@
3
3
  * (`tokens/space-scale`, `common/*`), never `tokens/palette` or `derive` (colour math on every
4
4
  * Write/Edit).
5
5
  *
6
- * GUARD_RULES: the closed registry of all 26 violation kinds.
6
+ * GUARD_RULES: the closed registry of all 27 violation kinds.
7
7
  * checkSource: pure (text, relPath, cfg) → Finding[]. No FS, no walk, no console.
8
8
  */
9
9
  import type { Finding, GuardConfig, GuardKind, GuardSeverity } from './types'
@@ -911,10 +911,15 @@ export const GRACE_PERIOD_KINDS: Partial<Record<GuardKind, GraceEntry>> = {
911
911
  promote: '2.24.0',
912
912
  why: 'The scale moved to 8/12/16/20/24 and the CSS micro ceiling dropped 10 → 7 in 2.16.0: a literal 8px/10px in CSS is newly a finding.',
913
913
  },
914
+ 'series-palette': {
915
+ since: '2.21.0',
916
+ promote: '2.23.0',
917
+ why: 'New in 2.21.0: the series file is judged by computed lightness, chroma, colour-blind separation and contrast; a palette that was tuned by eye is newly a finding.',
918
+ },
914
919
  }
915
920
 
916
921
  /** A kind's effective severity: consumer override first, then the grace table, then `error`. */
917
- function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
922
+ export function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
918
923
  return cfg.severity?.[kind] ?? (Object.hasOwn(GRACE_PERIOD_KINDS, kind) ? 'warn' : 'error')
919
924
  }
920
925
 
@@ -985,7 +990,7 @@ function exemptPatternMatches(pattern: string, relPath: string): boolean {
985
990
  * Whether `kind` is exempted at `relPath` via `cfg.exemptRules` — the config-driven, per-rule
986
991
  * counterpart to `isChartFile`'s hardcoded path scoping.
987
992
  */
988
- function isRuleExempt(
993
+ export function isRuleExempt(
989
994
  kind: GuardKind,
990
995
  relPath: string,
991
996
  exemptRules: GuardConfig['exemptRules'],
@@ -1982,7 +1987,7 @@ type GuardRule = {
1982
1987
  }
1983
1988
 
1984
1989
  /**
1985
- * The closed registry of all 26 guard kinds. The triad test asserts
1990
+ * The closed registry of all 27 guard kinds. The triad test asserts
1986
1991
  * `surface.guardKinds ⊆ keyof GUARD_RULES` at runtime.
1987
1992
  *
1988
1993
  * raw-surface, raw-html-layout, and sub-16-input-font are handled inline in checkSource
@@ -2208,6 +2213,13 @@ export const GUARD_RULES = {
2208
2213
  pattern: VX_VAR_REF, // handled inline (basalt-owned families); entry keeps the registry complete
2209
2214
  message: `var() names a --vx-* token basalt does not emit, so it resolves to its fallback (or to nothing) with no error anywhere. Judged: every name inside a basalt-owned family (${[...BASALT_VX_FAMILY_SET].join(', ')}), plus any name basalt used to emit in any family — pick the token from the stylesheet basalt-ui tokens:css emits; your own series belong in a family of their own (groupTokens throws on one inside basalt's, in dev builds). A removed name is reported with its replacement on the finding line (MIGRATING.md has the table). Any other name outside a basalt family is never judged, because groupTokens may declare it in a file this scan cannot see.`,
2210
2215
  },
2216
+ 'series-palette': {
2217
+ kind: 'series-palette',
2218
+ pattern: /(?!)/, // never matches: judged over the whole series FILE by `series-file.ts`, not per line
2219
+ appliesTo: () => false,
2220
+ message:
2221
+ "The series file's palette fails a computed check (OKLCH lightness band, chroma floor, colour-blind separation of neighbours, worst-pair separation, 3:1 contrast against the surface, ≤ 8 series without a repeat) — retune the hex in the series file; it is judged per scheme, light against the light panel and dark against the dark one. A deliberately neutral series is keyed `other`.",
2222
+ },
2211
2223
  } as const satisfies Record<GuardKind, GuardRule>
2212
2224
 
2213
2225
  /**