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
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Meter — one bounded quantity on a track: progress to a target, a committed/forecast split, a
|
|
3
|
-
* part-of-a-whole strip (`segments`), or a single headline ratio as a `ring`. Choose it for "how far
|
|
4
|
-
* along is this against a limit"; choose `BarList` for a ranking and a chart for a trend. An HTML/CSS
|
|
5
|
-
* primitive, not a chart kind (no scale, axis or tooltip).
|
|
6
|
-
*
|
|
7
|
-
* Colour law: the fill is neutral (`VX.line`). `color` is for a VERDICT only (over budget, below
|
|
8
|
-
* target) and is a status colour the consumer passes; categorical `segments` take the consumer's
|
|
9
|
-
* series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
|
|
10
|
-
* tick marks the boundary and a caption names the forecast. A value past `max` clamps the fill at the
|
|
11
|
-
* track end; the caption still states the real value.
|
|
12
|
-
*
|
|
13
|
-
* `zones` (bar only) draws the track as contiguous bands (neutral at stepped strengths unless a zone
|
|
14
|
-
* passes a status colour) and the reading becomes a MARKER on the track, not a fill. Each zone is
|
|
15
|
-
* named under the band at its start, the one holding the value (`from` inclusive) in ink and a
|
|
16
|
-
* heavier weight; names that would collide wrap as a list instead. The fit is measured in the
|
|
17
|
-
* browser, so server markup shows the band and the list may appear after mount. Use it for a
|
|
18
|
-
* reading judged against ranges.
|
|
19
|
-
*
|
|
20
|
-
* Every state (bar, ring, empty, loading) carries `data-basalt-meter` on its root. That attribute is
|
|
21
|
-
* the contract with `StatCard`: a Meter passed as its `sparkline` visual makes the slot size to content
|
|
22
|
-
* and keep the card's inline inset (both placements) instead of the sparkline's fixed height and bleed.
|
|
23
|
-
*
|
|
24
|
-
* Categorical `segments` (no `forecast` part) are captioned one per part — swatch, name, value — under
|
|
25
|
-
* the track and the default start caption is dropped (an explicit `startCaption` still shows);
|
|
26
|
-
* committed/forecast keeps the reading plus the forecast caption.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* import { Meter } from 'basalt-ui'
|
|
30
|
-
*
|
|
31
|
-
* // Spend against a budget: past the target the end caption states the overage.
|
|
32
|
-
* <Meter label="Monthly spend" value={512} max={600} target={450} color="var(--vx-status-bad)" format={usd} />
|
|
33
|
-
* // Training load as a zone band with a marker: the zones are named under the band, "Optimal" in ink.
|
|
34
|
-
* <Meter
|
|
35
|
-
* label="Training load"
|
|
36
|
-
* max={1000}
|
|
37
|
-
* value={612}
|
|
38
|
-
* zones={[
|
|
39
|
-
* { from: 0, to: 300, label: 'Low' },
|
|
40
|
-
* { from: 300, to: 750, label: 'Optimal' },
|
|
41
|
-
* { from: 750, to: 1000, label: 'High' },
|
|
42
|
-
* ]}
|
|
43
|
-
* />
|
|
44
|
-
* // A readiness score on its 0–100 scale (its contributors: <BarList max={100} … secondary="Good" />).
|
|
45
|
-
* <Meter label="Recovery" value={72} max={100} />
|
|
46
|
-
* <Meter
|
|
47
|
-
* label="Course progress"
|
|
48
|
-
* max={120}
|
|
49
|
-
* segments={[{ value: 70, label: 'Done' }, { value: 25, label: 'Planned', forecast: true }]}
|
|
50
|
-
* />
|
|
51
|
-
* <Meter shape="ring" label="Cache hit rate" value={87} max={100} format={(v) => `${v}%`} />
|
|
52
|
-
*/
|
|
53
1
|
import type { ReactNode } from 'react';
|
|
54
2
|
import type { BasaltProps } from '../common/props.js';
|
|
55
3
|
import type { MeterSegment, MeterTick, MeterZone } from './meter-model.js';
|
|
@@ -73,39 +21,69 @@ type BarCommon = Common & {
|
|
|
73
21
|
target?: number;
|
|
74
22
|
/**
|
|
75
23
|
* More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
|
|
76
|
-
* above the track,
|
|
24
|
+
* above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends). A
|
|
25
|
+
* caption that would collide with another hides. A tick outside `[min, max]` is dropped, not
|
|
77
26
|
* clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
|
|
78
27
|
* and `target`.
|
|
79
28
|
*/
|
|
80
29
|
ticks?: readonly MeterTick[];
|
|
81
30
|
/**
|
|
82
|
-
* `'muted'
|
|
83
|
-
*
|
|
31
|
+
* `'muted'` (default for a plain `value` bar; `segments` and `zones` keep their fills): a
|
|
32
|
+
* non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds 3:1 against
|
|
33
|
+
* the track in both schemes — the ink fill is near-white in dark. `'ink'` restores the full-ink
|
|
34
|
+
* `--vx-line` fill. A `color` wins over both.
|
|
84
35
|
*/
|
|
85
|
-
tone?: 'muted';
|
|
36
|
+
tone?: 'muted' | 'ink';
|
|
86
37
|
/**
|
|
87
38
|
* `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
|
|
88
|
-
*
|
|
89
|
-
*
|
|
39
|
+
* zone and tick captions). Categorical `segments` keep their per-part captions (swatch, name, value)
|
|
40
|
+
* so the parts stay named. The label stays as `aria-label`; the described-by text keeps the rest.
|
|
41
|
+
* Put the value beside it in your own layout.
|
|
90
42
|
*/
|
|
91
43
|
size?: 'row';
|
|
92
|
-
/** Start caption (default: the formatted reading). `null` drops it. */
|
|
44
|
+
/** Start caption (default: the formatted reading). `null` drops it; zone labels stay. */
|
|
93
45
|
startCaption?: ReactNode;
|
|
94
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* End caption (default: `Target <target>`, drawn at the target's tick rather than the track end
|
|
48
|
+
* when it fits). `null` drops it; zone labels stay.
|
|
49
|
+
*/
|
|
95
50
|
endCaption?: ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* The reading printed at the marker of a zoned bar. Default `true`, and `false` inside a basalt host
|
|
53
|
+
* (`StatCard`, a strip cell's `visual`) that already states the value. Pass `false` when YOUR
|
|
54
|
+
* headline states it: the marker stays and keeps its `aria-valuenow` / `aria-valuetext`. Pass `true`
|
|
55
|
+
* to print it inside a host. A `stops` track prints it only when `true`.
|
|
56
|
+
*/
|
|
57
|
+
reading?: boolean;
|
|
96
58
|
};
|
|
97
59
|
/**
|
|
98
60
|
* One of four forms; mixing them is a compile error.
|
|
99
61
|
* - Bar `value` (+ `target`, `color`): one reading on a neutral track.
|
|
100
62
|
* - Bar `segments`: ordered parts that sum to the reading (committed/forecast, part of a whole).
|
|
101
63
|
* - Bar `value` + `zones`: the reading is a marker against contiguous bands.
|
|
102
|
-
* -
|
|
64
|
+
* - Bar `value` + `stops`: the reading is a marker on one gradient track.
|
|
65
|
+
* - Ring (`shape: 'ring'`) `value` (+ `color`, `target`, `ticks`): one headline ratio; no captions,
|
|
66
|
+
* segments or zones.
|
|
103
67
|
*/
|
|
104
68
|
export type MeterProps = (BarCommon & {
|
|
105
69
|
/** The reading. `null`/`undefined` (or non-finite) renders the empty state. */
|
|
106
70
|
value?: number | null | undefined;
|
|
107
71
|
/** A status colour, for a verdict only. Omit for the neutral fill. */
|
|
108
72
|
color?: string;
|
|
73
|
+
/**
|
|
74
|
+
* `false` draws no track for a value with nothing to compare against (no `target`, no `ticks`):
|
|
75
|
+
* the track stays in the accessibility tree and the captions remain. A `target` or `ticks` keep it.
|
|
76
|
+
*/
|
|
77
|
+
track?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Draws the track as ONE gradient through these colours (the consumer's: tokens or its own
|
|
80
|
+
* values, `at` in the reading's units) and the reading as a marker on it. Not a zone: no names,
|
|
81
|
+
* and no labels unless `ticks` are given. Use it for a scale whose hue IS the quantity.
|
|
82
|
+
*/
|
|
83
|
+
stops?: readonly {
|
|
84
|
+
at: number;
|
|
85
|
+
color: string;
|
|
86
|
+
}[];
|
|
109
87
|
segments?: never;
|
|
110
88
|
zones?: never;
|
|
111
89
|
}) | (BarCommon & {
|
|
@@ -116,6 +94,8 @@ export type MeterProps = (BarCommon & {
|
|
|
116
94
|
value?: never;
|
|
117
95
|
color?: never;
|
|
118
96
|
zones?: never;
|
|
97
|
+
stops?: never;
|
|
98
|
+
track?: never;
|
|
119
99
|
}) | (BarCommon & {
|
|
120
100
|
value?: number | null | undefined;
|
|
121
101
|
/**
|
|
@@ -125,19 +105,26 @@ export type MeterProps = (BarCommon & {
|
|
|
125
105
|
zones: readonly MeterZone[];
|
|
126
106
|
segments?: never;
|
|
127
107
|
color?: never;
|
|
108
|
+
stops?: never;
|
|
109
|
+
track?: never;
|
|
128
110
|
}) | (Common & {
|
|
129
111
|
shape: 'ring';
|
|
130
112
|
value?: number | null | undefined;
|
|
131
113
|
/** A status colour, for a verdict only. */
|
|
132
114
|
color?: string;
|
|
115
|
+
/** A short radial mark at this value (a limit to compare the arc against); the value stays centred. */
|
|
116
|
+
target?: number;
|
|
117
|
+
/** More radial marks, each at its `at`; a `label` is for the accessible text only. */
|
|
118
|
+
ticks?: readonly MeterTick[];
|
|
133
119
|
segments?: never;
|
|
134
120
|
zones?: never;
|
|
135
|
-
target?: never;
|
|
136
|
-
ticks?: never;
|
|
137
121
|
tone?: never;
|
|
138
122
|
size?: never;
|
|
139
123
|
startCaption?: never;
|
|
140
124
|
endCaption?: never;
|
|
125
|
+
reading?: never;
|
|
126
|
+
stops?: never;
|
|
127
|
+
track?: never;
|
|
141
128
|
});
|
|
142
129
|
export declare function Meter(props: MeterProps): import("react").JSX.Element;
|
|
143
130
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter.tsx"],"names":[],"mappings":"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"}
|
package/dist/dashboard/meter.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { VX } from "../tokens/index.js";
|
|
2
4
|
import { isReading, normalizeSegments, segmentReading, spanOf } from "./meter-model.js";
|
|
3
5
|
import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from "./meter-parts.js";
|
|
4
6
|
import { asText } from "./scale.js";
|
|
7
|
+
import { VisualSlotContext } from "./visual-slot.js";
|
|
5
8
|
let warnedTrack = false;
|
|
6
9
|
function warnInvalidTrack(min, max) {
|
|
7
10
|
if (warnedTrack || spanOf(min, max).valid || process.env.NODE_ENV === "production") return;
|
|
@@ -10,12 +13,18 @@ function warnInvalidTrack(min, max) {
|
|
|
10
13
|
`[basalt] Meter: max (${max}) must be greater than min (${min}); drawing an empty track`
|
|
11
14
|
);
|
|
12
15
|
}
|
|
16
|
+
function barTone(tone, plain) {
|
|
17
|
+
if (tone === "ink") return void 0;
|
|
18
|
+
return tone === "muted" || plain ? "muted" : void 0;
|
|
19
|
+
}
|
|
13
20
|
function Meter(props) {
|
|
14
21
|
const { label, min = 0, max = 100, format = asText, className, style } = props;
|
|
15
22
|
const row = props.size === "row";
|
|
16
23
|
const shell = { className, style, row };
|
|
17
24
|
const ring = props.shape === "ring";
|
|
18
25
|
warnInvalidTrack(min, max);
|
|
26
|
+
const hostTone = useContext(VisualSlotContext)?.tone;
|
|
27
|
+
const hostColor = hostTone === void 0 ? void 0 : VX.status[hostTone];
|
|
19
28
|
if (props.loading === true) return /* @__PURE__ */ jsx(MeterLoading, { label, ring, shell });
|
|
20
29
|
const segments = props.segments === void 0 ? void 0 : normalizeSegments(props.segments);
|
|
21
30
|
const reading = segments === void 0 ? props.value : segmentReading(segments, min);
|
|
@@ -23,18 +32,30 @@ function Meter(props) {
|
|
|
23
32
|
return /* @__PURE__ */ jsx(MeterEmpty, { label, text: props.emptyText ?? "No data", ring, shell });
|
|
24
33
|
}
|
|
25
34
|
if (props.shape === "ring") {
|
|
26
|
-
return /* @__PURE__ */ jsx(
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
MeterRing,
|
|
37
|
+
{
|
|
38
|
+
...{ label, reading, min, max, format, shell },
|
|
39
|
+
color: props.color ?? hostColor,
|
|
40
|
+
target: isReading(props.target) ? props.target : void 0,
|
|
41
|
+
ticks: props.ticks
|
|
42
|
+
}
|
|
43
|
+
);
|
|
27
44
|
}
|
|
45
|
+
const plain = props.segments === void 0 && props.zones === void 0 && props.stops === void 0;
|
|
28
46
|
return /* @__PURE__ */ jsx(
|
|
29
47
|
MeterBar,
|
|
30
48
|
{
|
|
31
49
|
...{ label, reading, min, max, format, shell },
|
|
32
|
-
color: props.color,
|
|
50
|
+
color: props.color ?? (props.tone === void 0 && plain ? hostColor : void 0),
|
|
33
51
|
segments,
|
|
34
52
|
zones: props.zones,
|
|
53
|
+
stops: props.stops,
|
|
54
|
+
track: props.track,
|
|
55
|
+
markerReading: props.reading,
|
|
35
56
|
target: isReading(props.target) ? props.target : void 0,
|
|
36
57
|
ticks: props.ticks,
|
|
37
|
-
tone: props.tone,
|
|
58
|
+
tone: barTone(props.tone, plain),
|
|
38
59
|
forecastCaption: props.segments === void 0 ? void 0 : props.forecastCaption,
|
|
39
60
|
startCaption: props.startCaption,
|
|
40
61
|
endCaption: props.endCaption
|
|
@@ -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
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BasaltProps } from '../common/props.js';
|
|
3
|
+
type Fact = ReactNode | null | false | undefined;
|
|
4
|
+
type PageSummaryContent = {
|
|
5
|
+
/** The headline sentence. It must state a live number — never describe the page. */
|
|
6
|
+
sentence: ReactNode;
|
|
7
|
+
/** Short facts under the headline, e.g. `['3 need you', oldest && `oldest ${oldest}`]`. */
|
|
8
|
+
facts?: readonly Fact[];
|
|
9
|
+
/** Right of the headline: a date or a freshness word. */
|
|
10
|
+
aside?: ReactNode;
|
|
11
|
+
loading?: false;
|
|
12
|
+
};
|
|
13
|
+
/** While the sentence's data loads: a skeleton of the same shape, no content props needed. */
|
|
14
|
+
type PageSummaryLoading = Partial<Omit<PageSummaryContent, 'loading'>> & {
|
|
15
|
+
loading: true;
|
|
16
|
+
};
|
|
17
|
+
export type PageSummaryProps = BasaltProps & (PageSummaryContent | PageSummaryLoading);
|
|
18
|
+
export declare function PageSummary(props: PageSummaryProps): import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=page-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-summary.d.ts","sourceRoot":"","sources":["../../src/dashboard/page-summary.tsx"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD,KAAK,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,CAAA;AAEhD,KAAK,kBAAkB,GAAG;IACxB,oFAAoF;IACpF,QAAQ,EAAE,SAAS,CAAA;IACnB,2FAA2F;IAC3F,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAA;IACvB,yDAAyD;IACzD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,OAAO,CAAC,EAAE,KAAK,CAAA;CAChB,CAAA;AAED,8FAA8F;AAC9F,KAAK,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAA;AAE1F,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,CAAA;AAOtF,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAkClD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Skeleton } from "@mantine/core";
|
|
3
|
+
import { cx } from "../common/props.js";
|
|
4
|
+
import classes from "./page-summary.module.css";
|
|
5
|
+
const NO_FACTS = [];
|
|
6
|
+
const isShown = (fact) => fact !== null && fact !== false && fact !== void 0 && fact !== "";
|
|
7
|
+
function PageSummary(props) {
|
|
8
|
+
const { className, style } = props;
|
|
9
|
+
const common = { className: cx(classes.root, className), "data-page-summary": "", style };
|
|
10
|
+
if (props.loading === true) {
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", { ...common, "aria-busy": "true", children: [
|
|
12
|
+
/* @__PURE__ */ jsx(Skeleton, { className: classes.sentenceSkeleton, width: "55%", radius: "sm" }),
|
|
13
|
+
props.facts !== void 0 && /* @__PURE__ */ jsx(Skeleton, { className: classes.factsSkeleton, width: "35%", radius: "sm" })
|
|
14
|
+
] });
|
|
15
|
+
}
|
|
16
|
+
const { sentence, facts = NO_FACTS, aside } = props;
|
|
17
|
+
const shown = facts.filter(isShown);
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", { ...common, children: [
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { className: classes.top, children: [
|
|
20
|
+
/* @__PURE__ */ jsx("h2", { className: classes.sentence, children: sentence }),
|
|
21
|
+
aside !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.aside, children: aside })
|
|
22
|
+
] }),
|
|
23
|
+
shown.length > 0 && /* @__PURE__ */ jsx("p", { className: classes.facts, "data-page-summary-facts": true, children: shown.map((fact, i) => /* @__PURE__ */ jsx("span", { className: classes.fact, "data-page-summary-fact": true, children: fact }, i)) })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
PageSummary
|
|
28
|
+
};
|
|
@@ -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
|