basalt-ui 2.21.0 → 2.23.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 +60 -0
- package/MIGRATING.md +452 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +73 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +6 -0
- package/dist/charts/CartesianChart.d.ts +10 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +12 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +39 -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 +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +101 -22
- 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 +38 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +18 -1
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +25 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +152 -72
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +21 -6
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +52 -17
- 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 +43 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +75 -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 +13 -17
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +2 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +5 -2
- package/dist/charts/types.d.ts +18 -8
- package/dist/charts/types.d.ts.map +1 -1
- 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/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +68 -4
- 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 +202 -36
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +17 -1
- package/dist/cli/shot/playwright.d.ts +13 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +4 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- 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 +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +83 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- 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 +84 -5
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +100 -15
- package/dist/dashboard/meter-parts.d.ts +9 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +276 -74
- package/dist/dashboard/meter.d.ts +54 -65
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +21 -4
- package/dist/dashboard/meter.module.css +76 -0
- package/dist/dashboard/meter.module.css.d.ts +6 -0
- 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.map +1 -1
- package/dist/dashboard/query-state.js +1 -1
- 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 -5
- package/dist/dashboard/stat-card.module.css +36 -0
- package/dist/dashboard/stat-group.module.css +7 -0
- package/dist/dashboard/stat-strip.d.ts +22 -6
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +104 -60
- package/dist/dashboard/stat-strip.module.css +122 -53
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +7 -1
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +3 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +0 -5
- 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 +43 -4
- 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 +37 -0
- package/dist/theme/controls.module.css.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -27
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- 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/palette.d.ts +11 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +11 -10
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +42 -22
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +83 -3
- package/src/charts/Bars.tsx +7 -0
- package/src/charts/CartesianChart.tsx +18 -3
- package/src/charts/ChartCard.tsx +54 -13
- 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 +135 -25
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +50 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +253 -87
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +81 -26
- 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 +131 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +13 -17
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +9 -4
- package/src/charts/types.ts +18 -8
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +266 -35
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +20 -4
- package/src/cli/shot/types.ts +5 -0
- package/src/cli/tokens-css.ts +18 -20
- 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 +83 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +107 -69
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +207 -24
- package/src/dashboard/meter-parts.tsx +349 -67
- package/src/dashboard/meter.module.css +76 -0
- package/src/dashboard/meter.module.css.d.ts +6 -0
- package/src/dashboard/meter.tsx +72 -18
- 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 +1 -1
- 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 +36 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-group.module.css +7 -0
- package/src/dashboard/stat-strip.module.css +122 -53
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +176 -91
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/index.ts +0 -5
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +43 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +37 -0
- package/src/theme/controls.module.css.d.ts +2 -0
- package/src/theme/index.ts +22 -32
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +11 -10
- package/src/tokens/status-text.ts +2 -0
|
@@ -112,7 +112,9 @@
|
|
|
112
112
|
.pill {
|
|
113
113
|
--vx-hit-gap: var(--vx-space-control-gap);
|
|
114
114
|
position: relative;
|
|
115
|
-
|
|
115
|
+
/* A filter pill fits its selected option; this is only the ceiling. 15rem clipped an ordinary site
|
|
116
|
+
* or project name (argo astro site select) — 24rem holds a long one and the label truncates past it. */
|
|
117
|
+
max-width: 24rem;
|
|
116
118
|
border-color: color-mix(in srgb, var(--vx-ink) 12%, transparent);
|
|
117
119
|
}
|
|
118
120
|
|
|
@@ -353,6 +355,14 @@
|
|
|
353
355
|
flex: 0 1 auto;
|
|
354
356
|
}
|
|
355
357
|
|
|
358
|
+
/* Mantine's own inline-start inset is `--input-height / 3` = 10.67px, off every step. The `ctl` inset
|
|
359
|
+
* is the one the buttons beside it already use, so the value lines up with their labels. Set on the
|
|
360
|
+
* input itself: the `--input-padding-inline-start` var is declared on a CHILD of the root this class
|
|
361
|
+
* lands on, so a root-level override would be shadowed. */
|
|
362
|
+
.phoneSelect input {
|
|
363
|
+
padding-inline-start: var(--button-padding-x-ctl);
|
|
364
|
+
}
|
|
365
|
+
|
|
356
366
|
/* ── The facet list (MultiSelectFilter, `panel` + `sheet` surfaces) ──────────────────────────────── */
|
|
357
367
|
|
|
358
368
|
/*
|
|
@@ -75,6 +75,8 @@ export function FilterPill({
|
|
|
75
75
|
size="ctl"
|
|
76
76
|
className={cx(classes.pill, className)}
|
|
77
77
|
data-basalt-hit
|
|
78
|
+
// The label truncates past the pill's width cap; the full name stays one hover away.
|
|
79
|
+
title={label}
|
|
78
80
|
classNames={{ label: classes.pillLabel }}
|
|
79
81
|
{...(style !== undefined && { style })}
|
|
80
82
|
{...(active === true && { 'data-active': true })}
|
|
@@ -34,8 +34,22 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* The phone form's age (`2 m`): hidden above `sm`, where the long age already sits beside the label.
|
|
38
|
+
* `nowrap` is the whole point of it — a two-token string that wraps inside a 32px button is worse
|
|
39
|
+
* than no age at all.
|
|
40
|
+
*/
|
|
41
|
+
.ageCompact {
|
|
42
|
+
display: none;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
color: var(--vx-muted);
|
|
45
|
+
font-family: var(--basalt-font-mono);
|
|
46
|
+
font-size: var(--vx-text-xs);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* `scope: 'page'` below `sm`: the label and the long age go, the glyph stays, and the button
|
|
51
|
+
* collapses to the square icon form (spec §3) — unless an age exists, in which case the compact age
|
|
52
|
+
* rides beside the glyph and the square pin is released (argo m365 refresh at 390). Hidden, not unmounted — a second
|
|
39
53
|
* mount under `hiddenFrom` is exactly the responsive twin law C9 forbids, which is also why the
|
|
40
54
|
* accessible name lives on `aria-label` rather than in this text.
|
|
41
55
|
*
|
|
@@ -52,6 +66,10 @@
|
|
|
52
66
|
display: none;
|
|
53
67
|
}
|
|
54
68
|
|
|
69
|
+
.ageCompact {
|
|
70
|
+
display: inline;
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
.pageButton {
|
|
56
74
|
--button-padding-x: 0;
|
|
57
75
|
|
|
@@ -61,4 +79,18 @@
|
|
|
61
79
|
.pageButton :global(.mantine-Button-section[data-position='left']) {
|
|
62
80
|
margin-inline-end: 0;
|
|
63
81
|
}
|
|
82
|
+
|
|
83
|
+
/* An age beside the glyph: content-width, on the `ctl` inset, glyph and age one control gap apart. */
|
|
84
|
+
.pageButton[data-with-age] {
|
|
85
|
+
--button-padding-x: var(--button-padding-x-ctl);
|
|
86
|
+
|
|
87
|
+
/* Mantine divides the inline-start padding by 1.5 when a left section exists — off the scale. */
|
|
88
|
+
padding-inline: var(--button-padding-x-ctl);
|
|
89
|
+
width: auto;
|
|
90
|
+
flex: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.pageButton[data-with-age] :global(.mantine-Button-section[data-position='left']) {
|
|
94
|
+
margin-inline-end: var(--vx-space-control-gap);
|
|
95
|
+
}
|
|
64
96
|
}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* pushes a page's own actions into the kebab. The age and the error live in the tooltip; the
|
|
14
14
|
* accessible name is `label`.
|
|
15
15
|
* - `scope: 'page'` → `PageBar.sync` (the page's own data). The labelled `Button` with the age
|
|
16
|
-
* inline beside it on desktop
|
|
17
|
-
* mount, never a `visibleFrom` twin (law C9).
|
|
16
|
+
* inline beside it on desktop; below `sm` the label and the long age go and the glyph keeps a
|
|
17
|
+
* SHORT age (`2m`) beside it — CSS only, one mount, never a `visibleFrom` twin (law C9).
|
|
18
18
|
*
|
|
19
19
|
* Because the label is hidden rather than unmounted below `sm`, the accessible name comes from
|
|
20
20
|
* `aria-label` in BOTH forms: `display: none` text is out of the accessibility tree, so a page
|
|
@@ -26,6 +26,7 @@ import type { ReactNode } from 'react'
|
|
|
26
26
|
import { cx } from '../common/props'
|
|
27
27
|
import type { BasaltProps } from '../common/props'
|
|
28
28
|
import { relativeTime } from '../format'
|
|
29
|
+
import { numberFormat } from '../format/shared'
|
|
29
30
|
import { IconSlot } from '../theme/icon-slot'
|
|
30
31
|
import { RefreshGlyph } from './glyphs'
|
|
31
32
|
import classes from './sync-button.module.css'
|
|
@@ -69,15 +70,43 @@ function toMillis(at: number | Date | null | undefined): number | undefined {
|
|
|
69
70
|
* string (`now`, `1 min. ago`, …), so it is stable across calls within a bucket and a tick only
|
|
70
71
|
* re-renders when the label changes. With no timestamp there is no subscription and no timer.
|
|
71
72
|
*/
|
|
72
|
-
function useRelativeAge(
|
|
73
|
+
function useRelativeAge(
|
|
74
|
+
at: number | Date | null | undefined,
|
|
75
|
+
format: (timestamp: number) => string = (timestamp) =>
|
|
76
|
+
relativeTime(timestamp, { style: 'short' }),
|
|
77
|
+
): string | undefined {
|
|
73
78
|
const timestamp = toMillis(at)
|
|
74
79
|
return useSyncExternalStore(
|
|
75
80
|
timestamp === undefined ? subscribeNever : subscribeAgeTick,
|
|
76
|
-
() => (timestamp === undefined ? undefined :
|
|
81
|
+
() => (timestamp === undefined ? undefined : format(timestamp)),
|
|
77
82
|
() => undefined,
|
|
78
83
|
)
|
|
79
84
|
}
|
|
80
85
|
|
|
86
|
+
const COMPACT_UNITS = [
|
|
87
|
+
{ unit: 'day', seconds: 86_400 },
|
|
88
|
+
{ unit: 'hour', seconds: 3_600 },
|
|
89
|
+
{ unit: 'minute', seconds: 60 },
|
|
90
|
+
] as const
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The phone form's age: one number and a NARROW locale unit (`2m`, `3h`, `2d` in English, `2 Min.`
|
|
94
|
+
* in German), small enough to ride beside the glyph in the button at 390. `Intl.NumberFormat`'s
|
|
95
|
+
* unit style honours the `BasaltProvider` / `defineFormat` locale like every other format here.
|
|
96
|
+
* Under a minute it is the locale's own "now", the same bucket the long age uses, so the two never
|
|
97
|
+
* disagree about whether a sync just landed.
|
|
98
|
+
*/
|
|
99
|
+
function compactAge(timestamp: number): string {
|
|
100
|
+
const seconds = Math.max(0, (Date.now() - timestamp) / 1000)
|
|
101
|
+
const step = COMPACT_UNITS.find((u) => seconds >= u.seconds)
|
|
102
|
+
if (step === undefined) return relativeTime(timestamp, { style: 'short' })
|
|
103
|
+
return numberFormat(undefined, {
|
|
104
|
+
style: 'unit',
|
|
105
|
+
unit: step.unit,
|
|
106
|
+
unitDisplay: 'narrow',
|
|
107
|
+
}).format(Math.floor(seconds / step.seconds))
|
|
108
|
+
}
|
|
109
|
+
|
|
81
110
|
const subscribeNever = (): (() => void) => () => {}
|
|
82
111
|
|
|
83
112
|
function subscribeAgeTick(onTick: () => void): () => void {
|
|
@@ -108,6 +137,7 @@ export function SyncButton({
|
|
|
108
137
|
style,
|
|
109
138
|
}: SyncButtonProps): ReactNode {
|
|
110
139
|
const age = useRelativeAge(lastCompletedAt)
|
|
140
|
+
const shortAge = useRelativeAge(lastCompletedAt, compactAge)
|
|
111
141
|
// Wherever the label is not painted — every `global` mount, and a `page` mount below `sm` — the
|
|
112
142
|
// tooltip is where the age lives; an `error` outranks it everywhere. ONE tooltip, one mount.
|
|
113
143
|
const tooltip = error ?? age
|
|
@@ -158,6 +188,7 @@ export function SyncButton({
|
|
|
158
188
|
<Button
|
|
159
189
|
variant="default"
|
|
160
190
|
className={cx(classes.pageButton, className)}
|
|
191
|
+
{...(age !== undefined && { 'data-with-age': true })}
|
|
161
192
|
{...(style !== undefined && { style })}
|
|
162
193
|
leftSection={
|
|
163
194
|
<IconSlot>
|
|
@@ -168,6 +199,11 @@ export function SyncButton({
|
|
|
168
199
|
>
|
|
169
200
|
<span className={classes.label}>{label}</span>
|
|
170
201
|
{age !== undefined && <span className={classes.age}>{age}</span>}
|
|
202
|
+
{shortAge !== undefined && (
|
|
203
|
+
<span className={classes.ageCompact} data-sync-age="compact">
|
|
204
|
+
{shortAge}
|
|
205
|
+
</span>
|
|
206
|
+
)}
|
|
171
207
|
</Button>
|
|
172
208
|
)}
|
|
173
209
|
</Tooltip>
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
* row never wraps: the label truncates, the value is nowrap.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/*
|
|
9
|
+
* The width container the wide layout keys on (a container cannot restyle its own grid), in every
|
|
10
|
+
* state. It is named `basalt-card` because the theme guard permits only the declared names; that
|
|
11
|
+
* shadows an enclosing card's container for the list's descendants only, and the query below measures
|
|
12
|
+
* the LIST's own inline size, not the card's. `inline-size: 100%` keeps it from collapsing to zero in
|
|
13
|
+
* a flex row or an auto track (size containment ignores content width).
|
|
14
|
+
*/
|
|
15
|
+
.frame {
|
|
16
|
+
container: basalt-card / inline-size;
|
|
17
|
+
inline-size: 100%;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
8
21
|
.root {
|
|
9
22
|
display: grid;
|
|
10
23
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
@@ -158,9 +171,79 @@
|
|
|
158
171
|
text-overflow: ellipsis;
|
|
159
172
|
}
|
|
160
173
|
|
|
174
|
+
/* The dot + word never outgrows its cell: the word truncates (its cell carries the full text in `title`). */
|
|
175
|
+
.root[data-variant='thin'] .secondary > :first-child {
|
|
176
|
+
max-inline-size: 100%;
|
|
177
|
+
}
|
|
178
|
+
|
|
161
179
|
.root[data-variant='thin'] .secondary [data-verdict-word] {
|
|
162
180
|
min-width: 0;
|
|
163
181
|
overflow: hidden;
|
|
164
182
|
text-overflow: ellipsis;
|
|
165
183
|
white-space: nowrap;
|
|
166
184
|
}
|
|
185
|
+
|
|
186
|
+
/*
|
|
187
|
+
* Wide (a container of 480px or more): one row, `[label][value][secondary][track]`. The label column fits the
|
|
188
|
+
* longest label (capped at 40% or 14rem, the rest truncates with its `title`), value and secondary are right-
|
|
189
|
+
* aligned and shared by every row, and the track takes the remaining width on the one scale — a
|
|
190
|
+
* full-scale bar ends at the track end, never under a value. Compact keeps the stacked thin layout.
|
|
191
|
+
*/
|
|
192
|
+
@container basalt-card (width >= 480px) {
|
|
193
|
+
.root[data-variant='thin'] {
|
|
194
|
+
grid-template-columns: fit-content(min(40%, 14rem)) auto minmax(0, 1fr);
|
|
195
|
+
column-gap: var(--vx-space-stack-md, 0.75rem);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.root[data-variant='thin'][data-secondary] {
|
|
199
|
+
grid-template-columns: fit-content(min(40%, 14rem)) auto fit-content(30%) minmax(0, 1fr);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.root[data-variant='thin'] .row {
|
|
203
|
+
grid-template-rows: auto;
|
|
204
|
+
align-items: center;
|
|
205
|
+
padding-block: 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.root[data-variant='thin'] .track {
|
|
209
|
+
grid-column: auto;
|
|
210
|
+
align-self: center;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.root[data-variant='thin'] .label {
|
|
214
|
+
display: block;
|
|
215
|
+
white-space: nowrap;
|
|
216
|
+
text-overflow: ellipsis;
|
|
217
|
+
-webkit-line-clamp: unset;
|
|
218
|
+
line-clamp: unset;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.root[data-variant='thin'] .secondary {
|
|
222
|
+
text-align: end;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.root[data-variant='thin'][data-secondary-align='start'] .secondary {
|
|
226
|
+
text-align: start;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* A column of DeltaBadges: a two-column grid, the glyph in a fixed-width slot and the figure (the badge's
|
|
232
|
+
* bare text) end-aligned in a tabular slot of four characters, so "▲ 9%" and "▲13%" share both their glyph
|
|
233
|
+
* x and their right edge. A zero delta has no glyph; an empty `::before` holds its slot. Scoped here because
|
|
234
|
+
* a hero metric has no column to line up with (D33: tabular figures only in a table-like column).
|
|
235
|
+
*/
|
|
236
|
+
.secondary [data-delta] {
|
|
237
|
+
display: inline-grid;
|
|
238
|
+
grid-template-columns: 1em minmax(4ch, auto);
|
|
239
|
+
justify-items: end;
|
|
240
|
+
font-variant-numeric: tabular-nums;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.secondary [data-delta]:not(:has([data-delta-glyph]))::before {
|
|
244
|
+
content: '';
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.secondary [data-delta-glyph] {
|
|
248
|
+
justify-self: center;
|
|
249
|
+
}
|
|
@@ -12,7 +12,15 @@
|
|
|
12
12
|
* thin bar with the value right-aligned on the label line; `variant="inline"` is the older heavy track
|
|
13
13
|
* with the label inside it.
|
|
14
14
|
*
|
|
15
|
-
* Thin rows sit flush: no inline inset on the label or the rail.
|
|
15
|
+
* Thin rows sit flush: no inline inset on the label or the rail. In a container wider than the compact
|
|
16
|
+
* class (480px) a thin row reads `[label][value][secondary][track]` — the label column fits the longest
|
|
17
|
+
* label, the value and secondary columns are right-aligned and shared, and the track takes the rest on
|
|
18
|
+
* the one scale, so a name stays beside its value and a full-scale bar ends at the track end.
|
|
19
|
+
*
|
|
20
|
+
* The secondary column aligns by content (override: `secondaryAlign`): a text secondary (a status word,
|
|
21
|
+
* `StatusVerdict`/`StatusDot`) starts on one x so the dots line up; figures ("41%", "+€7"), numbers and a
|
|
22
|
+
* `DeltaBadge` end. A delta column also gets a fixed-width glyph slot and a tabular figure slot, so the
|
|
23
|
+
* glyphs AND the figures' right edges line up (a column of deltas is table-like, D33 allows tabular there).
|
|
16
24
|
*
|
|
17
25
|
* Colour law: bars are neutral. `accentLeader` (opt-in) lets the top row take the accent — the
|
|
18
26
|
* leader bar, and nothing else. Each value is rendered as text, never only a bar length.
|
|
@@ -38,10 +46,13 @@
|
|
|
38
46
|
* />
|
|
39
47
|
*/
|
|
40
48
|
import { Skeleton, VisuallyHidden } from '@mantine/core'
|
|
49
|
+
import { isValidElement } from 'react'
|
|
41
50
|
import type { ReactNode } from 'react'
|
|
42
51
|
import { cx } from '../common/props'
|
|
43
52
|
import type { BasaltProps } from '../common/props'
|
|
44
53
|
import classes from './bar-list.module.css'
|
|
54
|
+
import { StatusDot } from '../theme/status-dot'
|
|
55
|
+
import { StatusVerdict } from '../theme/status-verdict'
|
|
45
56
|
import { asText, barPercent } from './scale'
|
|
46
57
|
|
|
47
58
|
type BarListItem = {
|
|
@@ -76,6 +87,11 @@ export type BarListProps = BasaltProps & {
|
|
|
76
87
|
variant?: 'thin' | 'inline'
|
|
77
88
|
/** The first row's bar takes the accent. Off by default. */
|
|
78
89
|
accentLeader?: boolean
|
|
90
|
+
/**
|
|
91
|
+
* Which edge the secondary column aligns to. Default: by content — text (a status word, a status
|
|
92
|
+
* mark) starts, figures and other elements end.
|
|
93
|
+
*/
|
|
94
|
+
secondaryAlign?: 'start' | 'end'
|
|
79
95
|
/** Renders row-shaped skeletons. */
|
|
80
96
|
loading?: boolean
|
|
81
97
|
/** Skeleton rows while loading. Default 5. */
|
|
@@ -88,6 +104,19 @@ export type BarListProps = BasaltProps & {
|
|
|
88
104
|
const hasContent = (node: ReactNode): boolean =>
|
|
89
105
|
node !== undefined && node !== null && typeof node !== 'boolean'
|
|
90
106
|
|
|
107
|
+
const isFigure = (node: ReactNode): boolean =>
|
|
108
|
+
typeof node === 'number' || (typeof node === 'string' && /^[\s+\-−±▲▼]*[€$£¥]?\d/.test(node))
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The column's edge by content. A string that is not a figure and a status mark (`StatusVerdict`,
|
|
112
|
+
* `StatusDot`) are text and start on one x so the dots line up; a number, a numeric string and any other
|
|
113
|
+
* element (a `DeltaBadge`) are figures and keep the end edge.
|
|
114
|
+
*/
|
|
115
|
+
const isText = (node: ReactNode): boolean =>
|
|
116
|
+
typeof node === 'string'
|
|
117
|
+
? !isFigure(node)
|
|
118
|
+
: isValidElement(node) && (node.type === StatusVerdict || node.type === StatusDot)
|
|
119
|
+
|
|
91
120
|
export function BarList({
|
|
92
121
|
label,
|
|
93
122
|
items,
|
|
@@ -95,6 +124,7 @@ export function BarList({
|
|
|
95
124
|
max,
|
|
96
125
|
variant = 'thin',
|
|
97
126
|
accentLeader = false,
|
|
127
|
+
secondaryAlign,
|
|
98
128
|
loading = false,
|
|
99
129
|
loadingRows = 5,
|
|
100
130
|
emptyText = 'No data',
|
|
@@ -103,19 +133,23 @@ export function BarList({
|
|
|
103
133
|
}: BarListProps) {
|
|
104
134
|
if (loading) {
|
|
105
135
|
return (
|
|
106
|
-
<div className={cx(classes.
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
136
|
+
<div className={cx(classes.frame, className)} style={style}>
|
|
137
|
+
<div className={classes.root} aria-busy="true">
|
|
138
|
+
<VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
|
|
139
|
+
{Array.from({ length: loadingRows }, (_, i) => (
|
|
140
|
+
<Skeleton key={i} className={classes.skeletonRow} data-bar-skeleton />
|
|
141
|
+
))}
|
|
142
|
+
</div>
|
|
111
143
|
</div>
|
|
112
144
|
)
|
|
113
145
|
}
|
|
114
146
|
if (items.length === 0) {
|
|
115
147
|
return (
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
|
|
148
|
+
<div className={cx(classes.frame, className)} style={style}>
|
|
149
|
+
<output className={classes.root} aria-label={label}>
|
|
150
|
+
<span className={classes.empty}>{emptyText}</span>
|
|
151
|
+
</output>
|
|
152
|
+
</div>
|
|
119
153
|
)
|
|
120
154
|
}
|
|
121
155
|
|
|
@@ -127,70 +161,74 @@ export function BarList({
|
|
|
127
161
|
)
|
|
128
162
|
const thin = variant === 'thin'
|
|
129
163
|
const hasSecondary = items.some((i) => hasContent(i.secondary))
|
|
164
|
+
const align = secondaryAlign ?? (items.some((i) => isText(i.secondary)) ? 'start' : 'end')
|
|
130
165
|
return (
|
|
131
|
-
// The
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
<span
|
|
157
|
-
|
|
158
|
-
style={{ width: `${barPercent(item.value, rowScale)}%` }}
|
|
159
|
-
data-bar-fill=""
|
|
160
|
-
data-bar-leader={isLeader ? '' : undefined}
|
|
161
|
-
aria-hidden
|
|
162
|
-
/>
|
|
163
|
-
{item.tick !== undefined && (
|
|
164
|
-
// theme-allow hidden-inline-style — the position is the row's data (a % of its scale)
|
|
166
|
+
// The frame is the width container the wide layout keys on (a container cannot restyle its own grid).
|
|
167
|
+
<div className={cx(classes.frame, className)} style={style}>
|
|
168
|
+
{/* The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one. */}
|
|
169
|
+
<ul
|
|
170
|
+
className={classes.root}
|
|
171
|
+
// oxlint-disable-next-line jsx-a11y/no-redundant-roles
|
|
172
|
+
role="list"
|
|
173
|
+
aria-label={label}
|
|
174
|
+
data-secondary={hasSecondary ? '' : undefined}
|
|
175
|
+
data-secondary-align={hasSecondary ? align : undefined}
|
|
176
|
+
data-variant={variant}
|
|
177
|
+
>
|
|
178
|
+
{items.map((item, i) => {
|
|
179
|
+
const isLeader = accentLeader && i === 0
|
|
180
|
+
const rowScale = item.max ?? scale
|
|
181
|
+
const labelNode = (
|
|
182
|
+
<span className={classes.label} title={item.label}>
|
|
183
|
+
{item.label}
|
|
184
|
+
</span>
|
|
185
|
+
)
|
|
186
|
+
const tickName =
|
|
187
|
+
item.tick === undefined
|
|
188
|
+
? ''
|
|
189
|
+
: `${item.tickLabel ?? 'Threshold'} ${format(item.tick, 'value')}`
|
|
190
|
+
const track = (
|
|
191
|
+
<span className={classes.track} data-bar-track>
|
|
192
|
+
{/* theme-allow hidden-inline-style — the width is the row's data (a % of its scale), not styling */}
|
|
165
193
|
<span
|
|
166
|
-
className={classes.
|
|
167
|
-
style={{
|
|
168
|
-
data-bar-
|
|
194
|
+
className={cx(classes.bar, isLeader && classes.leader)}
|
|
195
|
+
style={{ width: `${barPercent(item.value, rowScale)}%` }}
|
|
196
|
+
data-bar-fill=""
|
|
197
|
+
data-bar-leader={isLeader ? '' : undefined}
|
|
169
198
|
aria-hidden
|
|
170
199
|
/>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
? item.max === undefined
|
|
184
|
-
? format(item.value, 'value')
|
|
185
|
-
: `${format(item.value, 'value')} / ${format(item.max, 'max')}`
|
|
186
|
-
: '—'}
|
|
200
|
+
{item.tick !== undefined && (
|
|
201
|
+
// theme-allow hidden-inline-style — the position is the row's data (a % of its scale)
|
|
202
|
+
<span
|
|
203
|
+
className={classes.tick}
|
|
204
|
+
style={{ insetInlineStart: `${barPercent(item.tick, rowScale)}%` }}
|
|
205
|
+
data-bar-tick=""
|
|
206
|
+
aria-hidden
|
|
207
|
+
/>
|
|
208
|
+
)}
|
|
209
|
+
{!thin && labelNode}
|
|
210
|
+
{/* Inside the track so it is never the row's last child (the value/secondary inset). */}
|
|
211
|
+
{item.tick !== undefined && <VisuallyHidden>{tickName}</VisuallyHidden>}
|
|
187
212
|
</span>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
213
|
+
)
|
|
214
|
+
return (
|
|
215
|
+
<li key={item.key ?? `${item.label}-${i}`} className={classes.row}>
|
|
216
|
+
{thin && labelNode}
|
|
217
|
+
{!thin && track}
|
|
218
|
+
<span className={classes.value}>
|
|
219
|
+
{Number.isFinite(item.value)
|
|
220
|
+
? item.max === undefined
|
|
221
|
+
? format(item.value, 'value')
|
|
222
|
+
: `${format(item.value, 'value')} / ${format(item.max, 'max')}`
|
|
223
|
+
: '—'}
|
|
224
|
+
</span>
|
|
225
|
+
{/* Kept empty on a row without one: the secondary column is shared, so every row has the cell. */}
|
|
226
|
+
{hasSecondary && <span className={classes.secondary}>{item.secondary}</span>}
|
|
227
|
+
{thin && track}
|
|
228
|
+
</li>
|
|
229
|
+
)
|
|
230
|
+
})}
|
|
231
|
+
</ul>
|
|
232
|
+
</div>
|
|
195
233
|
)
|
|
196
234
|
}
|
|
@@ -87,8 +87,12 @@ export function DeltaBadge({
|
|
|
87
87
|
const showGlyph = withGlyph && glyph !== undefined
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
|
-
<span className={classes.deltaBadge} style={{ color: tone }}>
|
|
91
|
-
{showGlyph &&
|
|
90
|
+
<span className={classes.deltaBadge} style={{ color: tone }} data-delta="">
|
|
91
|
+
{showGlyph && (
|
|
92
|
+
<span className={classes.deltaGlyph} data-delta-glyph="">
|
|
93
|
+
{glyph}
|
|
94
|
+
</span>
|
|
95
|
+
)}
|
|
92
96
|
{format(value)}
|
|
93
97
|
{period !== undefined && ' '}
|
|
94
98
|
{period !== undefined && (
|
package/src/dashboard/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { WidgetHeader } from './widget-header'
|
|
2
2
|
export { DeltaBadge } from './delta-badge'
|
|
3
3
|
export { Section } from './section'
|
|
4
|
+
export { PageSummary, type PageSummaryProps } from './page-summary'
|
|
4
5
|
export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from './stat-card'
|
|
5
6
|
export { StatGroup } from './stat-group'
|
|
6
7
|
export type { StatStripCell, StatStripRow } from './stat-strip'
|