basalt-ui 2.19.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 +50 -0
- package/MIGRATING.md +174 -12
- 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/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 +39 -15
- package/dist/dashboard/bar-list.module.css +77 -2
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +19 -0
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +18 -1
- 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 +114 -74
- package/dist/dashboard/meter.d.ts +22 -1
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +4 -1
- package/dist/dashboard/meter.module.css +90 -12
- package/dist/dashboard/meter.module.css.d.ts +5 -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.js +1 -1
- package/dist/dashboard/stat-card.d.ts +1 -1
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +3 -6
- package/dist/dashboard/stat-card.module.css +15 -7
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +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.module.css +10 -6
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +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/controls.module.css +3 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +23 -0
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +3 -2
- package/dist/theme/status-dot.d.ts.map +1 -1
- package/dist/theme/status-dot.js +12 -3
- package/dist/theme/status-verdict.d.ts +3 -2
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +3 -2
- package/dist/theme/status-verdict.module.css +4 -2
- package/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/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +77 -2
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +86 -18
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +35 -0
- package/src/dashboard/meter-parts.tsx +119 -23
- package/src/dashboard/meter.module.css +90 -12
- package/src/dashboard/meter.module.css.d.ts +5 -0
- package/src/dashboard/meter.tsx +26 -2
- package/src/dashboard/query-state.tsx +28 -19
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +15 -7
- package/src/dashboard/stat-card.tsx +5 -8
- 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 +10 -6
- package/src/dashboard/widget-header.tsx +3 -3
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +1 -1
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +168 -24
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/controls.module.css +3 -0
- package/src/theme/index.ts +30 -0
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.tsx +17 -5
- package/src/theme/status-verdict.module.css +4 -2
- package/src/theme/status-verdict.tsx +9 -4
|
@@ -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);
|
|
@@ -306,12 +310,13 @@
|
|
|
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);
|
|
@@ -353,6 +358,7 @@
|
|
|
353
358
|
.sparklineRight:has(> [data-basalt-meter]) {
|
|
354
359
|
flex: 1 1 auto;
|
|
355
360
|
height: auto;
|
|
361
|
+
padding-top: 0;
|
|
356
362
|
overflow: visible;
|
|
357
363
|
align-items: stretch;
|
|
358
364
|
}
|
|
@@ -367,7 +373,9 @@
|
|
|
367
373
|
display: flex;
|
|
368
374
|
flex: 0 1 var(--basalt-stat-sparkline-w, 4.5rem);
|
|
369
375
|
min-width: 0;
|
|
370
|
-
|
|
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);
|
|
371
379
|
align-items: flex-end;
|
|
372
380
|
align-self: flex-end;
|
|
373
381
|
overflow: hidden;
|
|
@@ -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).
|
|
@@ -211,7 +211,7 @@ export type StatCardProps = BasaltProps &
|
|
|
211
211
|
Omit<WidgetHeaderTitleProps, 'subtitle'> &
|
|
212
212
|
Omit<WidgetHeaderMetricProps, 'value'> &
|
|
213
213
|
WidgetHeaderDeltaProps & {
|
|
214
|
-
/** Pre-formatted hero figure (
|
|
214
|
+
/** Pre-formatted hero figure (sans `kpi`, weight 500, lining, ink). Required here, unlike on
|
|
215
215
|
* `WidgetHeader`: see the type's own doc. */
|
|
216
216
|
value: string
|
|
217
217
|
/**
|
|
@@ -490,11 +490,9 @@ export function StatCard({
|
|
|
490
490
|
<Card
|
|
491
491
|
className={cx(classNames?.root, className)}
|
|
492
492
|
style={{
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
// the responsive half of the ladder lives in `spaceMobileDecls` (`tokens/index.ts`), which
|
|
497
|
-
// 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"`.
|
|
498
496
|
//
|
|
499
497
|
// `overflow: hidden` clips the full-bleed sparkline to the card's rounded corners. An
|
|
500
498
|
// element's own `box-shadow` renders outside its border box and is NOT clipped by its own
|
|
@@ -502,7 +500,6 @@ export function StatCard({
|
|
|
502
500
|
//
|
|
503
501
|
// NO `minHeight`: the content states the height (the foot reserves its own), and cards in a
|
|
504
502
|
// grid row stretch to the tallest.
|
|
505
|
-
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
506
503
|
overflow: 'hidden',
|
|
507
504
|
// Consumers may anchor overlays (badges, menus) to the card, so it stays a positioned box.
|
|
508
505
|
position: 'relative',
|
|
@@ -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
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatStrip — the body of `StatGroup variant="strip"`: KPI cells joined into one surface and split
|
|
3
|
+
* by hairlines, with an optional footer row of wider cells. Internal: reached through `StatGroup`.
|
|
4
|
+
*
|
|
5
|
+
* Cell anatomy: a mono caption (with `· qualifier` muted on the same line and the `info` glyph), the
|
|
6
|
+
* hero `value` in the proportional sans, an optional `delta`, `visual` and `footer` line. `rows`
|
|
7
|
+
* replaces the hero with aligned `label · visual · value · delta` rows (one cell, several signals).
|
|
8
|
+
* `tone` inks the VALUE only, for a verdict; a null reading is `—`. A cell may carry BOTH: the hero
|
|
9
|
+
* (e.g. VO2max) with `rows` under it; omit `value` to render the rows alone.
|
|
10
|
+
*
|
|
11
|
+
* Anchors: each cell is `data-shot="strip-<key>"` and each footer cell
|
|
12
|
+
* `data-shot="strip-footer-<key>"` (derived — a consumer cannot choose another name).
|
|
13
|
+
*
|
|
14
|
+
* Mapping from a prototype: warden's JSX `qualifier` line UNDER the value is `footer`; the cell
|
|
15
|
+
* `qualifier` is the short `· text` on the caption line. Cells are equal-weight: unequal column
|
|
16
|
+
* weights are not supported. `stale` dims a cell while placeholder data shows.
|
|
17
|
+
*/
|
|
18
|
+
import { Card, Skeleton } from '@mantine/core'
|
|
19
|
+
import { useId } from 'react'
|
|
20
|
+
import type { CSSProperties, ReactNode } from 'react'
|
|
21
|
+
import { cx } from '../common/props'
|
|
22
|
+
import type { BasaltProps, Tone } from '../common/props'
|
|
23
|
+
import { VX } from '../tokens'
|
|
24
|
+
import { InfoGlyph } from './widget-header'
|
|
25
|
+
import classes from './stat-strip.module.css'
|
|
26
|
+
|
|
27
|
+
export type StatStripRow = {
|
|
28
|
+
key: string
|
|
29
|
+
label: string
|
|
30
|
+
/** `null` = no reading, printed as `—`. Pre-join the unit (`'48 ms'`). */
|
|
31
|
+
value: string | null
|
|
32
|
+
visual?: ReactNode
|
|
33
|
+
/** A `DeltaBadge`. */
|
|
34
|
+
delta?: ReactNode
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type StatStripCell = {
|
|
38
|
+
key: string
|
|
39
|
+
caption: string
|
|
40
|
+
/** Muted, on the caption line: `CAPTION · qualifier`. */
|
|
41
|
+
qualifier?: string
|
|
42
|
+
/** The definition behind the caption, in the info-glyph tooltip. */
|
|
43
|
+
info?: string
|
|
44
|
+
/** `null` = no reading, printed as `—`. Omit only when `rows` carries the cell. */
|
|
45
|
+
value?: string | null
|
|
46
|
+
unit?: string
|
|
47
|
+
/** A `DeltaBadge`. */
|
|
48
|
+
delta?: ReactNode
|
|
49
|
+
/** The micro-visual slot (Meter / Sparkline / BandStrip). */
|
|
50
|
+
visual?: ReactNode
|
|
51
|
+
/** A muted line pinned to the cell foot. */
|
|
52
|
+
footer?: ReactNode
|
|
53
|
+
/** Aligned signals under the hero (or alone when `value` is omitted). */
|
|
54
|
+
rows?: readonly StatStripRow[]
|
|
55
|
+
/** Inks the value only — set it when the reading is a verdict. */
|
|
56
|
+
tone?: Tone
|
|
57
|
+
/** Skeleton in place of the readings. */
|
|
58
|
+
loading?: boolean
|
|
59
|
+
/** Dims the cell while placeholder data shows. */
|
|
60
|
+
stale?: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type StatStripProps = BasaltProps & {
|
|
64
|
+
/** The strip's accessible name. */
|
|
65
|
+
label: string
|
|
66
|
+
cells: readonly StatStripCell[]
|
|
67
|
+
/** Wider cells under the cells. */
|
|
68
|
+
footer?: readonly { key: string; content: ReactNode }[]
|
|
69
|
+
/** The DESKTOP column count. Default: the cell count, capped at 6. */
|
|
70
|
+
cols?: 2 | 3 | 4 | 5 | 6
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const EMPTY = '—'
|
|
74
|
+
|
|
75
|
+
function StripCell({ cell }: { cell: StatStripCell }) {
|
|
76
|
+
const captionId = useId()
|
|
77
|
+
const { rows, loading } = cell
|
|
78
|
+
const hasHero = cell.value !== undefined || rows === undefined
|
|
79
|
+
return (
|
|
80
|
+
<article
|
|
81
|
+
className={classes.cell}
|
|
82
|
+
data-strip-cell={cell.key}
|
|
83
|
+
data-shot={`strip-${cell.key}`}
|
|
84
|
+
aria-labelledby={captionId}
|
|
85
|
+
{...(cell.stale && { 'data-stale': 'true' })}
|
|
86
|
+
>
|
|
87
|
+
<div className={classes.captionLine}>
|
|
88
|
+
{/* The caption and its info glyph are one unit: the qualifier wraps whole, never between them. */}
|
|
89
|
+
<span className={classes.lead}>
|
|
90
|
+
<span className={classes.caption} id={captionId} title={cell.caption} data-strip-caption>
|
|
91
|
+
{cell.caption}
|
|
92
|
+
</span>
|
|
93
|
+
{cell.info !== undefined && <InfoGlyph text={cell.info} />}
|
|
94
|
+
</span>
|
|
95
|
+
{cell.qualifier !== undefined && (
|
|
96
|
+
<span className={classes.qualifier}>{cell.qualifier}</span>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
{hasHero &&
|
|
100
|
+
(loading ? (
|
|
101
|
+
<Skeleton className={classes.skeletonValue} radius="sm" />
|
|
102
|
+
) : (
|
|
103
|
+
<div className={classes.valueRow}>
|
|
104
|
+
<span
|
|
105
|
+
className={classes.value}
|
|
106
|
+
data-strip-value
|
|
107
|
+
style={cell.tone !== undefined ? { color: VX.status[cell.tone] } : undefined}
|
|
108
|
+
>
|
|
109
|
+
{cell.value ?? EMPTY}
|
|
110
|
+
</span>
|
|
111
|
+
{cell.value !== undefined && cell.value !== null && cell.unit !== undefined && (
|
|
112
|
+
<span className={classes.unit}>{cell.unit}</span>
|
|
113
|
+
)}
|
|
114
|
+
{cell.delta}
|
|
115
|
+
</div>
|
|
116
|
+
))}
|
|
117
|
+
{cell.visual !== undefined && <div className={classes.visual}>{cell.visual}</div>}
|
|
118
|
+
{rows !== undefined &&
|
|
119
|
+
(loading ? (
|
|
120
|
+
<div className={classes.rows} aria-hidden="true">
|
|
121
|
+
{rows.map((row) => (
|
|
122
|
+
<Skeleton key={row.key} className={classes.skeletonRow} radius="sm" />
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
) : (
|
|
126
|
+
<ul className={classes.rows}>
|
|
127
|
+
{rows.map((row) => (
|
|
128
|
+
<li key={row.key} className={classes.row} data-strip-row={row.key}>
|
|
129
|
+
<span className={classes.rowLabel}>{row.label}</span>
|
|
130
|
+
<span className={classes.visual}>{row.visual}</span>
|
|
131
|
+
<span className={classes.rowValue}>{row.value ?? EMPTY}</span>
|
|
132
|
+
<span>{row.delta}</span>
|
|
133
|
+
</li>
|
|
134
|
+
))}
|
|
135
|
+
</ul>
|
|
136
|
+
))}
|
|
137
|
+
{cell.footer !== undefined && <div className={classes.footer}>{cell.footer}</div>}
|
|
138
|
+
</article>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function StatStrip({ label, cells, footer, cols, className, style }: StatStripProps) {
|
|
143
|
+
const desktop = cols ?? Math.min(Math.max(cells.length, 2), 6)
|
|
144
|
+
// `StatGroup`'s rule: four is 2 + 2 below the full count, never 3 + 1.
|
|
145
|
+
const mid = desktop === 4 ? 2 : Math.min(desktop, 3)
|
|
146
|
+
return (
|
|
147
|
+
<div className={cx(classes.container, className)} style={style}>
|
|
148
|
+
<Card>
|
|
149
|
+
<Card.Section
|
|
150
|
+
component="section"
|
|
151
|
+
aria-label={label}
|
|
152
|
+
className={classes.clip}
|
|
153
|
+
style={
|
|
154
|
+
{
|
|
155
|
+
'--basalt-strip-cols': desktop,
|
|
156
|
+
'--basalt-strip-cols-sm': mid,
|
|
157
|
+
} as CSSProperties
|
|
158
|
+
}
|
|
159
|
+
>
|
|
160
|
+
<div className={classes.cells}>
|
|
161
|
+
{cells.map((cell) => (
|
|
162
|
+
<StripCell key={cell.key} cell={cell} />
|
|
163
|
+
))}
|
|
164
|
+
</div>
|
|
165
|
+
{footer !== undefined && footer.length > 0 && (
|
|
166
|
+
<div className={classes.footerRow}>
|
|
167
|
+
{footer.map((entry) => (
|
|
168
|
+
<div
|
|
169
|
+
key={entry.key}
|
|
170
|
+
className={classes.footerCell}
|
|
171
|
+
data-strip-footer-cell={entry.key}
|
|
172
|
+
data-shot={`strip-footer-${entry.key}`}
|
|
173
|
+
>
|
|
174
|
+
{entry.content}
|
|
175
|
+
</div>
|
|
176
|
+
))}
|
|
177
|
+
</div>
|
|
178
|
+
)}
|
|
179
|
+
</Card.Section>
|
|
180
|
+
</Card>
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
@@ -143,7 +143,8 @@
|
|
|
143
143
|
border-radius: var(--vx-radius-ctrl);
|
|
144
144
|
background: var(--vx-surface-subtle);
|
|
145
145
|
padding: var(--vx-space-badge-inset-y) var(--vx-space-badge-inset-x);
|
|
146
|
-
font-family: var(--basalt-font-
|
|
146
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
147
|
+
font-variant-numeric: lining-nums;
|
|
147
148
|
font-size: var(--vx-text-xs);
|
|
148
149
|
font-weight: 500;
|
|
149
150
|
color: var(--vx-faint);
|
|
@@ -172,7 +173,8 @@
|
|
|
172
173
|
.value {
|
|
173
174
|
min-width: 0;
|
|
174
175
|
overflow-wrap: anywhere;
|
|
175
|
-
font-family: var(--basalt-font-
|
|
176
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
177
|
+
font-variant-numeric: lining-nums;
|
|
176
178
|
font-size: var(--vx-text-kpi);
|
|
177
179
|
font-weight: 500;
|
|
178
180
|
letter-spacing: -0.02em;
|
|
@@ -180,15 +182,16 @@
|
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
/*
|
|
183
|
-
* The unit beside the hero value.
|
|
184
|
-
* baseline
|
|
185
|
+
* The unit beside the hero value. Sans like the number it qualifies (so `412 TSS` sits on one
|
|
186
|
+
* baseline), `--vx-text-sm` and `--vx-muted` so it never competes with the numeral — the whole
|
|
185
187
|
* point is that a unit is the SMALL half of the pair. `flex-shrink: 0`: a unit clipped to `TS…`
|
|
186
188
|
* would state nothing.
|
|
187
189
|
*/
|
|
188
190
|
.unit {
|
|
189
191
|
flex-shrink: 0;
|
|
190
192
|
align-self: baseline;
|
|
191
|
-
font-family: var(--basalt-font-
|
|
193
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
194
|
+
font-variant-numeric: lining-nums;
|
|
192
195
|
font-size: var(--vx-text-sm);
|
|
193
196
|
font-weight: 500;
|
|
194
197
|
color: var(--vx-muted);
|
|
@@ -343,7 +346,8 @@
|
|
|
343
346
|
white-space: nowrap;
|
|
344
347
|
align-items: baseline;
|
|
345
348
|
gap: 3px;
|
|
346
|
-
font-family: var(--basalt-font-
|
|
349
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
350
|
+
font-variant-numeric: lining-nums;
|
|
347
351
|
font-size: var(--vx-text-sm);
|
|
348
352
|
font-weight: 500;
|
|
349
353
|
line-height: 1;
|
|
@@ -77,11 +77,11 @@ export type WidgetHeaderProps = BasaltProps &
|
|
|
77
77
|
* click — so a keyboard user gets it too. Mantine-free: a plain state bubble, not a Tooltip.
|
|
78
78
|
*/
|
|
79
79
|
info?: string
|
|
80
|
-
/** Pre-formatted metric value (
|
|
80
|
+
/** Pre-formatted metric value (sans, lining figures, hero size, never truncated). Renders on its own row with
|
|
81
81
|
* `delta` under the title row, or on the title row in a card 480px or wider. */
|
|
82
82
|
value?: string
|
|
83
83
|
/**
|
|
84
|
-
* The value's unit, rendered immediately after it on the hero row: muted,
|
|
84
|
+
* The value's unit, rendered immediately after it on the hero row: muted, sans, `--vx-text-sm`.
|
|
85
85
|
*
|
|
86
86
|
* It exists because `value` is a pre-formatted `string` and a KPI's unit is not part of the
|
|
87
87
|
* number: `412` and `TSS` are two facts at two weights, and jamming them into one string paints
|
|
@@ -120,7 +120,7 @@ export type WidgetHeaderProps = BasaltProps &
|
|
|
120
120
|
/** Trend visual slot, rendered below the metric row. Carries `data-placement="right"` so a
|
|
121
121
|
* wave-3 composer's `bleed` layout can select it. */
|
|
122
122
|
sparkline?: ReactNode
|
|
123
|
-
/**
|
|
123
|
+
/** Count tag rendered after the title (C11 — every table/list states its count). `0` is a
|
|
124
124
|
* real count and renders, distinct from omitting the prop entirely. */
|
|
125
125
|
count?: number
|
|
126
126
|
/** Right-aligned slot (`margin-inline-start: auto`) — the C1/C5 home for header actions. */
|