basalt-ui 2.19.0 → 2.21.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 +89 -0
- package/MIGRATING.md +291 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-app/SKILL.md +1 -1
- 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 +48 -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/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +34 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +33 -4
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +37 -11
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +13 -1
- package/dist/charts/Heatmap.js +1 -1
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +137 -18
- package/dist/charts/box.d.ts +2 -0
- package/dist/charts/box.d.ts.map +1 -1
- package/dist/charts/box.js +2 -0
- package/dist/charts/chart-box.module.css +30 -0
- package/dist/charts/chart-box.module.css.d.ts +1 -0
- package/dist/charts/chart-card.module.css +47 -0
- package/dist/charts/chart-card.module.css.d.ts +7 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +35 -8
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +2 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/sparkline.module.css +59 -0
- package/dist/charts/sparkline.module.css.d.ts +13 -0
- package/dist/charts/state.d.ts +5 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +34 -4
- package/dist/charts/types.d.ts +6 -0
- 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/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.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +6 -1
- 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 +396 -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/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -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/sync-button.d.ts +3 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/dashboard/bar-list.d.ts +18 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +39 -15
- package/dist/dashboard/bar-list.module.css +77 -2
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +53 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +62 -14
- package/dist/dashboard/meter-parts.d.ts +5 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +140 -68
- package/dist/dashboard/meter.d.ts +29 -4
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +8 -1
- package/dist/dashboard/meter.module.css +74 -43
- package/dist/dashboard/meter.module.css.d.ts +4 -4
- 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 +16 -10
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +1 -1
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +5 -7
- package/dist/dashboard/stat-card.module.css +15 -7
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +67 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +115 -0
- package/dist/dashboard/stat-strip.module.css +291 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +32 -0
- package/dist/dashboard/visual-slot.d.ts +2 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +5 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.module.css +10 -6
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +16 -3
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +15 -1
- 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/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/styles.css +6 -0
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/controls.module.css +13 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +41 -0
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +3 -2
- package/dist/theme/status-dot.d.ts.map +1 -1
- package/dist/theme/status-dot.js +12 -3
- package/dist/theme/status-verdict.d.ts +3 -2
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +3 -2
- package/dist/theme/status-verdict.module.css +4 -2
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/llms.txt +33 -7
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +79 -5
- package/src/charts/Donut.tsx +9 -1
- package/src/charts/Heatmap.tsx +1 -1
- package/src/charts/Sparkline.tsx +180 -18
- package/src/charts/box.tsx +2 -0
- package/src/charts/chart-box.module.css +30 -0
- package/src/charts/chart-box.module.css.d.ts +1 -0
- package/src/charts/chart-card.module.css +47 -0
- package/src/charts/chart-card.module.css.d.ts +7 -0
- package/src/charts/compile.ts +42 -9
- package/src/charts/host.tsx +6 -3
- package/src/charts/index.ts +1 -1
- package/src/charts/sparkline.module.css +59 -0
- package/src/charts/sparkline.module.css.d.ts +13 -0
- package/src/charts/state.tsx +53 -4
- package/src/charts/types.ts +6 -0
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +2 -1
- package/src/cli/shot/capture.ts +15 -2
- package/src/cli/shot/detect.ts +533 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/types.ts +5 -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/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +77 -2
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +89 -18
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +126 -20
- package/src/dashboard/meter-parts.tsx +224 -88
- package/src/dashboard/meter.module.css +74 -43
- package/src/dashboard/meter.module.css.d.ts +4 -4
- package/src/dashboard/meter.tsx +39 -5
- package/src/dashboard/query-state.tsx +26 -20
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +15 -7
- package/src/dashboard/stat-card.tsx +9 -9
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +291 -0
- package/src/dashboard/stat-strip.module.css.d.ts +32 -0
- package/src/dashboard/stat-strip.tsx +263 -0
- package/src/dashboard/visual-slot.ts +8 -0
- package/src/dashboard/widget-header.module.css +10 -6
- package/src/dashboard/widget-header.tsx +3 -3
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +17 -5
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +202 -24
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/controls.module.css +13 -0
- package/src/theme/index.ts +56 -0
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.tsx +17 -5
- package/src/theme/status-verdict.module.css +4 -2
- package/src/theme/status-verdict.tsx +9 -4
- package/src/tokens/oklab.ts +97 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The one Retry. ErrorState (Mantine, StatCard / pages), ChartCard's placeholder and a strip cell's
|
|
3
|
+
* error all render this, so the three read as one button. It is a plain element because `./charts`
|
|
4
|
+
* resolves with no Mantine, and it is styled to be a Mantine `size="xs" variant="default"` Button
|
|
5
|
+
* reading the same `--vx-*` tokens the theme binds that button to: panel fill (elevated on hover), no
|
|
6
|
+
* border, `shadow-raised`, the control radius, the xs type size, the theme's inline padding step and
|
|
7
|
+
* Mantine's 30px xs height. `--mantine-scale` carries the app's scale knob, 1 where Mantine is absent.
|
|
8
|
+
*/
|
|
9
|
+
.retry {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
flex: none;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
height: calc(1.875rem * var(--mantine-scale, 1));
|
|
16
|
+
padding-block: 0;
|
|
17
|
+
padding-inline: calc(var(--vx-space-stack-md, 0.75rem) * var(--mantine-scale, 1));
|
|
18
|
+
border: calc(0.0625rem * var(--mantine-scale, 1)) solid transparent;
|
|
19
|
+
border-radius: var(--vx-radius-ctrl);
|
|
20
|
+
background: var(--vx-surface-panel);
|
|
21
|
+
box-shadow: var(--vx-shadow-raised);
|
|
22
|
+
color: var(--mantine-color-default-color, var(--vx-ink));
|
|
23
|
+
font: inherit;
|
|
24
|
+
font-size: var(--vx-text-xs);
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
line-height: 1;
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
user-select: none;
|
|
30
|
+
transition: box-shadow 120ms ease;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.retry:focus-visible {
|
|
34
|
+
outline: calc(0.125rem * var(--mantine-scale, 1)) solid
|
|
35
|
+
var(--mantine-primary-color-filled, var(--vx-accent-fill));
|
|
36
|
+
outline-offset: calc(0.125rem * var(--mantine-scale, 1));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Hover is a pointer affordance: a touch tap would leave it stuck on. */
|
|
40
|
+
@media (hover: hover) {
|
|
41
|
+
.retry:hover:not(:disabled) {
|
|
42
|
+
background: var(--vx-surface-elevated);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Busy is Mantine's disabled paint: its own disabled colour and background, flat, no border. */
|
|
47
|
+
.retry:disabled {
|
|
48
|
+
background: var(--mantine-color-disabled, var(--vx-surface-subtle));
|
|
49
|
+
color: var(--mantine-color-disabled-color, var(--vx-muted));
|
|
50
|
+
box-shadow: none;
|
|
51
|
+
cursor: not-allowed;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (prefers-reduced-motion: reduce) {
|
|
55
|
+
.retry {
|
|
56
|
+
transition: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one Retry button of the shared error anatomy (status dot + word + message + Retry). Internal:
|
|
3
|
+
* `ErrorState`, `ChartCard`'s placeholder and a strip cell's error all render it, so they cannot
|
|
4
|
+
* drift. Mantine-free — `./charts` uses it with no `@mantine/*` installed.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactElement } from 'react'
|
|
7
|
+
import classes from './retry-button.module.css'
|
|
8
|
+
|
|
9
|
+
export function RetryButton({
|
|
10
|
+
onClick,
|
|
11
|
+
retrying = false,
|
|
12
|
+
}: {
|
|
13
|
+
onClick: () => void
|
|
14
|
+
/** A refetch is in flight: inert and marked busy. */
|
|
15
|
+
retrying?: boolean
|
|
16
|
+
}): ReactElement {
|
|
17
|
+
return (
|
|
18
|
+
<button
|
|
19
|
+
type="button"
|
|
20
|
+
className={classes.retry}
|
|
21
|
+
data-basalt-retry=""
|
|
22
|
+
disabled={retrying}
|
|
23
|
+
{...(retrying && { 'aria-busy': true })}
|
|
24
|
+
onClick={onClick}
|
|
25
|
+
>
|
|
26
|
+
Retry
|
|
27
|
+
</button>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -86,6 +86,9 @@ function subscribeAgeTick(onTick: () => void): () => void {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
+
* The age label follows the `BasaltProvider` / `defineFormat` locale. It is read when the label is
|
|
90
|
+
* formatted, so a locale switch shows on the next age tick or re-render (no new subscription).
|
|
91
|
+
*
|
|
89
92
|
* @example
|
|
90
93
|
* // page scope — the page's own data
|
|
91
94
|
* <PageBar sync={{ syncing, lastCompletedAt, onSync: refetch }} />
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
.value {
|
|
65
|
-
font-family: var(--basalt-font-
|
|
65
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
66
|
+
font-variant-numeric: lining-nums;
|
|
66
67
|
text-align: end;
|
|
67
68
|
white-space: nowrap;
|
|
68
69
|
}
|
|
@@ -73,7 +74,8 @@
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
.secondary {
|
|
76
|
-
font-family: var(--basalt-font-
|
|
77
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
78
|
+
font-variant-numeric: lining-nums;
|
|
77
79
|
font-size: var(--vx-text-sm);
|
|
78
80
|
color: var(--vx-muted);
|
|
79
81
|
white-space: nowrap;
|
|
@@ -89,3 +91,76 @@
|
|
|
89
91
|
grid-column: 1 / -1;
|
|
90
92
|
height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
/* A row's threshold: a hairline across the bar at a position on the row's own scale. */
|
|
96
|
+
.tick {
|
|
97
|
+
position: absolute;
|
|
98
|
+
inset-block: 0;
|
|
99
|
+
inline-size: 0;
|
|
100
|
+
border-inline-start: 1px solid var(--vx-ink);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Thin: label and value share the first line, the bar is a thin rail on the second spanning every
|
|
105
|
+
* column. The label column is still shared (subgrid), so the value columns stay aligned.
|
|
106
|
+
*/
|
|
107
|
+
.root[data-variant='thin'] .row {
|
|
108
|
+
grid-template-rows: auto auto;
|
|
109
|
+
row-gap: var(--vx-space-stack-xs, 0.25rem);
|
|
110
|
+
align-items: baseline;
|
|
111
|
+
padding-block: var(--vx-space-stack-xs, 0.25rem);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.root[data-variant='thin'] .track {
|
|
115
|
+
grid-column: 1 / -1;
|
|
116
|
+
align-self: auto;
|
|
117
|
+
block-size: 0.25rem;
|
|
118
|
+
padding-inline: 0;
|
|
119
|
+
border-radius: var(--vx-radius-fine);
|
|
120
|
+
background: color-mix(in srgb, var(--vx-line) 20%, transparent);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.root[data-variant='thin'] .bar {
|
|
124
|
+
background: color-mix(in srgb, var(--vx-line) 80%, transparent);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.root[data-variant='thin'] .bar.leader {
|
|
128
|
+
background: var(--vx-accent);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* The mark outgrows the rail so a 1px line stays visible against a 4px bar. */
|
|
132
|
+
.root[data-variant='thin'] .tick {
|
|
133
|
+
inset-block: calc(var(--vx-space-stack-xs, 0.25rem) * -1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* Thin rows get a phone's width: the label wraps up to two lines, then truncates (its `title` carries
|
|
138
|
+
* the whole text), and the secondary column takes at most 40% of the list, clipped, so a long status
|
|
139
|
+
* never squeezes the title down to a few characters.
|
|
140
|
+
*/
|
|
141
|
+
.root[data-variant='thin'][data-secondary] {
|
|
142
|
+
grid-template-columns: minmax(0, 1fr) auto fit-content(40%);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.root[data-variant='thin'] .label {
|
|
146
|
+
display: -webkit-box;
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
white-space: normal;
|
|
149
|
+
overflow-wrap: anywhere;
|
|
150
|
+
-webkit-box-orient: vertical;
|
|
151
|
+
-webkit-line-clamp: 2;
|
|
152
|
+
line-clamp: 2;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.root[data-variant='thin'] .secondary {
|
|
156
|
+
min-width: 0;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.root[data-variant='thin'] .secondary [data-verdict-word] {
|
|
162
|
+
min-width: 0;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
text-overflow: ellipsis;
|
|
165
|
+
white-space: nowrap;
|
|
166
|
+
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BarList — a ranked list: label, an inline bar on ONE shared scale, a
|
|
2
|
+
* BarList — a ranked list: label, an inline bar on ONE shared scale, a right-aligned sans value and
|
|
3
3
|
* an optional muted secondary value. Choose it for "top N" (the bar ranks by length before anything
|
|
4
4
|
* is read). The bar spans the label column only — values sit outside it, so a full-scale bar ends
|
|
5
5
|
* before its value. Intended for 5–10 rows; past 10 use a table with an inline `Meter` cell. An
|
|
6
6
|
* HTML/CSS primitive, not a chart kind.
|
|
7
7
|
*
|
|
8
|
+
* A row may carry its own `max` (points of 40 / 35 / 25): its bar fills value / row.max and the value
|
|
9
|
+
* column reads "32 / 40". The shared scale — `max` prop, else the largest value — is computed over the
|
|
10
|
+
* rows WITHOUT their own `max` only. A row's `tick` (on that row's scale) draws a hairline across the
|
|
11
|
+
* bar, named for assistive tech. The default (`variant="thin"`) puts the label on its own line above a
|
|
12
|
+
* thin bar with the value right-aligned on the label line; `variant="inline"` is the older heavy track
|
|
13
|
+
* with the label inside it.
|
|
14
|
+
*
|
|
15
|
+
* Thin rows sit flush: no inline inset on the label or the rail.
|
|
16
|
+
*
|
|
8
17
|
* Colour law: bars are neutral. `accentLeader` (opt-in) lets the top row take the accent — the
|
|
9
18
|
* leader bar, and nothing else. Each value is rendered as text, never only a bar length.
|
|
10
19
|
*
|
|
@@ -14,6 +23,13 @@
|
|
|
14
23
|
* // Recovery contributors on a fixed 0–100 scale, the qualitative level as the secondary value:
|
|
15
24
|
* <BarList label="Recovery contributors" max={100} items={[{ label: 'Sleep', value: 82, secondary: 'Good' }]} />
|
|
16
25
|
*
|
|
26
|
+
* // Points of different maxima, a threshold tick ("32 / 40 pts"; the tick is named for AT):
|
|
27
|
+
* <BarList
|
|
28
|
+
* label="Recovery contributors"
|
|
29
|
+
* format={(n, part) => (part === 'max' ? `${n} pts` : String(n))}
|
|
30
|
+
* items={[{ label: 'Sleep', value: 32, max: 40, tick: 30, tickLabel: 'Target' }, { label: 'HRV', value: 14, max: 35 }]}
|
|
31
|
+
* />
|
|
32
|
+
*
|
|
17
33
|
* <BarList
|
|
18
34
|
* label="Top projects by tokens"
|
|
19
35
|
* items={[{ label: 'argo', value: 1840, secondary: '41%' }, { label: 'rb', value: 920 }]}
|
|
@@ -28,17 +44,36 @@ import type { BasaltProps } from '../common/props'
|
|
|
28
44
|
import classes from './bar-list.module.css'
|
|
29
45
|
import { asText, barPercent } from './scale'
|
|
30
46
|
|
|
31
|
-
type BarListItem = {
|
|
47
|
+
type BarListItem = {
|
|
48
|
+
label: string
|
|
49
|
+
value: number
|
|
50
|
+
secondary?: ReactNode
|
|
51
|
+
key?: string
|
|
52
|
+
/** This row's own scale end: the bar fills value / max and the value reads "value / max". */
|
|
53
|
+
max?: number
|
|
54
|
+
/** A hairline mark at this position on the row's scale (a threshold). */
|
|
55
|
+
tick?: number
|
|
56
|
+
/** Names the tick for assistive tech (visually hidden text in the track). Default "Threshold". */
|
|
57
|
+
tickLabel?: string
|
|
58
|
+
}
|
|
32
59
|
|
|
33
60
|
export type BarListProps = BasaltProps & {
|
|
34
61
|
/** Accessible name of the list. Required. */
|
|
35
62
|
label: string
|
|
36
63
|
/** Rows in display order (sort them yourself; the list does not reorder). */
|
|
37
64
|
items: readonly BarListItem[]
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Formats each number. `part` is `'max'` for a row's denominator, `'value'` otherwise (the value and
|
|
67
|
+
* the tick), so a unit can sit on one side only: `'32 / 40 pts'`. Default: the number as written.
|
|
68
|
+
*/
|
|
69
|
+
format?: (value: number, part: 'value' | 'max') => string
|
|
70
|
+
/** Scale end shared by rows without their own `max`. Default: the largest of those rows' values. */
|
|
41
71
|
max?: number
|
|
72
|
+
/**
|
|
73
|
+
* `thin` (default): label on its own line above a thin bar, value right-aligned on that line.
|
|
74
|
+
* `inline`: the label sits inside a heavier track, the value outside it.
|
|
75
|
+
*/
|
|
76
|
+
variant?: 'thin' | 'inline'
|
|
42
77
|
/** The first row's bar takes the accent. Off by default. */
|
|
43
78
|
accentLeader?: boolean
|
|
44
79
|
/** Renders row-shaped skeletons. */
|
|
@@ -58,6 +93,7 @@ export function BarList({
|
|
|
58
93
|
items,
|
|
59
94
|
format = asText,
|
|
60
95
|
max,
|
|
96
|
+
variant = 'thin',
|
|
61
97
|
accentLeader = false,
|
|
62
98
|
loading = false,
|
|
63
99
|
loadingRows = 5,
|
|
@@ -84,7 +120,12 @@ export function BarList({
|
|
|
84
120
|
}
|
|
85
121
|
|
|
86
122
|
const scale =
|
|
87
|
-
max ??
|
|
123
|
+
max ??
|
|
124
|
+
items.reduce(
|
|
125
|
+
(top, i) => (i.max === undefined && Number.isFinite(i.value) ? Math.max(top, i.value) : top),
|
|
126
|
+
0,
|
|
127
|
+
)
|
|
128
|
+
const thin = variant === 'thin'
|
|
88
129
|
const hasSecondary = items.some((i) => hasContent(i.secondary))
|
|
89
130
|
return (
|
|
90
131
|
// The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
@@ -95,28 +136,58 @@ export function BarList({
|
|
|
95
136
|
role="list"
|
|
96
137
|
aria-label={label}
|
|
97
138
|
data-secondary={hasSecondary ? '' : undefined}
|
|
139
|
+
data-variant={variant}
|
|
98
140
|
>
|
|
99
141
|
{items.map((item, i) => {
|
|
100
142
|
const isLeader = accentLeader && i === 0
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
143
|
+
const rowScale = item.max ?? scale
|
|
144
|
+
const labelNode = (
|
|
145
|
+
<span className={classes.label} title={item.label}>
|
|
146
|
+
{item.label}
|
|
147
|
+
</span>
|
|
148
|
+
)
|
|
149
|
+
const tickName =
|
|
150
|
+
item.tick === undefined
|
|
151
|
+
? ''
|
|
152
|
+
: `${item.tickLabel ?? 'Threshold'} ${format(item.tick, 'value')}`
|
|
153
|
+
const track = (
|
|
154
|
+
<span className={classes.track} data-bar-track>
|
|
155
|
+
{/* theme-allow hidden-inline-style — the width is the row's data (a % of its scale), not styling */}
|
|
156
|
+
<span
|
|
157
|
+
className={cx(classes.bar, isLeader && classes.leader)}
|
|
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)
|
|
105
165
|
<span
|
|
106
|
-
className={
|
|
107
|
-
style={{
|
|
108
|
-
data-bar-
|
|
166
|
+
className={classes.tick}
|
|
167
|
+
style={{ insetInlineStart: `${barPercent(item.tick, rowScale)}%` }}
|
|
168
|
+
data-bar-tick=""
|
|
109
169
|
aria-hidden
|
|
110
170
|
/>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
</
|
|
171
|
+
)}
|
|
172
|
+
{!thin && labelNode}
|
|
173
|
+
{/* Inside the track so it is never the row's last child (the value/secondary inset). */}
|
|
174
|
+
{item.tick !== undefined && <VisuallyHidden>{tickName}</VisuallyHidden>}
|
|
175
|
+
</span>
|
|
176
|
+
)
|
|
177
|
+
return (
|
|
178
|
+
<li key={item.key ?? `${item.label}-${i}`} className={classes.row}>
|
|
179
|
+
{thin && labelNode}
|
|
180
|
+
{!thin && track}
|
|
115
181
|
<span className={classes.value}>
|
|
116
|
-
{Number.isFinite(item.value)
|
|
182
|
+
{Number.isFinite(item.value)
|
|
183
|
+
? item.max === undefined
|
|
184
|
+
? format(item.value, 'value')
|
|
185
|
+
: `${format(item.value, 'value')} / ${format(item.max, 'max')}`
|
|
186
|
+
: '—'}
|
|
117
187
|
</span>
|
|
118
188
|
{/* Kept empty on a row without one: the secondary column is shared, so every row has the cell. */}
|
|
119
189
|
{hasSecondary && <span className={classes.secondary}>{item.secondary}</span>}
|
|
190
|
+
{thin && track}
|
|
120
191
|
</li>
|
|
121
192
|
)
|
|
122
193
|
})}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DeltaBadge — the KPI trend readout (docs/DESIGN-CORE.md: "up/down deltas are text colour only,
|
|
3
|
-
* never a fill"): a glyph and a signed figure in the trend colour,
|
|
4
|
-
* or padding in either scheme. The optional ▲/▼ glyph sits on the `micro` rung and `period` is
|
|
3
|
+
* never a fill"): a glyph and a signed figure in the trend colour, proportional-sans `sm` with
|
|
4
|
+
* lining figures, with NO fill, border or padding in either scheme. The optional ▲/▼ glyph sits on the `micro` rung and `period` is
|
|
5
5
|
* `micro` muted. `polarity` decides the TONE the sign maps to — `'up-good'` (default) reads a rise
|
|
6
6
|
* as success and a fall as danger; `'up-bad'` inverts that for a metric where a rise is the worse
|
|
7
7
|
* reading (a cycle-top index, latency, error rate); `'neutral'` renders every sign in a faint,
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* <DeltaBadge value={0} /> // 0.0%, faint, no glyph
|
|
24
24
|
* <DeltaBadge value={182} format={(v) => `${Math.abs(v)}ms`} withGlyph={false} />
|
|
25
25
|
* <DeltaBadge value={35.9} polarity="up-bad" /> // ▲ 35.9%, danger — a rise is bad here
|
|
26
|
+
* <DeltaBadge value={4.2} period="last week" /> // ▲ 4.2% vs last week
|
|
26
27
|
*/
|
|
27
28
|
import { VX } from '../tokens'
|
|
28
29
|
import classes from './widget-header.module.css'
|
|
@@ -41,13 +42,24 @@ export type DeltaBadgeProps = {
|
|
|
41
42
|
format?: (value: number) => string
|
|
42
43
|
/** Render the ▲/▼ direction glyph. Defaults to `true`; a zero value never shows a glyph. */
|
|
43
44
|
withGlyph?: boolean
|
|
44
|
-
/** Optional comparison
|
|
45
|
-
* `
|
|
45
|
+
/** Optional comparison period rendered after the value, muted, as `<periodPrefix> <period>`
|
|
46
|
+
* (`period="last week"` → "vs last week"). One rule: the prefix is prepended unless the period
|
|
47
|
+
* already starts with it (case-insensitive, optional trailing dot: "vs", "VS", "vs."), so a caller
|
|
48
|
+
* still writing "vs last week" renders it once. Other words ("versus") are not detected. */
|
|
46
49
|
period?: string | undefined
|
|
50
|
+
/** The word composed before `period`. Defaults to `'vs'`; pass your locale's word, or `''` to
|
|
51
|
+
* render `period` raw. */
|
|
52
|
+
periodPrefix?: string
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
const defaultFormat = (value: number): string => `${Math.abs(value).toFixed(1)}%`
|
|
50
56
|
|
|
57
|
+
function composePeriod(period: string, prefix: string): string {
|
|
58
|
+
if (prefix === '') return period
|
|
59
|
+
const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
60
|
+
return new RegExp(`^${escaped}\\.?(\\s|$)`, 'i').test(period) ? period : `${prefix} ${period}`
|
|
61
|
+
}
|
|
62
|
+
|
|
51
63
|
function resolveTone(value: number, polarity: DeltaPolarity): string {
|
|
52
64
|
if (value === 0 || polarity === 'neutral') return VX.faint
|
|
53
65
|
const rose = value > 0
|
|
@@ -68,6 +80,7 @@ export function DeltaBadge({
|
|
|
68
80
|
format = defaultFormat,
|
|
69
81
|
withGlyph = true,
|
|
70
82
|
period,
|
|
83
|
+
periodPrefix = 'vs',
|
|
71
84
|
}: DeltaBadgeProps) {
|
|
72
85
|
const tone = resolveTone(value, polarity)
|
|
73
86
|
const glyph = directionGlyph(value)
|
|
@@ -77,7 +90,10 @@ export function DeltaBadge({
|
|
|
77
90
|
<span className={classes.deltaBadge} style={{ color: tone }}>
|
|
78
91
|
{showGlyph && <span className={classes.deltaGlyph}>{glyph}</span>}
|
|
79
92
|
{format(value)}
|
|
80
|
-
{period !== undefined &&
|
|
93
|
+
{period !== undefined && ' '}
|
|
94
|
+
{period !== undefined && (
|
|
95
|
+
<span className={classes.deltaPeriod}>{composePeriod(period, periodPrefix)}</span>
|
|
96
|
+
)}
|
|
81
97
|
</span>
|
|
82
98
|
)
|
|
83
99
|
}
|
package/src/dashboard/index.ts
CHANGED
|
@@ -3,7 +3,9 @@ export { DeltaBadge } from './delta-badge'
|
|
|
3
3
|
export { Section } from './section'
|
|
4
4
|
export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from './stat-card'
|
|
5
5
|
export { StatGroup } from './stat-group'
|
|
6
|
+
export type { StatStripCell, StatStripRow } from './stat-strip'
|
|
6
7
|
export { EmptyState } from './empty-state'
|
|
7
8
|
export { SettingsSection, SettingsRow, DangerZone } from './settings-section'
|
|
8
9
|
export { Meter, type MeterProps } from './meter'
|
|
10
|
+
export type { MeterSegment, MeterTick, MeterZone } from './meter-model'
|
|
9
11
|
export { BarList, type BarListProps } from './bar-list'
|
|
@@ -6,7 +6,22 @@ import type { ReactNode } from 'react'
|
|
|
6
6
|
import { clamp01, toPct } from './scale'
|
|
7
7
|
|
|
8
8
|
export type MeterSegment = { value: number; label: string; color?: string; forecast?: boolean }
|
|
9
|
-
export type MeterZone = {
|
|
9
|
+
export type MeterZone = {
|
|
10
|
+
from: number
|
|
11
|
+
to: number
|
|
12
|
+
label: string
|
|
13
|
+
/**
|
|
14
|
+
* A shorter name for a narrow track. The row tries `label`, then `short`, and only then hides the
|
|
15
|
+
* name; the holding zone always shows its full `label`. The described-by text keeps `label`.
|
|
16
|
+
*/
|
|
17
|
+
short?: string
|
|
18
|
+
color?: string
|
|
19
|
+
}
|
|
20
|
+
/** A mark on the track at `at` (in the reading's units). A label is captioned beside it. */
|
|
21
|
+
export type MeterTick = { at: number; label?: string }
|
|
22
|
+
|
|
23
|
+
/** One tick on the track: its percent position and what it says (caption `label`, aria `text`). */
|
|
24
|
+
export type TickMark = { key: string; pct: number; label: string | undefined; text: string }
|
|
10
25
|
|
|
11
26
|
/** A fill on the track, as fractions (0–1) of the span, with the segment it was laid out from. */
|
|
12
27
|
export type Part = {
|
|
@@ -22,8 +37,16 @@ export type Part = {
|
|
|
22
37
|
/** One categorical part's caption: its position key, name, formatted amount and fill colour (`undefined` = neutral). */
|
|
23
38
|
export type PartCaption = { key: string; label: string; text: string; color: string | undefined }
|
|
24
39
|
|
|
25
|
-
/** One zone's name on the
|
|
26
|
-
export type ZoneLabel = {
|
|
40
|
+
/** One zone's name on the label row: its span's centre and width (percent) and whether it holds the reading. */
|
|
41
|
+
export type ZoneLabel = {
|
|
42
|
+
key: string
|
|
43
|
+
label: string
|
|
44
|
+
/** The fallback name, when the zone has one. */
|
|
45
|
+
short?: string
|
|
46
|
+
centrePct: number
|
|
47
|
+
widthPct: number
|
|
48
|
+
holding: boolean
|
|
49
|
+
}
|
|
27
50
|
|
|
28
51
|
/**
|
|
29
52
|
* What the caption row says. `reading`: the formatted reading; `parts`: categorical segments name
|
|
@@ -33,6 +56,31 @@ export type CaptionMode = 'reading' | 'parts' | 'forecast'
|
|
|
33
56
|
|
|
34
57
|
type Format = (value: number) => string
|
|
35
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The ticks that sit on the track, in the order given. A tick outside `[min, max]` (or not a number)
|
|
61
|
+
* is DROPPED, never clamped: a mark pinned to the end would state a position it is not at.
|
|
62
|
+
*/
|
|
63
|
+
export function tickMarks(
|
|
64
|
+
ticks: readonly MeterTick[] | undefined,
|
|
65
|
+
min: number,
|
|
66
|
+
max: number,
|
|
67
|
+
format: Format,
|
|
68
|
+
): TickMark[] {
|
|
69
|
+
const { span } = spanOf(min, max)
|
|
70
|
+
return (ticks ?? []).flatMap((t, i) =>
|
|
71
|
+
Number.isFinite(t.at) && t.at >= min && t.at <= max
|
|
72
|
+
? [
|
|
73
|
+
{
|
|
74
|
+
key: String(i),
|
|
75
|
+
pct: toPct((t.at - min) / span),
|
|
76
|
+
label: t.label,
|
|
77
|
+
text: `${t.label ?? 'Tick'} ${format(t.at)}`,
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
: [],
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
36
84
|
export const isReading = (n: number | null | undefined): n is number =>
|
|
37
85
|
typeof n === 'number' && Number.isFinite(n)
|
|
38
86
|
|
|
@@ -92,18 +140,66 @@ export const LABEL_SUBPIXEL = 0.5
|
|
|
92
140
|
export type LabelBox = { left: number; right: number }
|
|
93
141
|
|
|
94
142
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* Boxes are relative to the row's own start edge.
|
|
143
|
+
* A label on the shared row: its measured box and, for a zone name, the span it must stay inside.
|
|
144
|
+
* The holding zone's name never hides for width: it ignores its span and is shifted into the row.
|
|
98
145
|
*/
|
|
99
|
-
export
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
)
|
|
146
|
+
export type RowLabel = { box: LabelBox; span?: LabelBox; holding?: boolean; short?: LabelBox }
|
|
147
|
+
|
|
148
|
+
/** The placement of the row's labels, index-aligned with the input. */
|
|
149
|
+
export type RowPlacement = {
|
|
150
|
+
shown: boolean[]
|
|
151
|
+
/** Index-aligned with `shown`: the label shows as its `short` box rather than the full one. */
|
|
152
|
+
short: boolean[]
|
|
153
|
+
/** Pixels a shown label moves along the row's physical x axis to stay inside it (0 unless clamped). */
|
|
154
|
+
shift: number[]
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Which labels of the row show, in input order. The holding zone's name claims its place first (it
|
|
159
|
+
* is the reading's verdict, so it never hides for width: it may spill past its span, shifted inside
|
|
160
|
+
* the row); the labels without a span (the end ticks) go next; every other zone name then shows only
|
|
161
|
+
* when it lies inside the row and its own span and clears every label already kept, trying its full
|
|
162
|
+
* name and then its `short` box. A hidden name is still named in the described-by text.
|
|
163
|
+
*/
|
|
164
|
+
export function placeRowLabels(labels: readonly RowLabel[], rowWidth: number): RowPlacement {
|
|
165
|
+
const shown = labels.map(() => false)
|
|
166
|
+
const short = labels.map(() => false)
|
|
167
|
+
const shift = labels.map(() => 0)
|
|
168
|
+
const kept: LabelBox[] = []
|
|
169
|
+
const rank = (l: RowLabel) => (l.holding ? 0 : l.span ? 2 : 1)
|
|
170
|
+
const order = labels
|
|
171
|
+
.map((_, i) => i)
|
|
172
|
+
.toSorted((a, b) => rank(labels[a] as RowLabel) - rank(labels[b] as RowLabel))
|
|
173
|
+
const clears = (b: LabelBox) =>
|
|
174
|
+
!kept.some((k) => b.left < k.right - LABEL_SUBPIXEL && k.left < b.right - LABEL_SUBPIXEL)
|
|
175
|
+
for (const i of order) {
|
|
176
|
+
const label = labels[i] as RowLabel
|
|
177
|
+
const { span } = label
|
|
178
|
+
let box = label.box
|
|
179
|
+
if (label.holding) {
|
|
180
|
+
const width = box.right - box.left
|
|
181
|
+
const left = Math.max(0, Math.min(box.left, rowWidth - width))
|
|
182
|
+
shift[i] = left - box.left
|
|
183
|
+
box = { left, right: left + width }
|
|
184
|
+
if (!clears(box)) continue
|
|
185
|
+
shown[i] = true
|
|
186
|
+
kept.push(box)
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
const fits = (b: LabelBox) =>
|
|
190
|
+
b.left >= -LABEL_SUBPIXEL &&
|
|
191
|
+
b.right <= rowWidth + LABEL_SUBPIXEL &&
|
|
192
|
+
(span === undefined ||
|
|
193
|
+
(b.left >= span.left - LABEL_SUBPIXEL && b.right <= span.right + LABEL_SUBPIXEL)) &&
|
|
194
|
+
clears(b)
|
|
195
|
+
const useShort = !fits(box) && label.short !== undefined && fits(label.short)
|
|
196
|
+
if (useShort) box = label.short as LabelBox
|
|
197
|
+
else if (!fits(box)) continue
|
|
198
|
+
shown[i] = true
|
|
199
|
+
short[i] = useShort
|
|
200
|
+
kept.push(box)
|
|
201
|
+
}
|
|
202
|
+
return { shown, short, shift }
|
|
107
203
|
}
|
|
108
204
|
|
|
109
205
|
/** A zone band as left edge + width in percent, clipped to the track. */
|
|
@@ -124,6 +220,7 @@ export type BarInput = {
|
|
|
124
220
|
segments?: readonly MeterSegment[] | undefined
|
|
125
221
|
zones?: readonly MeterZone[] | undefined
|
|
126
222
|
target?: number | undefined
|
|
223
|
+
ticks?: readonly MeterTick[] | undefined
|
|
127
224
|
color?: string | undefined
|
|
128
225
|
forecastCaption?: string | undefined
|
|
129
226
|
}
|
|
@@ -140,6 +237,7 @@ export type BarModel = {
|
|
|
140
237
|
partCaptions: readonly PartCaption[]
|
|
141
238
|
/** Only on a zoned track: every zone's name, in zone order. Empty otherwise. */
|
|
142
239
|
zoneLabels: readonly ZoneLabel[]
|
|
240
|
+
ticks: readonly TickMark[]
|
|
143
241
|
markerPct: number | undefined
|
|
144
242
|
targetPct: number | undefined
|
|
145
243
|
/** The default start caption (the zone is named on the band, so it is the bare reading); `startCaption` decides whether it shows. */
|
|
@@ -197,6 +295,7 @@ export function startCaptionText(model: BarModel, override: ReactNode | undefine
|
|
|
197
295
|
|
|
198
296
|
export function modelBar(input: BarInput): BarModel {
|
|
199
297
|
const { reading, min, max, format, segments, zones, target } = input
|
|
298
|
+
const ticks = tickMarks(input.ticks, min, max, format)
|
|
200
299
|
const { span } = spanOf(min, max)
|
|
201
300
|
const zoned = zones !== undefined && zones.length > 0
|
|
202
301
|
const holding = zoned ? findHoldingZone(zones, reading) : undefined
|
|
@@ -221,6 +320,7 @@ export function modelBar(input: BarInput): BarModel {
|
|
|
221
320
|
...(segments?.map((s) => segmentText(s, format)) ?? []),
|
|
222
321
|
...zoneText,
|
|
223
322
|
...(target === undefined ? [] : [`Target ${format(target)}`]),
|
|
323
|
+
...ticks.map((t) => t.text),
|
|
224
324
|
]
|
|
225
325
|
|
|
226
326
|
return {
|
|
@@ -235,12 +335,18 @@ export function modelBar(input: BarInput): BarModel {
|
|
|
235
335
|
partCaptions,
|
|
236
336
|
zoneLabels: !zoned
|
|
237
337
|
? []
|
|
238
|
-
: zones.map((z, i) =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
338
|
+
: zones.map((z, i) => {
|
|
339
|
+
const band = zoneBand(z, min, span)
|
|
340
|
+
return {
|
|
341
|
+
key: String(i),
|
|
342
|
+
label: z.label,
|
|
343
|
+
...(z.short !== undefined && { short: z.short }),
|
|
344
|
+
centrePct: band.start + band.width / 2,
|
|
345
|
+
widthPct: band.width,
|
|
346
|
+
holding: z === holding,
|
|
347
|
+
}
|
|
348
|
+
}),
|
|
349
|
+
ticks,
|
|
244
350
|
markerPct: zoned ? toPct((reading - min) / span) : undefined,
|
|
245
351
|
targetPct: target === undefined ? undefined : toPct((target - min) / span),
|
|
246
352
|
startText: format(reading),
|