basalt-ui 2.20.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/MIGRATING.md +394 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-tokens.md +3 -3
- package/agent/skills/basalt-design/SKILL.md +10 -23
- package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
- package/agent/skills/basalt-design/references/catalogue.md +49 -0
- package/agent/skills/basalt-design/references/concept.md +36 -0
- package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
- package/agent/skills/basalt-design/references/stat-tile.md +24 -0
- package/agent/templates/AGENTS-block.md.tpl +3 -3
- package/configs/oxlint-plugin.js +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +27 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +5 -0
- package/dist/charts/CartesianChart.d.ts +8 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +17 -4
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +33 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +39 -14
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +20 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +9 -0
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +17 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +145 -74
- package/dist/charts/labels.d.ts +15 -4
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +34 -10
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +26 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +63 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +10 -11
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +7 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +4 -1
- package/dist/charts/types.d.ts +14 -5
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +3 -0
- package/dist/cli/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -2
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +27 -15
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +71 -6
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +200 -33
- package/dist/cli/shot/detect.d.ts +51 -0
- package/dist/cli/shot/detect.d.ts.map +1 -0
- package/dist/cli/shot/detect.js +409 -0
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +7 -4
- package/dist/cli/shot/measure.d.ts +2 -0
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +2 -0
- package/dist/cli/shot/playwright.d.ts +5 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/types.d.ts +6 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +4 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/common/retry-button.d.ts +12 -0
- package/dist/common/retry-button.d.ts.map +1 -0
- package/dist/common/retry-button.js +22 -0
- package/dist/common/retry-button.module.css +58 -0
- package/dist/common/retry-button.module.css.d.ts +8 -0
- package/dist/controls/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts +5 -2
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +9 -10
- package/dist/dashboard/bar-list.module.css +53 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +108 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +123 -19
- package/dist/dashboard/meter-parts.d.ts +8 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +345 -146
- package/dist/dashboard/meter.d.ts +50 -63
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +24 -3
- package/dist/dashboard/meter.module.css +79 -65
- package/dist/dashboard/meter.module.css.d.ts +7 -7
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- package/dist/dashboard/query-state.d.ts +1 -1
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +3 -2
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -4
- package/dist/dashboard/stat-card.module.css +17 -0
- package/dist/dashboard/stat-strip.d.ts +24 -1
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +97 -39
- package/dist/dashboard/stat-strip.module.css +147 -17
- package/dist/dashboard/stat-strip.module.css.d.ts +8 -0
- package/dist/dashboard/visual-slot.d.ts +8 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +7 -0
- package/dist/guard/index.d.ts +15 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +14 -0
- package/dist/guard/palette.d.ts +51 -0
- package/dist/guard/palette.d.ts.map +1 -0
- package/dist/guard/palette.js +190 -0
- package/dist/guard/series-file.d.ts +15 -0
- package/dist/guard/series-file.d.ts.map +1 -0
- package/dist/guard/series-file.js +29 -0
- package/dist/guard/types.d.ts +3 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +34 -2
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +33 -0
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +11 -5
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/dist/tokens/palette.d.ts +4 -0
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +4 -0
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +43 -23
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +33 -3
- package/src/charts/Bars.tsx +6 -0
- package/src/charts/CartesianChart.tsx +16 -3
- package/src/charts/ChartCard.tsx +43 -7
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +50 -13
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +31 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +210 -85
- package/src/charts/labels.ts +48 -14
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +104 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +10 -11
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +12 -1
- package/src/charts/types.ts +14 -5
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +102 -4
- package/src/cli/shot/capture.ts +266 -34
- package/src/cli/shot/detect.ts +550 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/playwright.ts +2 -2
- package/src/cli/shot/types.ts +8 -1
- package/src/cli/sync.ts +4 -2
- package/src/common/retry-button.module.css +58 -0
- package/src/common/retry-button.module.css.d.ts +8 -0
- package/src/common/retry-button.tsx +29 -0
- package/src/controls/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +53 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +88 -76
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +265 -28
- package/src/dashboard/meter-parts.tsx +424 -163
- package/src/dashboard/meter.module.css +79 -65
- package/src/dashboard/meter.module.css.d.ts +7 -7
- package/src/dashboard/meter.tsx +77 -17
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/query-state.tsx +4 -7
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +17 -0
- package/src/dashboard/stat-card.tsx +14 -5
- package/src/dashboard/stat-strip.module.css +147 -17
- package/src/dashboard/stat-strip.module.css.d.ts +8 -0
- package/src/dashboard/stat-strip.tsx +182 -56
- package/src/dashboard/visual-slot.ts +17 -0
- package/src/guard/index.ts +16 -4
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +34 -2
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +220 -60
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +33 -0
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +18 -5
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/oklab.ts +97 -0
- package/src/tokens/palette.ts +4 -0
- package/src/tokens/status-text.ts +2 -0
|
@@ -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;
|
|
@@ -32,6 +28,26 @@
|
|
|
32
28
|
position: relative;
|
|
33
29
|
}
|
|
34
30
|
|
|
31
|
+
/* A `stops` track is one gradient through the consumer's colours; the reading is a marker on it. */
|
|
32
|
+
.track[data-meter-stops] {
|
|
33
|
+
background: linear-gradient(var(--basalt-stop-dir, to right), var(--basalt-stops));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.trackBox:dir(rtl) {
|
|
37
|
+
--basalt-stop-dir: to left;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* `track={false}`: no drawn track, still in the accessibility tree (the role and value stay). */
|
|
41
|
+
.trackHidden {
|
|
42
|
+
position: absolute;
|
|
43
|
+
width: 1px;
|
|
44
|
+
height: 1px;
|
|
45
|
+
margin: -1px;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
clip-path: inset(50%);
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
.fill {
|
|
36
52
|
flex: none;
|
|
37
53
|
height: 100%;
|
|
@@ -57,56 +73,46 @@
|
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
/*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
76
|
+
* The one label row under (or, for a plain tick Meter, above) the track: zone names centred on their
|
|
77
|
+
* spans, labelled ticks hugging their marks, all absolutely placed on one baseline. A label that does
|
|
78
|
+
* not fit is hidden but stays laid out, so a resize can measure it again.
|
|
63
79
|
*/
|
|
64
|
-
.
|
|
80
|
+
.labelRow {
|
|
81
|
+
--basalt-reading-dir: 1;
|
|
65
82
|
position: relative;
|
|
66
|
-
/*
|
|
83
|
+
/* A hidden name keeps its box (so it can be measured again) and may sit past the row's end. */
|
|
84
|
+
overflow-x: clip;
|
|
67
85
|
height: 1.25em;
|
|
86
|
+
/* Read by the layout: the least two captions keep apart (one gap step). */
|
|
87
|
+
column-gap: var(--vx-space-control-gap, 0.375rem);
|
|
68
88
|
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
69
89
|
font-variant-numeric: lining-nums;
|
|
70
90
|
font-size: var(--basalt-meter-caption);
|
|
71
91
|
color: var(--vx-muted);
|
|
72
92
|
}
|
|
73
93
|
|
|
74
|
-
|
|
75
|
-
|
|
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;
|
|
94
|
+
.labelRow:dir(rtl) {
|
|
95
|
+
--basalt-reading-dir: -1;
|
|
84
96
|
}
|
|
85
97
|
|
|
86
|
-
.
|
|
98
|
+
.rowLabel {
|
|
87
99
|
position: absolute;
|
|
88
100
|
top: 0;
|
|
89
101
|
white-space: nowrap;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
color: var(--vx-ink);
|
|
104
|
+
.rowLabel[data-hidden] {
|
|
105
|
+
visibility: hidden;
|
|
95
106
|
}
|
|
96
107
|
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
|
|
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);
|
|
108
|
+
/* A zone name is centred on its span: the physical `translate` flips sign in RTL. */
|
|
109
|
+
.zoneLabel {
|
|
110
|
+
translate: calc(-50% * var(--basalt-reading-dir)) 0;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
.
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
.zoneLabelHolding {
|
|
114
|
+
font-weight: 500;
|
|
115
|
+
color: var(--vx-ink);
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
/* The reading under the band, centred on the marker. Clipped so it never widens the row before the first measure. */
|
|
@@ -180,6 +186,20 @@
|
|
|
180
186
|
color: var(--vx-muted);
|
|
181
187
|
}
|
|
182
188
|
|
|
189
|
+
/* Captions at their marks: each is placed (inline `inset-inline-start`) by the measured layout. */
|
|
190
|
+
.captionsAnchored {
|
|
191
|
+
position: relative;
|
|
192
|
+
display: block;
|
|
193
|
+
height: 1lh;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.captionsAnchored > * {
|
|
197
|
+
position: absolute;
|
|
198
|
+
top: 0;
|
|
199
|
+
margin: 0;
|
|
200
|
+
white-space: nowrap;
|
|
201
|
+
}
|
|
202
|
+
|
|
183
203
|
/* Captions never truncate: the row wraps, and a caption wider than the row wraps inside itself. */
|
|
184
204
|
.caption {
|
|
185
205
|
min-width: 0;
|
|
@@ -223,6 +243,20 @@
|
|
|
223
243
|
overflow-wrap: anywhere;
|
|
224
244
|
}
|
|
225
245
|
|
|
246
|
+
/* Every part's caption fits under its own segment: the list is positioned, not wrapped. */
|
|
247
|
+
.partCaptionsUnder {
|
|
248
|
+
position: relative;
|
|
249
|
+
display: block;
|
|
250
|
+
height: 1lh;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/* Under its segment a caption is one line by construction: it was measured to fit as one. */
|
|
254
|
+
.partCaptionsUnder > .partCaption {
|
|
255
|
+
position: absolute;
|
|
256
|
+
top: 0;
|
|
257
|
+
white-space: nowrap;
|
|
258
|
+
}
|
|
259
|
+
|
|
226
260
|
/* A shape cue beside the name, so the part never reads by colour alone. */
|
|
227
261
|
.swatch {
|
|
228
262
|
flex: none;
|
|
@@ -281,6 +315,17 @@
|
|
|
281
315
|
stroke: var(--vx-line);
|
|
282
316
|
}
|
|
283
317
|
|
|
318
|
+
/* A ring tick: an ink mark with a track-coloured halo, so it reads over the arc and the track. */
|
|
319
|
+
.ringTick {
|
|
320
|
+
stroke: var(--vx-ink);
|
|
321
|
+
stroke-width: 1.5;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.ringTickHalo {
|
|
325
|
+
stroke: var(--vx-surface-subtle);
|
|
326
|
+
stroke-width: 3;
|
|
327
|
+
}
|
|
328
|
+
|
|
284
329
|
.ringValue {
|
|
285
330
|
position: relative;
|
|
286
331
|
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
@@ -295,37 +340,6 @@
|
|
|
295
340
|
height: 5rem;
|
|
296
341
|
}
|
|
297
342
|
|
|
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
343
|
/* ── size="row" ──────────────────────────────────────────────────────────────────────────────── */
|
|
330
344
|
|
|
331
345
|
.row {
|
|
@@ -5,17 +5,16 @@
|
|
|
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
|
|
10
|
+
readonly trackHidden: string
|
|
11
11
|
readonly fill: string
|
|
12
12
|
readonly forecastFill: string
|
|
13
13
|
readonly zone: string
|
|
14
|
-
readonly
|
|
14
|
+
readonly labelRow: string
|
|
15
|
+
readonly rowLabel: string
|
|
15
16
|
readonly zoneLabel: string
|
|
16
17
|
readonly zoneLabelHolding: string
|
|
17
|
-
readonly zoneList: string
|
|
18
|
-
readonly zoneListItem: string
|
|
19
18
|
readonly zoneReadingRow: string
|
|
20
19
|
readonly zoneReading: string
|
|
21
20
|
readonly marker: string
|
|
@@ -24,8 +23,10 @@ declare const classes: {
|
|
|
24
23
|
readonly captions: string
|
|
25
24
|
readonly caption: string
|
|
26
25
|
readonly captionEnd: string
|
|
26
|
+
readonly captionsAnchored: string
|
|
27
27
|
readonly partCaptions: string
|
|
28
28
|
readonly partCaption: string
|
|
29
|
+
readonly partCaptionsUnder: string
|
|
29
30
|
readonly swatch: string
|
|
30
31
|
readonly empty: string
|
|
31
32
|
readonly skeletonTrack: string
|
|
@@ -34,11 +35,10 @@ declare const classes: {
|
|
|
34
35
|
readonly ring: string
|
|
35
36
|
readonly ringTrack: string
|
|
36
37
|
readonly ringArc: string
|
|
38
|
+
readonly ringTick: string
|
|
39
|
+
readonly ringTickHalo: string
|
|
37
40
|
readonly ringValue: string
|
|
38
41
|
readonly skeletonRing: string
|
|
39
|
-
readonly tickLabels: string
|
|
40
|
-
readonly tickBand: string
|
|
41
|
-
readonly tickLabel: string
|
|
42
42
|
readonly row: string
|
|
43
43
|
}
|
|
44
44
|
export default classes
|
package/src/dashboard/meter.tsx
CHANGED
|
@@ -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:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
*
|
|
@@ -50,12 +51,15 @@
|
|
|
50
51
|
* />
|
|
51
52
|
* <Meter shape="ring" label="Cache hit rate" value={87} max={100} format={(v) => `${v}%`} />
|
|
52
53
|
*/
|
|
54
|
+
import { useContext } from 'react'
|
|
53
55
|
import type { ReactNode } from 'react'
|
|
54
56
|
import type { BasaltProps } from '../common/props'
|
|
57
|
+
import { VX } from '../tokens'
|
|
55
58
|
import { isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
|
|
56
59
|
import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
|
|
57
60
|
import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from './meter-parts'
|
|
58
61
|
import { asText } from './scale'
|
|
62
|
+
import { VisualSlotContext } from './visual-slot'
|
|
59
63
|
|
|
60
64
|
type Common = BasaltProps & {
|
|
61
65
|
/** Accessible name (`aria-label`). Required: a meter without one is announced as a bare number. */
|
|
@@ -78,26 +82,40 @@ type BarCommon = Common & {
|
|
|
78
82
|
target?: number
|
|
79
83
|
/**
|
|
80
84
|
* More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
|
|
81
|
-
* above the track,
|
|
85
|
+
* above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends). A
|
|
86
|
+
* caption that would collide with another hides. A tick outside `[min, max]` is dropped, not
|
|
82
87
|
* clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
|
|
83
88
|
* and `target`.
|
|
84
89
|
*/
|
|
85
90
|
ticks?: readonly MeterTick[]
|
|
86
91
|
/**
|
|
87
|
-
* `'muted'
|
|
88
|
-
*
|
|
92
|
+
* `'muted'` (default for a plain `value` bar; `segments` and `zones` keep their fills): a
|
|
93
|
+
* non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds 3:1 against
|
|
94
|
+
* the track in both schemes — the ink fill is near-white in dark. `'ink'` restores the full-ink
|
|
95
|
+
* `--vx-line` fill. A `color` wins over both.
|
|
89
96
|
*/
|
|
90
|
-
tone?: 'muted'
|
|
97
|
+
tone?: 'muted' | 'ink'
|
|
91
98
|
/**
|
|
92
99
|
* `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
|
|
93
|
-
*
|
|
94
|
-
*
|
|
100
|
+
* zone and tick captions). Categorical `segments` keep their per-part captions (swatch, name, value)
|
|
101
|
+
* so the parts stay named. The label stays as `aria-label`; the described-by text keeps the rest.
|
|
102
|
+
* Put the value beside it in your own layout.
|
|
95
103
|
*/
|
|
96
104
|
size?: 'row'
|
|
97
|
-
/** Start caption (default: the formatted reading). `null` drops it. */
|
|
105
|
+
/** Start caption (default: the formatted reading). `null` drops it; zone labels stay. */
|
|
98
106
|
startCaption?: ReactNode
|
|
99
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* End caption (default: `Target <target>`, drawn at the target's tick rather than the track end
|
|
109
|
+
* when it fits). `null` drops it; zone labels stay.
|
|
110
|
+
*/
|
|
100
111
|
endCaption?: ReactNode
|
|
112
|
+
/**
|
|
113
|
+
* The reading printed at the marker of a zoned bar. Default `true`, and `false` inside a basalt host
|
|
114
|
+
* (`StatCard`, a strip cell's `visual`) that already states the value. Pass `false` when YOUR
|
|
115
|
+
* headline states it: the marker stays and keeps its `aria-valuenow` / `aria-valuetext`. Pass `true`
|
|
116
|
+
* to print it inside a host. A `stops` track prints it only when `true`.
|
|
117
|
+
*/
|
|
118
|
+
reading?: boolean
|
|
101
119
|
}
|
|
102
120
|
|
|
103
121
|
/**
|
|
@@ -105,7 +123,9 @@ type BarCommon = Common & {
|
|
|
105
123
|
* - Bar `value` (+ `target`, `color`): one reading on a neutral track.
|
|
106
124
|
* - Bar `segments`: ordered parts that sum to the reading (committed/forecast, part of a whole).
|
|
107
125
|
* - Bar `value` + `zones`: the reading is a marker against contiguous bands.
|
|
108
|
-
* -
|
|
126
|
+
* - Bar `value` + `stops`: the reading is a marker on one gradient track.
|
|
127
|
+
* - Ring (`shape: 'ring'`) `value` (+ `color`, `target`, `ticks`): one headline ratio; no captions,
|
|
128
|
+
* segments or zones.
|
|
109
129
|
*/
|
|
110
130
|
export type MeterProps =
|
|
111
131
|
| (BarCommon & {
|
|
@@ -113,6 +133,17 @@ export type MeterProps =
|
|
|
113
133
|
value?: number | null | undefined
|
|
114
134
|
/** A status colour, for a verdict only. Omit for the neutral fill. */
|
|
115
135
|
color?: string
|
|
136
|
+
/**
|
|
137
|
+
* `false` draws no track for a value with nothing to compare against (no `target`, no `ticks`):
|
|
138
|
+
* the track stays in the accessibility tree and the captions remain. A `target` or `ticks` keep it.
|
|
139
|
+
*/
|
|
140
|
+
track?: boolean
|
|
141
|
+
/**
|
|
142
|
+
* Draws the track as ONE gradient through these colours (the consumer's: tokens or its own
|
|
143
|
+
* values, `at` in the reading's units) and the reading as a marker on it. Not a zone: no names,
|
|
144
|
+
* and no labels unless `ticks` are given. Use it for a scale whose hue IS the quantity.
|
|
145
|
+
*/
|
|
146
|
+
stops?: readonly { at: number; color: string }[]
|
|
116
147
|
segments?: never
|
|
117
148
|
zones?: never
|
|
118
149
|
})
|
|
@@ -124,6 +155,8 @@ export type MeterProps =
|
|
|
124
155
|
value?: never
|
|
125
156
|
color?: never
|
|
126
157
|
zones?: never
|
|
158
|
+
stops?: never
|
|
159
|
+
track?: never
|
|
127
160
|
})
|
|
128
161
|
| (BarCommon & {
|
|
129
162
|
value?: number | null | undefined
|
|
@@ -134,20 +167,27 @@ export type MeterProps =
|
|
|
134
167
|
zones: readonly MeterZone[]
|
|
135
168
|
segments?: never
|
|
136
169
|
color?: never
|
|
170
|
+
stops?: never
|
|
171
|
+
track?: never
|
|
137
172
|
})
|
|
138
173
|
| (Common & {
|
|
139
174
|
shape: 'ring'
|
|
140
175
|
value?: number | null | undefined
|
|
141
176
|
/** A status colour, for a verdict only. */
|
|
142
177
|
color?: string
|
|
178
|
+
/** A short radial mark at this value (a limit to compare the arc against); the value stays centred. */
|
|
179
|
+
target?: number
|
|
180
|
+
/** More radial marks, each at its `at`; a `label` is for the accessible text only. */
|
|
181
|
+
ticks?: readonly MeterTick[]
|
|
143
182
|
segments?: never
|
|
144
183
|
zones?: never
|
|
145
|
-
target?: never
|
|
146
|
-
ticks?: never
|
|
147
184
|
tone?: never
|
|
148
185
|
size?: never
|
|
149
186
|
startCaption?: never
|
|
150
187
|
endCaption?: never
|
|
188
|
+
reading?: never
|
|
189
|
+
stops?: never
|
|
190
|
+
track?: never
|
|
151
191
|
})
|
|
152
192
|
|
|
153
193
|
let warnedTrack = false
|
|
@@ -160,12 +200,20 @@ function warnInvalidTrack(min: number, max: number) {
|
|
|
160
200
|
)
|
|
161
201
|
}
|
|
162
202
|
|
|
203
|
+
/** Muted is the default for a plain `value` bar only; `segments`/`zones` keep their fills unless asked. */
|
|
204
|
+
function barTone(tone: 'muted' | 'ink' | undefined, plain: boolean): 'muted' | undefined {
|
|
205
|
+
if (tone === 'ink') return undefined
|
|
206
|
+
return tone === 'muted' || plain ? 'muted' : undefined
|
|
207
|
+
}
|
|
208
|
+
|
|
163
209
|
export function Meter(props: MeterProps) {
|
|
164
210
|
const { label, min = 0, max = 100, format = asText, className, style } = props
|
|
165
211
|
const row = props.size === 'row'
|
|
166
212
|
const shell = { className, style, row }
|
|
167
213
|
const ring = props.shape === 'ring'
|
|
168
214
|
warnInvalidTrack(min, max)
|
|
215
|
+
const hostTone = useContext(VisualSlotContext)?.tone
|
|
216
|
+
const hostColor = hostTone === undefined ? undefined : VX.status[hostTone]
|
|
169
217
|
|
|
170
218
|
if (props.loading === true) return <MeterLoading label={label} ring={ring} shell={shell} />
|
|
171
219
|
|
|
@@ -178,17 +226,29 @@ export function Meter(props: MeterProps) {
|
|
|
178
226
|
}
|
|
179
227
|
|
|
180
228
|
if (props.shape === 'ring') {
|
|
181
|
-
return
|
|
229
|
+
return (
|
|
230
|
+
<MeterRing
|
|
231
|
+
{...{ label, reading, min, max, format, shell }}
|
|
232
|
+
color={props.color ?? hostColor}
|
|
233
|
+
target={isReading(props.target) ? props.target : undefined}
|
|
234
|
+
ticks={props.ticks}
|
|
235
|
+
/>
|
|
236
|
+
)
|
|
182
237
|
}
|
|
238
|
+
const plain =
|
|
239
|
+
props.segments === undefined && props.zones === undefined && props.stops === undefined
|
|
183
240
|
return (
|
|
184
241
|
<MeterBar
|
|
185
242
|
{...{ label, reading, min, max, format, shell }}
|
|
186
|
-
color={props.color}
|
|
243
|
+
color={props.color ?? (props.tone === undefined && plain ? hostColor : undefined)}
|
|
187
244
|
segments={segments}
|
|
188
245
|
zones={props.zones}
|
|
246
|
+
stops={props.stops}
|
|
247
|
+
track={props.track}
|
|
248
|
+
markerReading={props.reading}
|
|
189
249
|
target={isReading(props.target) ? props.target : undefined}
|
|
190
250
|
ticks={props.ticks}
|
|
191
|
-
tone={props.tone}
|
|
251
|
+
tone={barTone(props.tone, plain)}
|
|
192
252
|
forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
|
|
193
253
|
startCaption={props.startCaption}
|
|
194
254
|
endCaption={props.endCaption}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* PageSummary (SPEC § 6.9). A page's opening: headline, then one facts line. No surface of its own —
|
|
3
|
+
* it sits on the page background above the first Section.
|
|
4
|
+
*/
|
|
5
|
+
.root {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: var(--vx-space-stack-xs);
|
|
9
|
+
min-width: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.top {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: baseline;
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
gap: var(--vx-space-stack-md);
|
|
17
|
+
min-width: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* `h1` step, head face, tight tracking (SPEC row "Page headline"). Sans with lining figures: the
|
|
21
|
+
* sentence carries the live number, and D33 keeps figures proportional. */
|
|
22
|
+
.sentence {
|
|
23
|
+
margin: 0;
|
|
24
|
+
min-width: 0;
|
|
25
|
+
font-family: var(--basalt-font-head);
|
|
26
|
+
font-size: var(--vx-text-h1);
|
|
27
|
+
font-weight: 550;
|
|
28
|
+
font-stretch: 88%;
|
|
29
|
+
letter-spacing: -0.02em;
|
|
30
|
+
line-height: 1.2;
|
|
31
|
+
color: var(--vx-ink);
|
|
32
|
+
text-wrap: balance;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.aside {
|
|
36
|
+
flex: none;
|
|
37
|
+
font-size: var(--vx-text-xs);
|
|
38
|
+
color: var(--vx-muted);
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* The facts line: sans `xs`, muted, `·`-separated. A wrapping flex list, `--facts-gap` between facts.
|
|
44
|
+
* Each fact draws its own dot one gap to its inline-start, centred in it, and the list clips inline overflow: the fact
|
|
45
|
+
* that opens a line starts at the list's left edge, so its dot lands outside the clip and a wrapped
|
|
46
|
+
* line never leads with `·` (argo UPSTREAM § Wave 26). Clip, not hidden — the block axis stays free.
|
|
47
|
+
*/
|
|
48
|
+
.facts {
|
|
49
|
+
--facts-gap: var(--vx-space-stack-md);
|
|
50
|
+
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-wrap: wrap;
|
|
53
|
+
column-gap: var(--facts-gap);
|
|
54
|
+
row-gap: 0;
|
|
55
|
+
margin: 0;
|
|
56
|
+
overflow-x: clip;
|
|
57
|
+
font-size: var(--vx-text-xs);
|
|
58
|
+
line-height: 1.4;
|
|
59
|
+
color: var(--vx-muted);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.fact {
|
|
63
|
+
position: relative;
|
|
64
|
+
min-width: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.fact::before {
|
|
68
|
+
content: '·';
|
|
69
|
+
position: absolute;
|
|
70
|
+
inset-inline-start: calc(-1 * var(--facts-gap));
|
|
71
|
+
width: var(--facts-gap);
|
|
72
|
+
text-align: center;
|
|
73
|
+
color: var(--vx-faint);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* The list clips inline overflow, so a focus ring on a link inside a fact is drawn inward: an
|
|
77
|
+
* outset ring would be cut at the list's edges. */
|
|
78
|
+
.fact :where(a, button, [tabindex]):focus-visible {
|
|
79
|
+
outline-offset: -2px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Skeleton: the headline bar is one h1 line, the facts bar one xs line. */
|
|
83
|
+
.sentenceSkeleton {
|
|
84
|
+
height: calc(var(--vx-text-h1) * 1.2);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.factsSkeleton {
|
|
88
|
+
height: calc(var(--vx-text-xs) * 1.4);
|
|
89
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 root: string
|
|
7
|
+
readonly top: string
|
|
8
|
+
readonly sentence: string
|
|
9
|
+
readonly aside: string
|
|
10
|
+
readonly facts: string
|
|
11
|
+
readonly fact: string
|
|
12
|
+
readonly sentenceSkeleton: string
|
|
13
|
+
readonly factsSkeleton: string
|
|
14
|
+
}
|
|
15
|
+
export default classes
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PageSummary — a page's opening (docs/waves/design-parity/SPEC.md § 6.9): one headline sentence
|
|
3
|
+
* that carries at least one live number, an optional facts line under it, and an optional `aside`
|
|
4
|
+
* right of the headline. It renders an `h2` at the `h1` type step (head face, −0.02em): the page's own
|
|
5
|
+
* h1 is the shell breadcrumb's / `PageTitle`'s, and a second one would split the outline. The facts
|
|
6
|
+
* are the proportional sans at `xs`, muted, `·`-separated — a time fact may take mono itself, the line does
|
|
7
|
+
* not (D33).
|
|
8
|
+
*
|
|
9
|
+
* The sentence MUST state a live fact — "12 open, 3 need you", never "Overview of your tickets".
|
|
10
|
+
* A sentence without a number is the page restating its own name, which the breadcrumb already does.
|
|
11
|
+
* That is the reviewer's rule too: a page summary without a number is a defect.
|
|
12
|
+
*
|
|
13
|
+
* `null` / `false` / `undefined` / `''` facts drop, so conditional facts pass inline. A facts line
|
|
14
|
+
* that wraps never opens a line with `·`: each fact owns its separator as a pseudo-element in the gap
|
|
15
|
+
* before it (logical, so RTL mirrors), and the list clips inline overflow, so the dot of the fact that starts a line falls
|
|
16
|
+
* outside the clip.
|
|
17
|
+
*
|
|
18
|
+
* `loading` renders a skeleton of the same shape — the headline bar, plus a facts bar when `facts`
|
|
19
|
+
* is passed — so the page does not jump when the numbers arrive.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { PageSummary } from 'basalt-ui'
|
|
23
|
+
*
|
|
24
|
+
* <PageSummary
|
|
25
|
+
* sentence={`${open} open, ${needYou} need you`}
|
|
26
|
+
* facts={[oldest && `oldest ${oldest}`, `${runs} runs today`]}
|
|
27
|
+
* aside="Today"
|
|
28
|
+
* />
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* <PageSummary loading facts={[]} />
|
|
32
|
+
*/
|
|
33
|
+
import { Skeleton } from '@mantine/core'
|
|
34
|
+
import type { ReactNode } from 'react'
|
|
35
|
+
import { cx } from '../common/props'
|
|
36
|
+
import type { BasaltProps } from '../common/props'
|
|
37
|
+
import classes from './page-summary.module.css'
|
|
38
|
+
|
|
39
|
+
type Fact = ReactNode | null | false | undefined
|
|
40
|
+
|
|
41
|
+
type PageSummaryContent = {
|
|
42
|
+
/** The headline sentence. It must state a live number — never describe the page. */
|
|
43
|
+
sentence: ReactNode
|
|
44
|
+
/** Short facts under the headline, e.g. `['3 need you', oldest && `oldest ${oldest}`]`. */
|
|
45
|
+
facts?: readonly Fact[]
|
|
46
|
+
/** Right of the headline: a date or a freshness word. */
|
|
47
|
+
aside?: ReactNode
|
|
48
|
+
loading?: false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** While the sentence's data loads: a skeleton of the same shape, no content props needed. */
|
|
52
|
+
type PageSummaryLoading = Partial<Omit<PageSummaryContent, 'loading'>> & { loading: true }
|
|
53
|
+
|
|
54
|
+
export type PageSummaryProps = BasaltProps & (PageSummaryContent | PageSummaryLoading)
|
|
55
|
+
|
|
56
|
+
const NO_FACTS: readonly Fact[] = []
|
|
57
|
+
|
|
58
|
+
const isShown = (fact: Fact): boolean =>
|
|
59
|
+
fact !== null && fact !== false && fact !== undefined && fact !== ''
|
|
60
|
+
|
|
61
|
+
export function PageSummary(props: PageSummaryProps) {
|
|
62
|
+
const { className, style } = props
|
|
63
|
+
const common = { className: cx(classes.root, className), 'data-page-summary': '', style }
|
|
64
|
+
|
|
65
|
+
if (props.loading === true) {
|
|
66
|
+
return (
|
|
67
|
+
<div {...common} aria-busy="true">
|
|
68
|
+
<Skeleton className={classes.sentenceSkeleton} width="55%" radius="sm" />
|
|
69
|
+
{props.facts !== undefined && (
|
|
70
|
+
<Skeleton className={classes.factsSkeleton} width="35%" radius="sm" />
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const { sentence, facts = NO_FACTS, aside } = props
|
|
77
|
+
const shown = facts.filter(isShown)
|
|
78
|
+
return (
|
|
79
|
+
<div {...common}>
|
|
80
|
+
<div className={classes.top}>
|
|
81
|
+
<h2 className={classes.sentence}>{sentence}</h2>
|
|
82
|
+
{aside !== undefined && <span className={classes.aside}>{aside}</span>}
|
|
83
|
+
</div>
|
|
84
|
+
{shown.length > 0 && (
|
|
85
|
+
<p className={classes.facts} data-page-summary-facts>
|
|
86
|
+
{shown.map((fact, i) => (
|
|
87
|
+
<span key={i} className={classes.fact} data-page-summary-fact>
|
|
88
|
+
{fact}
|
|
89
|
+
</span>
|
|
90
|
+
))}
|
|
91
|
+
</p>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
}
|