basalt-ui 2.18.0 → 2.20.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 +90 -0
- package/MIGRATING.md +238 -12
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +33 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +28 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +33 -11
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +13 -1
- package/dist/charts/Heatmap.js +1 -1
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +137 -18
- package/dist/charts/box.d.ts +2 -0
- package/dist/charts/box.d.ts.map +1 -1
- package/dist/charts/box.js +2 -0
- package/dist/charts/chart-box.module.css +30 -0
- package/dist/charts/chart-box.module.css.d.ts +1 -0
- package/dist/charts/chart-card.module.css +47 -0
- package/dist/charts/chart-card.module.css.d.ts +7 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +35 -8
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +2 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/sparkline.module.css +59 -0
- package/dist/charts/sparkline.module.css.d.ts +13 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +32 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/commands/notifications/center.d.ts.map +1 -1
- package/dist/commands/notifications/center.js +18 -26
- package/dist/content/callout.d.ts +1 -1
- package/dist/content/callout.d.ts.map +1 -1
- package/dist/content/callout.js +10 -1
- package/dist/content/callout.module.css +15 -3
- package/dist/content/callout.module.css.d.ts +1 -0
- package/dist/controls/sync-button.d.ts +3 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/dashboard/bar-list.d.ts +15 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +56 -19
- package/dist/dashboard/bar-list.module.css +110 -17
- package/dist/dashboard/bar-list.module.css.d.ts +2 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +68 -1
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +65 -4
- package/dist/dashboard/meter-parts.d.ts +5 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +234 -60
- package/dist/dashboard/meter.d.ts +38 -6
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +4 -1
- package/dist/dashboard/meter.module.css +209 -13
- package/dist/dashboard/meter.module.css.d.ts +16 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +14 -9
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.d.ts +3 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +18 -3
- package/dist/dashboard/stat-card.d.ts +7 -6
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +51 -83
- package/dist/dashboard/stat-card.module.css +42 -14
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +50 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +85 -0
- package/dist/dashboard/stat-strip.module.css +208 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +28 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +2 -1
- package/dist/dashboard/widget-header.module.css +38 -7
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/styles.css +6 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/chrome-vars.d.ts +29 -17
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +18 -8
- package/dist/theme/controls.module.css +3 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +32 -5
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +7 -0
- package/dist/theme/status-dot.d.ts.map +1 -0
- package/dist/theme/status-dot.js +18 -0
- package/dist/theme/status-dot.module.css +9 -0
- package/dist/theme/status-dot.module.css.d.ts +8 -0
- package/dist/theme/status-verdict.d.ts +10 -0
- package/dist/theme/status-verdict.d.ts.map +1 -0
- package/dist/theme/status-verdict.js +14 -0
- package/dist/theme/status-verdict.module.css +25 -0
- package/dist/theme/status-verdict.module.css.d.ts +9 -0
- package/llms.txt +30 -6
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +70 -4
- package/src/charts/Donut.tsx +9 -1
- package/src/charts/Heatmap.tsx +1 -1
- package/src/charts/Sparkline.tsx +180 -18
- package/src/charts/box.tsx +2 -0
- package/src/charts/chart-box.module.css +30 -0
- package/src/charts/chart-box.module.css.d.ts +1 -0
- package/src/charts/chart-card.module.css +47 -0
- package/src/charts/chart-card.module.css.d.ts +7 -0
- package/src/charts/compile.ts +42 -9
- package/src/charts/host.tsx +6 -3
- package/src/charts/index.ts +1 -1
- package/src/charts/sparkline.module.css +59 -0
- package/src/charts/sparkline.module.css.d.ts +13 -0
- package/src/charts/state.tsx +44 -4
- package/src/charts/types.ts +6 -0
- package/src/commands/notifications/center.tsx +29 -32
- package/src/content/callout.module.css +15 -3
- package/src/content/callout.module.css.d.ts +1 -0
- package/src/content/callout.tsx +15 -2
- package/src/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +110 -17
- package/src/dashboard/bar-list.module.css.d.ts +2 -0
- package/src/dashboard/bar-list.tsx +102 -21
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +132 -4
- package/src/dashboard/meter-parts.tsx +305 -25
- package/src/dashboard/meter.module.css +209 -13
- package/src/dashboard/meter.module.css.d.ts +16 -0
- package/src/dashboard/meter.tsx +42 -7
- package/src/dashboard/query-state.tsx +28 -19
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +22 -2
- package/src/dashboard/stat-card.module.css +42 -14
- package/src/dashboard/stat-card.tsx +23 -60
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +208 -0
- package/src/dashboard/stat-strip.module.css.d.ts +28 -0
- package/src/dashboard/stat-strip.tsx +183 -0
- package/src/dashboard/widget-header.module.css +38 -7
- package/src/dashboard/widget-header.tsx +7 -4
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +1 -1
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +242 -26
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/chrome-vars.ts +48 -23
- package/src/theme/controls.module.css +3 -0
- package/src/theme/index.ts +40 -6
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.module.css +9 -0
- package/src/theme/status-dot.module.css.d.ts +8 -0
- package/src/theme/status-dot.tsx +31 -0
- package/src/theme/status-verdict.module.css +25 -0
- package/src/theme/status-verdict.module.css.d.ts +9 -0
- package/src/theme/status-verdict.tsx +32 -0
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
--basalt-stat-visual-h: 1.375rem;
|
|
13
13
|
--basalt-stat-footer-h: 1.25rem;
|
|
14
14
|
--basalt-stat-foot-gap: 0.25rem;
|
|
15
|
+
/* The line a Sparkline's hover readout takes above its plot (`charts/sparkline.module.css` reads
|
|
16
|
+
* it too). A slot that cannot spare it reserves it as padding, so the chip never covers the hero. */
|
|
17
|
+
--basalt-spark-readout-h: 1.125rem;
|
|
15
18
|
/* The figure's size and line box, in one place: `.value`, the empty line and the pending skeleton
|
|
16
19
|
* all read them, so nothing moves when a reading lands. */
|
|
17
20
|
--basalt-stat-figure-size: var(--vx-text-kpi);
|
|
@@ -86,7 +89,6 @@
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
.qualifier {
|
|
89
|
-
font-family: var(--basalt-font-mono);
|
|
90
92
|
font-size: var(--vx-text-micro);
|
|
91
93
|
color: var(--vx-muted);
|
|
92
94
|
/* Wraps before it is ever cut: a qualifier too long for the row on its own line breaks its words. */
|
|
@@ -128,7 +130,8 @@
|
|
|
128
130
|
.value {
|
|
129
131
|
min-width: 0;
|
|
130
132
|
overflow-wrap: anywhere;
|
|
131
|
-
font-family: var(--basalt-font-
|
|
133
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
134
|
+
font-variant-numeric: lining-nums;
|
|
132
135
|
font-size: var(--basalt-stat-figure-size);
|
|
133
136
|
line-height: var(--basalt-stat-figure-line);
|
|
134
137
|
font-weight: 500;
|
|
@@ -136,11 +139,12 @@
|
|
|
136
139
|
color: var(--vx-ink);
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
/*
|
|
142
|
+
/* Sans like the number it qualifies, `sm` and muted: the SMALL half of the pair. Never shrinks — a
|
|
140
143
|
* unit clipped to `TS…` would state nothing. */
|
|
141
144
|
.unit {
|
|
142
145
|
flex-shrink: 0;
|
|
143
|
-
font-family: var(--basalt-font-
|
|
146
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
147
|
+
font-variant-numeric: lining-nums;
|
|
144
148
|
font-size: var(--vx-text-sm);
|
|
145
149
|
font-weight: 500;
|
|
146
150
|
color: var(--vx-muted);
|
|
@@ -173,15 +177,15 @@
|
|
|
173
177
|
height: var(--basalt-stat-figure-h);
|
|
174
178
|
}
|
|
175
179
|
|
|
180
|
+
/* Inset on both sides, unlike the sparkline at rest (which bleeds): a placeholder that touches one
|
|
181
|
+
* card edge and stops short of the other reads as misaligned, and a Meter in the slot is inset anyway. */
|
|
176
182
|
.skeletonVisual {
|
|
177
183
|
--skeleton-radius: 0;
|
|
178
184
|
height: var(--basalt-stat-visual-h);
|
|
179
|
-
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
.sparklineRight .skeletonVisual {
|
|
183
188
|
flex: 1 1 auto;
|
|
184
|
-
margin-inline: 0;
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
.skeletonRowBox {
|
|
@@ -306,23 +310,24 @@
|
|
|
306
310
|
color: var(--vx-muted);
|
|
307
311
|
}
|
|
308
312
|
|
|
309
|
-
/*
|
|
313
|
+
/* Sans and ink — a breakdown value is a number, and it is the half of the row worth reading. Never
|
|
310
314
|
* shrinks: the LABEL is the prose half and the one that may ellipsize. */
|
|
311
315
|
.breakdownValue {
|
|
312
316
|
flex-shrink: 0;
|
|
313
317
|
margin: 0;
|
|
314
|
-
font-family: var(--basalt-font-
|
|
318
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
319
|
+
font-variant-numeric: lining-nums;
|
|
315
320
|
font-size: var(--vx-text-sm);
|
|
316
321
|
font-weight: 500;
|
|
317
322
|
color: var(--vx-ink);
|
|
318
323
|
}
|
|
319
324
|
|
|
320
325
|
/*
|
|
321
|
-
* A row past a threshold. Same vocabulary and the same per-scheme solids as the card's own tone
|
|
322
|
-
* (`
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
+
* A row past a threshold. Same vocabulary and the same per-scheme solids as the card's own tone dot
|
|
327
|
+
* (`VX.status[tone]`), so a row saying `bad` and a dot saying `bad` are one claim at two scales.
|
|
328
|
+
* Colour is not the only carrier at the CARD level (the dot ships a word); at
|
|
329
|
+
* the ROW level the label is the carrier — a row reading `Paid · 1,204` states its own subject
|
|
330
|
+
* either way, and the tint only ranks it.
|
|
326
331
|
*/
|
|
327
332
|
.breakdownRow[data-tone='good'] .breakdownValue {
|
|
328
333
|
color: var(--vx-status-good);
|
|
@@ -341,6 +346,23 @@
|
|
|
341
346
|
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
342
347
|
}
|
|
343
348
|
|
|
349
|
+
/* A Meter in the visual slot is a block, not a chart: it sizes to its content and keeps the card's
|
|
350
|
+
* inline inset instead of the sparkline's fixed 22px and side bleed. */
|
|
351
|
+
.sparklineBleed:has(> [data-basalt-meter]) {
|
|
352
|
+
height: auto;
|
|
353
|
+
margin-inline: 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* The `right` placement: the fixed basis, 22px height and clip are a sparkline's box. A Meter takes the
|
|
357
|
+
* row's remaining width and its own height, unclipped. */
|
|
358
|
+
.sparklineRight:has(> [data-basalt-meter]) {
|
|
359
|
+
flex: 1 1 auto;
|
|
360
|
+
height: auto;
|
|
361
|
+
padding-top: 0;
|
|
362
|
+
overflow: visible;
|
|
363
|
+
align-items: stretch;
|
|
364
|
+
}
|
|
365
|
+
|
|
344
366
|
/* Asks for `StatCard`'s `SPARKLINE_RIGHT_WIDTH`/`_HEIGHT` (handed down as custom properties, so this
|
|
345
367
|
* rule and the narrow-card reset below can both reach them). `align-self: flex-end` is the one alignment
|
|
346
368
|
* this restructure keeps at the SPARKLINE's own level rather than the row's: `.metricsRow` does not
|
|
@@ -351,7 +373,9 @@
|
|
|
351
373
|
display: flex;
|
|
352
374
|
flex: 0 1 var(--basalt-stat-sparkline-w, 4.5rem);
|
|
353
375
|
min-width: 0;
|
|
354
|
-
|
|
376
|
+
/* The slot clips, so it holds the Sparkline's readout line inside its own box (padding-top). */
|
|
377
|
+
height: calc(var(--basalt-stat-sparkline-h, 1.375rem) + var(--basalt-spark-readout-h));
|
|
378
|
+
padding-top: var(--basalt-spark-readout-h);
|
|
355
379
|
align-items: flex-end;
|
|
356
380
|
align-self: flex-end;
|
|
357
381
|
overflow: hidden;
|
|
@@ -375,4 +399,8 @@
|
|
|
375
399
|
margin-top: auto;
|
|
376
400
|
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
377
401
|
}
|
|
402
|
+
|
|
403
|
+
.metricsRow .sparklineRight:has(> [data-basalt-meter], > .skeletonVisual) {
|
|
404
|
+
margin-inline: 0;
|
|
405
|
+
}
|
|
378
406
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 1. the CAPTION row — `title` as a mono uppercase `micro` faint label, the optional `info` glyph,
|
|
6
6
|
* `qualifier` right-aligned (period, target or source; it takes its own line UNDER the caption,
|
|
7
7
|
* left-aligned, when the card is too narrow for both), and the `actions` slot;
|
|
8
|
-
* 2. the VALUE row — the hero figure (`kpi`,
|
|
8
|
+
* 2. the VALUE row — the hero figure (`kpi`, sans 500, lining), `unit` inline at `sm` muted on the same
|
|
9
9
|
* baseline, then the delta (text only — see `DeltaBadge`) and its muted `deltaPeriod`;
|
|
10
10
|
* 3. the FOOT — the `sparkline` visual (22 px, bled to the card's side edges) and one muted `sm`
|
|
11
11
|
* `subtitle` line under it (a source or "as of", never a restatement of the caption).
|
|
@@ -31,15 +31,14 @@
|
|
|
31
31
|
* (`emptyText`). `loading` shows the same skeleton with no query at all. The caption row stays put
|
|
32
32
|
* in every branch.
|
|
33
33
|
*
|
|
34
|
-
* `tone`
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* the meaning of omission: it exists for the threshold where the calm number IS the finding (zero
|
|
34
|
+
* `tone` states a threshold verdict as a status dot plus a short word on the caption row (`OK`,
|
|
35
|
+
* `Watch`, `Over`), with the full phrase for assistive tech. The dot carries the colour and the word
|
|
36
|
+
* the meaning, so the verdict never rides on colour alone. It exists because `value` is typed
|
|
37
|
+
* `string`: without it, a card whose number has crossed a threshold reads exactly as calm as one
|
|
38
|
+
* that hasn't. A coloured edge stripe is not the form — it reads as generic dashboard decoration
|
|
39
|
+
* (Wave 34). `undefined` renders nothing at all — absence of a reading is neither a good one nor a
|
|
40
|
+
* bad one, and must never be tinted. `'good'` is a deliberate positive verdict, never the meaning
|
|
41
|
+
* of omission: it exists for the threshold where the calm number IS the finding (zero
|
|
43
42
|
* downtime over the window), and a card that has measured nothing must not be able to reach green by
|
|
44
43
|
* leaving the prop off.
|
|
45
44
|
*
|
|
@@ -74,7 +73,7 @@
|
|
|
74
73
|
* <StatCard title="Active users" value="—" loading sparkline={() => null} />
|
|
75
74
|
*
|
|
76
75
|
* @example
|
|
77
|
-
* // Past a threshold —
|
|
76
|
+
* // Past a threshold — a status dot and the word "Over" on the caption row, value untouched.
|
|
78
77
|
* <StatCard title="Downtime" value="29 min" tone="bad" />
|
|
79
78
|
*
|
|
80
79
|
* @example
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
* tone={hasCoverage ? (downtimeMinutes === 0 ? 'good' : 'bad') : undefined}
|
|
91
90
|
* />
|
|
92
91
|
*/
|
|
93
|
-
import {
|
|
92
|
+
import { Card, VisuallyHidden } from '@mantine/core'
|
|
94
93
|
import { useEffect, useState } from 'react'
|
|
95
94
|
import type { ReactNode } from 'react'
|
|
96
95
|
import {
|
|
@@ -108,7 +107,6 @@ import type {
|
|
|
108
107
|
WidgetHeaderTitleProps,
|
|
109
108
|
} from './widget-header'
|
|
110
109
|
import { DeltaBadge } from './delta-badge'
|
|
111
|
-
import { VX } from '../tokens'
|
|
112
110
|
import { cx } from '../common/props'
|
|
113
111
|
import type { BasaltProps, SlotStylesProps, Tone } from '../common/props'
|
|
114
112
|
import { ErrorState, QueryState, resolveQueryBranch } from './query-state'
|
|
@@ -126,7 +124,7 @@ export type StatCardSlot = 'root' | 'header' | 'body' | 'sparkline'
|
|
|
126
124
|
*
|
|
127
125
|
* `value` is a pre-formatted `string` for the same reason the hero's is: the card cannot know the
|
|
128
126
|
* locale, the currency or the precision the number was measured at. `tone` marks ONE row as past a
|
|
129
|
-
* threshold and is the same vocabulary as the card's own `tone`, so a row saying `bad` and a
|
|
127
|
+
* threshold and is the same vocabulary as the card's own `tone`, so a row saying `bad` and a dot
|
|
130
128
|
* saying `bad` are the same claim at two scales; omitting it is untinted, never `'good'`.
|
|
131
129
|
*/
|
|
132
130
|
export type StatCardBreakdownRow = {
|
|
@@ -193,16 +191,6 @@ function useSlotWidth(active: boolean): {
|
|
|
193
191
|
return { ref: setNode, width }
|
|
194
192
|
}
|
|
195
193
|
|
|
196
|
-
/** The rail's width, in px. Wide enough to read as a deliberate mark at a glance, narrow enough
|
|
197
|
-
* that it cannot be mistaken for the card's own edge. */
|
|
198
|
-
const TONE_RAIL_WIDTH = 3
|
|
199
|
-
|
|
200
|
-
const TONE_LABEL: Record<Tone, string> = {
|
|
201
|
-
good: 'Within the good threshold',
|
|
202
|
-
warn: 'Past the warning threshold',
|
|
203
|
-
bad: 'Past the severe threshold',
|
|
204
|
-
}
|
|
205
|
-
|
|
206
194
|
/**
|
|
207
195
|
* `StatCard` re-publishes three NAMED `WidgetHeader` slices (`WidgetHeaderTitleProps` /
|
|
208
196
|
* `WidgetHeaderMetricProps` / `WidgetHeaderDeltaProps`, audit B #2) rather than re-declaring the
|
|
@@ -223,7 +211,7 @@ export type StatCardProps = BasaltProps &
|
|
|
223
211
|
Omit<WidgetHeaderTitleProps, 'subtitle'> &
|
|
224
212
|
Omit<WidgetHeaderMetricProps, 'value'> &
|
|
225
213
|
WidgetHeaderDeltaProps & {
|
|
226
|
-
/** Pre-formatted hero figure (
|
|
214
|
+
/** Pre-formatted hero figure (sans `kpi`, weight 500, lining, ink). Required here, unlike on
|
|
227
215
|
* `WidgetHeader`: see the type's own doc. */
|
|
228
216
|
value: string
|
|
229
217
|
/**
|
|
@@ -302,10 +290,11 @@ export type StatCardProps = BasaltProps &
|
|
|
302
290
|
/** Caption-row right slot (e.g. a ghost "..." menu trigger) — wrapped in `CtlSlot tier="widget"`,
|
|
303
291
|
* so a raw `ActionIcon` with no `size` lands on the 24px step the caption row holds (C1/C5). */
|
|
304
292
|
actions?: ReactNode
|
|
305
|
-
/** Threshold verdict —
|
|
306
|
-
* assistive tech. Omitting it is NOT `'good'`: omitted covers a
|
|
307
|
-
* is absent, and stays untinted so a card with nothing
|
|
308
|
-
* `'good'` only to assert a measured value that has
|
|
293
|
+
/** Threshold verdict — a status dot plus a short word (`OK` / `Watch` / `Over`) on the caption
|
|
294
|
+
* row, with the full phrase for assistive tech. Omitting it is NOT `'good'`: omitted covers a
|
|
295
|
+
* reading that is fine AND one that is absent, and stays untinted so a card with nothing
|
|
296
|
+
* measured can never render green. Pass `'good'` only to assert a measured value that has
|
|
297
|
+
* earned the verdict. */
|
|
309
298
|
tone?: Tone
|
|
310
299
|
}
|
|
311
300
|
|
|
@@ -501,11 +490,9 @@ export function StatCard({
|
|
|
501
490
|
<Card
|
|
502
491
|
className={cx(classNames?.root, className)}
|
|
503
492
|
style={{
|
|
504
|
-
//
|
|
505
|
-
//
|
|
506
|
-
//
|
|
507
|
-
// the responsive half of the ladder lives in `spaceMobileDecls` (`tokens/index.ts`), which
|
|
508
|
-
// is the only home that can reach an inline style like this one.
|
|
493
|
+
// The inset is the theme's (`card-inset.module.css`: the `cardInsetY`/`cardInsetX` tokens, 12/16
|
|
494
|
+
// at level 0, stepping the horizontal one down a rung below `sm`), so it is NOT restated here —
|
|
495
|
+
// an inline copy would bypass `variant="flush"`.
|
|
509
496
|
//
|
|
510
497
|
// `overflow: hidden` clips the full-bleed sparkline to the card's rounded corners. An
|
|
511
498
|
// element's own `box-shadow` renders outside its border box and is NOT clipped by its own
|
|
@@ -513,10 +500,8 @@ export function StatCard({
|
|
|
513
500
|
//
|
|
514
501
|
// NO `minHeight`: the content states the height (the foot reserves its own), and cards in a
|
|
515
502
|
// grid row stretch to the tallest.
|
|
516
|
-
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
517
503
|
overflow: 'hidden',
|
|
518
|
-
//
|
|
519
|
-
// depending on whether it happens to have crossed a threshold this render.
|
|
504
|
+
// Consumers may anchor overlays (badges, menus) to the card, so it stays a positioned box.
|
|
520
505
|
position: 'relative',
|
|
521
506
|
// The card's own width drives its chrome (`stat-card.module.css`).
|
|
522
507
|
containerType: 'inline-size',
|
|
@@ -525,29 +510,6 @@ export function StatCard({
|
|
|
525
510
|
}}
|
|
526
511
|
data-tone={tone}
|
|
527
512
|
>
|
|
528
|
-
{tone !== undefined && (
|
|
529
|
-
<>
|
|
530
|
-
{/* The rail is decoration; the verdict it encodes is real information, so it is also
|
|
531
|
-
stated in text for anyone who cannot see a 3px colour bar. Colour alone is never the
|
|
532
|
-
only carrier of a threshold. */}
|
|
533
|
-
<VisuallyHidden>{TONE_LABEL[tone]}</VisuallyHidden>
|
|
534
|
-
<Box
|
|
535
|
-
aria-hidden="true"
|
|
536
|
-
style={{
|
|
537
|
-
position: 'absolute',
|
|
538
|
-
insetBlock: 0,
|
|
539
|
-
insetInlineStart: 0,
|
|
540
|
-
width: TONE_RAIL_WIDTH,
|
|
541
|
-
// `Tone`'s members are `VX.status` keys by construction, so the rail reads the
|
|
542
|
-
// per-scheme `--vx-status-*` solid directly — never a hex, so it re-resolves in both
|
|
543
|
-
// schemes and under a consumer's `derive` retune. Contrast against
|
|
544
|
-
// `--vx-surface-panel` is measured in `theme/contrast.test.ts`.
|
|
545
|
-
background: VX.status[tone],
|
|
546
|
-
}}
|
|
547
|
-
/>
|
|
548
|
-
</>
|
|
549
|
-
)}
|
|
550
|
-
|
|
551
513
|
<div
|
|
552
514
|
className={cx(classes.body, classNames?.body)}
|
|
553
515
|
data-placement={sparklinePlacement}
|
|
@@ -560,6 +522,7 @@ export function StatCard({
|
|
|
560
522
|
{...(icon !== undefined && { icon })}
|
|
561
523
|
{...(info !== undefined && { info })}
|
|
562
524
|
{...(qualifier !== undefined && { qualifier })}
|
|
525
|
+
{...(tone !== undefined && { tone })}
|
|
563
526
|
{...(actions !== undefined && { actions })}
|
|
564
527
|
/>
|
|
565
528
|
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* rule on the GROUP, so the cells stay whatever they are; on `StatCard`s (which carry their own
|
|
22
22
|
* panel and shadow ring) the rail reads as a second frame, so pair it with unadorned children.
|
|
23
23
|
*
|
|
24
|
+
* `variant="strip"` is the joined-surface form with typed cells and a footer row (`stat-strip.tsx`).
|
|
25
|
+
*
|
|
24
26
|
* @example
|
|
25
27
|
* import { StatCard, StatGroup } from 'basalt-ui'
|
|
26
28
|
*
|
|
@@ -33,12 +35,15 @@
|
|
|
33
35
|
import type { CSSProperties, ReactNode } from 'react'
|
|
34
36
|
import { cx } from '../common/props'
|
|
35
37
|
import type { BasaltProps } from '../common/props'
|
|
38
|
+
import { StatStrip } from './stat-strip'
|
|
39
|
+
import type { StatStripProps } from './stat-strip'
|
|
36
40
|
import classes from './stat-group.module.css'
|
|
37
41
|
|
|
38
42
|
/** The desktop KPI column count. */
|
|
39
43
|
export type StatGroupCols = 2 | 3 | 4 | 5
|
|
40
44
|
|
|
41
|
-
export type
|
|
45
|
+
export type StatGridProps = BasaltProps & {
|
|
46
|
+
variant?: 'grid'
|
|
42
47
|
/** The DESKTOP column count (`lg` and up). Default `4`. `sm` gets `min(cols, 3)` — except `4`, which gets 2 rather than an orphan row. A phone gets 2.
|
|
43
48
|
* Never a responsive object — the law is basalt's, see the module docblock. */
|
|
44
49
|
cols?: StatGroupCols
|
|
@@ -48,13 +53,19 @@ export type StatGroupProps = BasaltProps & {
|
|
|
48
53
|
children: ReactNode
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/** `variant="strip"`: one joined surface of typed `cells` split by hairlines, plus an optional
|
|
57
|
+
* `footer` row — see `StatStripProps`. `cols` here may be 6 (the strip's desktop count). */
|
|
58
|
+
export type StatGroupProps = StatGridProps | ({ variant: 'strip' } & StatStripProps)
|
|
59
|
+
|
|
60
|
+
export function StatGroup(props: StatGroupProps) {
|
|
61
|
+
if (props.variant === 'strip') {
|
|
62
|
+
const { variant: _variant, ...strip } = props
|
|
63
|
+
return <StatStrip {...strip} />
|
|
64
|
+
}
|
|
65
|
+
return <StatGrid {...props} />
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function StatGrid({ cols = 4, divided = false, children, className, style }: StatGridProps) {
|
|
58
69
|
// `4 -> 2`, not `4 -> 3`. `min(cols, 3)` is the general rule and it is right for 2, 3 and 5, but
|
|
59
70
|
// FOUR is the default and the overwhelmingly common count, and three columns leave a four-KPI row
|
|
60
71
|
// as 3 + 1 — one orphan cell against two thirds of empty track. MEASURED on the playground
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* StatGroup `variant="strip"`: one joined surface, cells split by 1px hairlines.
|
|
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.
|
|
9
|
+
*
|
|
10
|
+
* The column law keys on the CONTAINER like `StatGroup`'s own: two columns at < 480px (the `regular` class boundary) with an odd
|
|
11
|
+
* last cell spanning, never one; up to three below 800px; the full `cols` from 800px.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
.container {
|
|
15
|
+
container-type: inline-size;
|
|
16
|
+
container-name: basalt-grid;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.clip {
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.cells {
|
|
24
|
+
display: grid;
|
|
25
|
+
grid-template-columns: repeat(var(--basalt-strip-cols-sm), minmax(0, 1fr));
|
|
26
|
+
margin: -1px 0 0 -1px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.cell {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: var(--vx-space-stack-sm);
|
|
33
|
+
min-width: 0;
|
|
34
|
+
padding: var(--vx-space-stack-md);
|
|
35
|
+
border-inline-start: 1px solid var(--vx-divider);
|
|
36
|
+
}
|
|
37
|
+
|
|
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);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@container basalt-grid (max-width: 479.9px) {
|
|
45
|
+
.cells {
|
|
46
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.cells > .cell:last-child:nth-child(odd) {
|
|
50
|
+
grid-column: 1 / -1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@container basalt-grid (min-width: 800px) {
|
|
55
|
+
.cells {
|
|
56
|
+
grid-template-columns: repeat(var(--basalt-strip-cols), minmax(0, 1fr));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.captionLine {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-wrap: wrap;
|
|
63
|
+
align-items: center;
|
|
64
|
+
column-gap: var(--vx-space-control-gap);
|
|
65
|
+
min-width: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Caption and info glyph are one unit: the caption truncates, the glyph never leaves its line. */
|
|
69
|
+
.lead {
|
|
70
|
+
display: inline-flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
column-gap: var(--vx-space-control-gap);
|
|
73
|
+
min-width: 0;
|
|
74
|
+
max-width: 100%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.caption {
|
|
78
|
+
margin: 0;
|
|
79
|
+
min-width: 0;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
text-overflow: ellipsis;
|
|
82
|
+
white-space: nowrap;
|
|
83
|
+
font-family: var(--basalt-font-mono);
|
|
84
|
+
font-size: var(--vx-text-micro);
|
|
85
|
+
font-weight: 500;
|
|
86
|
+
letter-spacing: 0.06em;
|
|
87
|
+
text-transform: uppercase;
|
|
88
|
+
color: var(--vx-faint);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* The lowercase qualifier is the muted sans (mono is for the UPPERCASE caption only). It is one flex
|
|
92
|
+
* item, so when it does not fit beside the caption it wraps WHOLE onto its own line below. */
|
|
93
|
+
.qualifier {
|
|
94
|
+
font-size: var(--vx-text-micro);
|
|
95
|
+
color: var(--vx-muted);
|
|
96
|
+
overflow-wrap: anywhere;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.valueRow {
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-wrap: wrap;
|
|
102
|
+
align-items: baseline;
|
|
103
|
+
column-gap: var(--vx-space-stack-sm);
|
|
104
|
+
min-width: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* The numeral face (proportional sans, lining figures; Wave 35 typography law): never mono. */
|
|
108
|
+
.value {
|
|
109
|
+
min-width: 0;
|
|
110
|
+
overflow-wrap: anywhere;
|
|
111
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
112
|
+
font-size: var(--vx-text-kpi);
|
|
113
|
+
line-height: 1.25;
|
|
114
|
+
font-weight: 500;
|
|
115
|
+
letter-spacing: -0.02em;
|
|
116
|
+
font-variant-numeric: lining-nums;
|
|
117
|
+
color: var(--vx-ink);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.unit {
|
|
121
|
+
flex-shrink: 0;
|
|
122
|
+
font-size: var(--vx-text-sm);
|
|
123
|
+
font-weight: 500;
|
|
124
|
+
color: var(--vx-muted);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.skeletonValue {
|
|
128
|
+
width: 45%;
|
|
129
|
+
height: calc(var(--vx-text-kpi) * 1.25);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.cell[data-stale] {
|
|
133
|
+
/* The package's one dimmed-state value (controls.module.css, panel-row.module.css). */
|
|
134
|
+
opacity: 0.55;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.skeletonRow {
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 0.75rem;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.visual {
|
|
143
|
+
min-width: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* A Sparkline's hover readout takes this line above its plot (`charts/sparkline.module.css`). The
|
|
147
|
+
* cell's own stack gap already sits above it; the slot reserves the rest, so the chip never covers
|
|
148
|
+
* the value. */
|
|
149
|
+
.cell {
|
|
150
|
+
--basalt-spark-readout-h: 1.125rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.visual:has([data-basalt-sparkline]) {
|
|
154
|
+
padding-top: max(0px, calc(var(--basalt-spark-readout-h) - var(--vx-space-stack-sm)));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.footer {
|
|
158
|
+
margin-top: auto;
|
|
159
|
+
font-size: var(--vx-text-sm);
|
|
160
|
+
color: var(--vx-muted);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* ── multi-row cell: label · visual · value · delta ──────────────────────────────────────────── */
|
|
164
|
+
|
|
165
|
+
.rows {
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
gap: var(--vx-space-stack-sm);
|
|
169
|
+
margin: 0;
|
|
170
|
+
padding: 0;
|
|
171
|
+
list-style: none;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.row {
|
|
175
|
+
display: grid;
|
|
176
|
+
grid-template-columns: minmax(3.5rem, auto) minmax(0, 1fr) auto auto;
|
|
177
|
+
align-items: center;
|
|
178
|
+
column-gap: var(--vx-space-stack-sm);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.rowLabel {
|
|
182
|
+
font-size: var(--vx-text-sm);
|
|
183
|
+
color: var(--vx-muted);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.rowValue {
|
|
187
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
188
|
+
font-size: var(--vx-text-sm);
|
|
189
|
+
font-weight: 500;
|
|
190
|
+
font-variant-numeric: lining-nums;
|
|
191
|
+
color: var(--vx-ink);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* ── footer row: wider cells under the cells, split by the same hairline ─────────────────────── */
|
|
195
|
+
|
|
196
|
+
.footerRow {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-wrap: wrap;
|
|
199
|
+
margin-left: -1px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.footerCell {
|
|
203
|
+
flex: 1 1 14rem;
|
|
204
|
+
min-width: 0;
|
|
205
|
+
padding: var(--vx-space-stack-md);
|
|
206
|
+
border-inline-start: 1px solid var(--vx-divider);
|
|
207
|
+
border-block-start: 1px solid var(--vx-divider);
|
|
208
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly container: string
|
|
7
|
+
readonly clip: string
|
|
8
|
+
readonly cells: string
|
|
9
|
+
readonly cell: string
|
|
10
|
+
readonly captionLine: string
|
|
11
|
+
readonly lead: string
|
|
12
|
+
readonly caption: string
|
|
13
|
+
readonly qualifier: string
|
|
14
|
+
readonly valueRow: string
|
|
15
|
+
readonly value: string
|
|
16
|
+
readonly unit: string
|
|
17
|
+
readonly skeletonValue: string
|
|
18
|
+
readonly skeletonRow: string
|
|
19
|
+
readonly visual: string
|
|
20
|
+
readonly footer: string
|
|
21
|
+
readonly rows: string
|
|
22
|
+
readonly row: string
|
|
23
|
+
readonly rowLabel: string
|
|
24
|
+
readonly rowValue: string
|
|
25
|
+
readonly footerRow: string
|
|
26
|
+
readonly footerCell: string
|
|
27
|
+
}
|
|
28
|
+
export default classes
|