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
|
@@ -4,17 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare const classes: {
|
|
6
6
|
readonly root: string
|
|
7
|
-
readonly
|
|
7
|
+
readonly summary: string
|
|
8
8
|
readonly track: string
|
|
9
9
|
readonly trackBox: string
|
|
10
10
|
readonly fill: string
|
|
11
11
|
readonly forecastFill: string
|
|
12
12
|
readonly zone: string
|
|
13
|
-
readonly
|
|
13
|
+
readonly labelRow: string
|
|
14
|
+
readonly rowLabel: string
|
|
14
15
|
readonly zoneLabel: string
|
|
15
16
|
readonly zoneLabelHolding: string
|
|
16
|
-
readonly zoneList: string
|
|
17
|
-
readonly zoneListItem: string
|
|
18
17
|
readonly zoneReadingRow: string
|
|
19
18
|
readonly zoneReading: string
|
|
20
19
|
readonly marker: string
|
|
@@ -35,5 +34,6 @@ declare const classes: {
|
|
|
35
34
|
readonly ringArc: string
|
|
36
35
|
readonly ringValue: string
|
|
37
36
|
readonly skeletonRing: string
|
|
37
|
+
readonly row: string
|
|
38
38
|
}
|
|
39
39
|
export default classes
|
package/src/dashboard/meter.tsx
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* along is this against a limit"; choose `BarList` for a ranking and a chart for a trend. An HTML/CSS
|
|
5
5
|
* primitive, not a chart kind (no scale, axis or tooltip).
|
|
6
6
|
*
|
|
7
|
-
* Colour law:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Colour law: a plain `value` bar's fill is neutral (`--vx-muted` at a strength that holds 3:1 on
|
|
8
|
+
* the track; `tone="ink"` for full ink); `segments` and `zones` keep their own fills. `color` is
|
|
9
|
+
* for a VERDICT only (over budget, below target) and is a status colour the consumer passes;
|
|
10
|
+
* categorical `segments` take the consumer's series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
|
|
10
11
|
* tick marks the boundary and a caption names the forecast. A value past `max` clamps the fill at the
|
|
11
12
|
* track end; the caption still states the real value.
|
|
12
13
|
*
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
import type { ReactNode } from 'react'
|
|
54
55
|
import type { BasaltProps } from '../common/props'
|
|
55
56
|
import { isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
|
|
56
|
-
import type { MeterSegment, MeterZone } from './meter-model'
|
|
57
|
+
import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
|
|
57
58
|
import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from './meter-parts'
|
|
58
59
|
import { asText } from './scale'
|
|
59
60
|
|
|
@@ -76,6 +77,27 @@ type BarCommon = Common & {
|
|
|
76
77
|
shape?: 'bar'
|
|
77
78
|
/** Target position; draws a tick and states it in the end caption (with the overage past it). */
|
|
78
79
|
target?: number
|
|
80
|
+
/**
|
|
81
|
+
* More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
|
|
82
|
+
* above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends). A
|
|
83
|
+
* caption that would collide with another hides. A tick outside `[min, max]` is dropped, not
|
|
84
|
+
* clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
|
|
85
|
+
* and `target`.
|
|
86
|
+
*/
|
|
87
|
+
ticks?: readonly MeterTick[]
|
|
88
|
+
/**
|
|
89
|
+
* `'muted'` (default for a plain `value` bar; `segments` and `zones` keep their fills): a
|
|
90
|
+
* non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds 3:1 against
|
|
91
|
+
* the track in both schemes — the ink fill is near-white in dark. `'ink'` restores the full-ink
|
|
92
|
+
* `--vx-line` fill. A `color` wins over both.
|
|
93
|
+
*/
|
|
94
|
+
tone?: 'muted' | 'ink'
|
|
95
|
+
/**
|
|
96
|
+
* `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
|
|
97
|
+
* part, zone and tick captions). The label stays as `aria-label`; the described-by text keeps the
|
|
98
|
+
* rest. Put the value beside it in your own layout.
|
|
99
|
+
*/
|
|
100
|
+
size?: 'row'
|
|
79
101
|
/** Start caption (default: the formatted reading). `null` drops it. */
|
|
80
102
|
startCaption?: ReactNode
|
|
81
103
|
/** End caption (default: `Target <target>`). `null` drops it. */
|
|
@@ -125,6 +147,9 @@ export type MeterProps =
|
|
|
125
147
|
segments?: never
|
|
126
148
|
zones?: never
|
|
127
149
|
target?: never
|
|
150
|
+
ticks?: never
|
|
151
|
+
tone?: never
|
|
152
|
+
size?: never
|
|
128
153
|
startCaption?: never
|
|
129
154
|
endCaption?: never
|
|
130
155
|
})
|
|
@@ -139,9 +164,16 @@ function warnInvalidTrack(min: number, max: number) {
|
|
|
139
164
|
)
|
|
140
165
|
}
|
|
141
166
|
|
|
167
|
+
/** Muted is the default for a plain `value` bar only; `segments`/`zones` keep their fills unless asked. */
|
|
168
|
+
function barTone(tone: 'muted' | 'ink' | undefined, plain: boolean): 'muted' | undefined {
|
|
169
|
+
if (tone === 'ink') return undefined
|
|
170
|
+
return tone === 'muted' || plain ? 'muted' : undefined
|
|
171
|
+
}
|
|
172
|
+
|
|
142
173
|
export function Meter(props: MeterProps) {
|
|
143
174
|
const { label, min = 0, max = 100, format = asText, className, style } = props
|
|
144
|
-
const
|
|
175
|
+
const row = props.size === 'row'
|
|
176
|
+
const shell = { className, style, row }
|
|
145
177
|
const ring = props.shape === 'ring'
|
|
146
178
|
warnInvalidTrack(min, max)
|
|
147
179
|
|
|
@@ -165,6 +197,8 @@ export function Meter(props: MeterProps) {
|
|
|
165
197
|
segments={segments}
|
|
166
198
|
zones={props.zones}
|
|
167
199
|
target={isReading(props.target) ? props.target : undefined}
|
|
200
|
+
ticks={props.ticks}
|
|
201
|
+
tone={barTone(props.tone, props.segments === undefined && props.zones === undefined)}
|
|
168
202
|
forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
|
|
169
203
|
startCaption={props.startCaption}
|
|
170
204
|
endCaption={props.endCaption}
|
|
@@ -14,11 +14,14 @@
|
|
|
14
14
|
* the re-derivation this exists to delete. `LoadingState` / `ErrorState` ship alongside as the
|
|
15
15
|
* escape hatch for a page that must place its branches in different DOM positions.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { Center, Group, Loader, Stack, Text } from '@mantine/core'
|
|
18
18
|
import type { CSSProperties, ReactNode } from 'react'
|
|
19
19
|
import { toErrorMessage } from '../common/errors'
|
|
20
20
|
import { cx } from '../common/props'
|
|
21
|
+
import { RetryButton } from '../common/retry-button'
|
|
21
22
|
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
23
|
+
import { VX } from '../tokens'
|
|
24
|
+
import { StatusDot } from '../theme/status-dot'
|
|
22
25
|
import { EmptyState } from './empty-state'
|
|
23
26
|
import { assertQueryStateLike } from '../common/query-state-like'
|
|
24
27
|
import type { QueryStateLike } from '../common/query-state-like'
|
|
@@ -102,7 +105,7 @@ export type ErrorStateProps = BasaltProps & {
|
|
|
102
105
|
/** Shown only when the server body carries no readable message. */
|
|
103
106
|
fallback?: string
|
|
104
107
|
onRetry?: () => void
|
|
105
|
-
/** Disables
|
|
108
|
+
/** Disables the retry button while a refetch is in flight. */
|
|
106
109
|
retrying?: boolean
|
|
107
110
|
/** How loud this state is. Default `'page'`. */
|
|
108
111
|
tier?: QueryStateTier
|
|
@@ -126,28 +129,31 @@ export function ErrorState({
|
|
|
126
129
|
style,
|
|
127
130
|
}: ErrorStateProps): ReactNode {
|
|
128
131
|
const resolved = tier ?? 'page'
|
|
132
|
+
// D28: a status dot + a word + the message + the retry, on the neutral surface — never a
|
|
133
|
+
// red-tinted filled panel (SPEC § 6.12).
|
|
129
134
|
const alert = (
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
title={title}
|
|
135
|
+
<Stack
|
|
136
|
+
gap="xs"
|
|
137
|
+
role="alert"
|
|
134
138
|
{...(resolved === 'section' && className !== undefined && { className })}
|
|
135
139
|
{...(resolved === 'section' && style !== undefined && { style })}
|
|
136
140
|
>
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
141
|
+
<Group gap="xs" wrap="nowrap">
|
|
142
|
+
<StatusDot color={VX.status.bad} />
|
|
143
|
+
<Text size="sm" fw={500}>
|
|
144
|
+
{title}
|
|
145
|
+
</Text>
|
|
146
|
+
</Group>
|
|
147
|
+
<Text size="sm" c="dimmed">
|
|
148
|
+
{toErrorMessage(error, fallback)}
|
|
149
|
+
</Text>
|
|
150
|
+
{(onRetry ?? action) !== undefined && (
|
|
151
|
+
<Group gap="xs">
|
|
152
|
+
{onRetry && <RetryButton onClick={onRetry} retrying={retrying} />}
|
|
153
|
+
{action}
|
|
154
|
+
</Group>
|
|
155
|
+
)}
|
|
156
|
+
</Stack>
|
|
151
157
|
)
|
|
152
158
|
if (resolved === 'section') return alert
|
|
153
159
|
return (
|
|
@@ -79,13 +79,7 @@ export function SettingsSection({
|
|
|
79
79
|
classNames,
|
|
80
80
|
}: SettingsSectionProps) {
|
|
81
81
|
return (
|
|
82
|
-
<Card
|
|
83
|
-
className={cx(classNames?.root, className)}
|
|
84
|
-
style={{
|
|
85
|
-
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
86
|
-
...style,
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
82
|
+
<Card className={cx(classNames?.root, className)} style={style}>
|
|
89
83
|
<div className={cx(classes.header, classNames?.header)}>
|
|
90
84
|
<WidgetHeader
|
|
91
85
|
tier="section"
|
|
@@ -158,7 +152,6 @@ export function DangerZone({
|
|
|
158
152
|
<Card
|
|
159
153
|
className={cx(classNames?.root, className)}
|
|
160
154
|
style={{
|
|
161
|
-
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
162
155
|
boxShadow: `${VX.shadowCard}, 0 0 0 1px ${alpha(VX.status.bad, 0.25)}`,
|
|
163
156
|
...style,
|
|
164
157
|
}}
|
|
@@ -41,7 +41,7 @@ export function CaptionRow({ title, icon, info, qualifier, tone, actions }: Capt
|
|
|
41
41
|
<div className={classes.lead}>
|
|
42
42
|
<h3 className={classes.caption}>
|
|
43
43
|
{icon !== undefined && <IconSlot className={classes.icon}>{icon}</IconSlot>}
|
|
44
|
-
<span className={classes.captionText} data-widget-title>
|
|
44
|
+
<span className={classes.captionText} title={title} data-widget-title>
|
|
45
45
|
{title}
|
|
46
46
|
</span>
|
|
47
47
|
</h3>
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
--basalt-stat-visual-h: 1.375rem;
|
|
13
13
|
--basalt-stat-footer-h: 1.25rem;
|
|
14
14
|
--basalt-stat-foot-gap: 0.25rem;
|
|
15
|
+
/* The line a Sparkline's hover readout takes above its plot (`charts/sparkline.module.css` reads
|
|
16
|
+
* it too). A slot that cannot spare it reserves it as padding, so the chip never covers the hero. */
|
|
17
|
+
--basalt-spark-readout-h: 1.125rem;
|
|
15
18
|
/* The figure's size and line box, in one place: `.value`, the empty line and the pending skeleton
|
|
16
19
|
* all read them, so nothing moves when a reading lands. */
|
|
17
20
|
--basalt-stat-figure-size: var(--vx-text-kpi);
|
|
@@ -86,7 +89,6 @@
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
.qualifier {
|
|
89
|
-
font-family: var(--basalt-font-mono);
|
|
90
92
|
font-size: var(--vx-text-micro);
|
|
91
93
|
color: var(--vx-muted);
|
|
92
94
|
/* Wraps before it is ever cut: a qualifier too long for the row on its own line breaks its words. */
|
|
@@ -128,7 +130,8 @@
|
|
|
128
130
|
.value {
|
|
129
131
|
min-width: 0;
|
|
130
132
|
overflow-wrap: anywhere;
|
|
131
|
-
font-family: var(--basalt-font-
|
|
133
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
134
|
+
font-variant-numeric: lining-nums;
|
|
132
135
|
font-size: var(--basalt-stat-figure-size);
|
|
133
136
|
line-height: var(--basalt-stat-figure-line);
|
|
134
137
|
font-weight: 500;
|
|
@@ -136,11 +139,12 @@
|
|
|
136
139
|
color: var(--vx-ink);
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
/*
|
|
142
|
+
/* Sans like the number it qualifies, `sm` and muted: the SMALL half of the pair. Never shrinks — a
|
|
140
143
|
* unit clipped to `TS…` would state nothing. */
|
|
141
144
|
.unit {
|
|
142
145
|
flex-shrink: 0;
|
|
143
|
-
font-family: var(--basalt-font-
|
|
146
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
147
|
+
font-variant-numeric: lining-nums;
|
|
144
148
|
font-size: var(--vx-text-sm);
|
|
145
149
|
font-weight: 500;
|
|
146
150
|
color: var(--vx-muted);
|
|
@@ -306,12 +310,13 @@
|
|
|
306
310
|
color: var(--vx-muted);
|
|
307
311
|
}
|
|
308
312
|
|
|
309
|
-
/*
|
|
313
|
+
/* Sans and ink — a breakdown value is a number, and it is the half of the row worth reading. Never
|
|
310
314
|
* shrinks: the LABEL is the prose half and the one that may ellipsize. */
|
|
311
315
|
.breakdownValue {
|
|
312
316
|
flex-shrink: 0;
|
|
313
317
|
margin: 0;
|
|
314
|
-
font-family: var(--basalt-font-
|
|
318
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
319
|
+
font-variant-numeric: lining-nums;
|
|
315
320
|
font-size: var(--vx-text-sm);
|
|
316
321
|
font-weight: 500;
|
|
317
322
|
color: var(--vx-ink);
|
|
@@ -353,6 +358,7 @@
|
|
|
353
358
|
.sparklineRight:has(> [data-basalt-meter]) {
|
|
354
359
|
flex: 1 1 auto;
|
|
355
360
|
height: auto;
|
|
361
|
+
padding-top: 0;
|
|
356
362
|
overflow: visible;
|
|
357
363
|
align-items: stretch;
|
|
358
364
|
}
|
|
@@ -367,7 +373,9 @@
|
|
|
367
373
|
display: flex;
|
|
368
374
|
flex: 0 1 var(--basalt-stat-sparkline-w, 4.5rem);
|
|
369
375
|
min-width: 0;
|
|
370
|
-
|
|
376
|
+
/* The slot clips, so it holds the Sparkline's readout line inside its own box (padding-top). */
|
|
377
|
+
height: calc(var(--basalt-stat-sparkline-h, 1.375rem) + var(--basalt-spark-readout-h));
|
|
378
|
+
padding-top: var(--basalt-spark-readout-h);
|
|
371
379
|
align-items: flex-end;
|
|
372
380
|
align-self: flex-end;
|
|
373
381
|
overflow: hidden;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 1. the CAPTION row — `title` as a mono uppercase `micro` faint label, the optional `info` glyph,
|
|
6
6
|
* `qualifier` right-aligned (period, target or source; it takes its own line UNDER the caption,
|
|
7
7
|
* left-aligned, when the card is too narrow for both), and the `actions` slot;
|
|
8
|
-
* 2. the VALUE row — the hero figure (`kpi`,
|
|
8
|
+
* 2. the VALUE row — the hero figure (`kpi`, sans 500, lining), `unit` inline at `sm` muted on the same
|
|
9
9
|
* baseline, then the delta (text only — see `DeltaBadge`) and its muted `deltaPeriod`;
|
|
10
10
|
* 3. the FOOT — the `sparkline` visual (22 px, bled to the card's side edges) and one muted `sm`
|
|
11
11
|
* `subtitle` line under it (a source or "as of", never a restatement of the caption).
|
|
@@ -112,6 +112,7 @@ import type { BasaltProps, SlotStylesProps, Tone } from '../common/props'
|
|
|
112
112
|
import { ErrorState, QueryState, resolveQueryBranch } from './query-state'
|
|
113
113
|
import type { QueryBranch, QueryStateLike } from './query-state'
|
|
114
114
|
import classes from './stat-card.module.css'
|
|
115
|
+
import { VisualSlotContext } from './visual-slot'
|
|
115
116
|
|
|
116
117
|
/**
|
|
117
118
|
* The boxes `StatCard` paints, and the whole styling seam it offers (`common/props.ts`).
|
|
@@ -211,7 +212,7 @@ export type StatCardProps = BasaltProps &
|
|
|
211
212
|
Omit<WidgetHeaderTitleProps, 'subtitle'> &
|
|
212
213
|
Omit<WidgetHeaderMetricProps, 'value'> &
|
|
213
214
|
WidgetHeaderDeltaProps & {
|
|
214
|
-
/** Pre-formatted hero figure (
|
|
215
|
+
/** Pre-formatted hero figure (sans `kpi`, weight 500, lining, ink). Required here, unlike on
|
|
215
216
|
* `WidgetHeader`: see the type's own doc. */
|
|
216
217
|
value: string
|
|
217
218
|
/**
|
|
@@ -448,7 +449,9 @@ export function StatCard({
|
|
|
448
449
|
>
|
|
449
450
|
{/* A measured slot renders nothing on the first commit (width 0) — an SVG at width 0 is a
|
|
450
451
|
visible 0-width box that then jumps, which is worse than one frame of nothing. */}
|
|
451
|
-
|
|
452
|
+
<VisualSlotContext.Provider value>
|
|
453
|
+
{isRender ? measured.width > 0 && sparkline(measured) : sparkline}
|
|
454
|
+
</VisualSlotContext.Provider>
|
|
452
455
|
</div>
|
|
453
456
|
)
|
|
454
457
|
|
|
@@ -490,11 +493,9 @@ export function StatCard({
|
|
|
490
493
|
<Card
|
|
491
494
|
className={cx(classNames?.root, className)}
|
|
492
495
|
style={{
|
|
493
|
-
//
|
|
494
|
-
//
|
|
495
|
-
//
|
|
496
|
-
// the responsive half of the ladder lives in `spaceMobileDecls` (`tokens/index.ts`), which
|
|
497
|
-
// is the only home that can reach an inline style like this one.
|
|
496
|
+
// The inset is the theme's (`card-inset.module.css`: the `cardInsetY`/`cardInsetX` tokens, 12/16
|
|
497
|
+
// at level 0, stepping the horizontal one down a rung below `sm`), so it is NOT restated here —
|
|
498
|
+
// an inline copy would bypass `variant="flush"`.
|
|
498
499
|
//
|
|
499
500
|
// `overflow: hidden` clips the full-bleed sparkline to the card's rounded corners. An
|
|
500
501
|
// element's own `box-shadow` renders outside its border box and is NOT clipped by its own
|
|
@@ -502,7 +503,6 @@ export function StatCard({
|
|
|
502
503
|
//
|
|
503
504
|
// NO `minHeight`: the content states the height (the foot reserves its own), and cards in a
|
|
504
505
|
// grid row stretch to the tallest.
|
|
505
|
-
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
506
506
|
overflow: 'hidden',
|
|
507
507
|
// Consumers may anchor overlays (badges, menus) to the card, so it stays a positioned box.
|
|
508
508
|
position: 'relative',
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* rule on the GROUP, so the cells stay whatever they are; on `StatCard`s (which carry their own
|
|
22
22
|
* panel and shadow ring) the rail reads as a second frame, so pair it with unadorned children.
|
|
23
23
|
*
|
|
24
|
+
* `variant="strip"` is the joined-surface form with typed cells and a footer row (`stat-strip.tsx`).
|
|
25
|
+
*
|
|
24
26
|
* @example
|
|
25
27
|
* import { StatCard, StatGroup } from 'basalt-ui'
|
|
26
28
|
*
|
|
@@ -33,12 +35,15 @@
|
|
|
33
35
|
import type { CSSProperties, ReactNode } from 'react'
|
|
34
36
|
import { cx } from '../common/props'
|
|
35
37
|
import type { BasaltProps } from '../common/props'
|
|
38
|
+
import { StatStrip } from './stat-strip'
|
|
39
|
+
import type { StatStripProps } from './stat-strip'
|
|
36
40
|
import classes from './stat-group.module.css'
|
|
37
41
|
|
|
38
42
|
/** The desktop KPI column count. */
|
|
39
43
|
export type StatGroupCols = 2 | 3 | 4 | 5
|
|
40
44
|
|
|
41
|
-
export type
|
|
45
|
+
export type StatGridProps = BasaltProps & {
|
|
46
|
+
variant?: 'grid'
|
|
42
47
|
/** The DESKTOP column count (`lg` and up). Default `4`. `sm` gets `min(cols, 3)` — except `4`, which gets 2 rather than an orphan row. A phone gets 2.
|
|
43
48
|
* Never a responsive object — the law is basalt's, see the module docblock. */
|
|
44
49
|
cols?: StatGroupCols
|
|
@@ -48,13 +53,19 @@ export type StatGroupProps = BasaltProps & {
|
|
|
48
53
|
children: ReactNode
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/** `variant="strip"`: one joined surface of typed `cells` split by hairlines, plus an optional
|
|
57
|
+
* `footer` row — see `StatStripProps`. `cols` here may be 6 (the strip's desktop count). */
|
|
58
|
+
export type StatGroupProps = StatGridProps | ({ variant: 'strip' } & StatStripProps)
|
|
59
|
+
|
|
60
|
+
export function StatGroup(props: StatGroupProps) {
|
|
61
|
+
if (props.variant === 'strip') {
|
|
62
|
+
const { variant: _variant, ...strip } = props
|
|
63
|
+
return <StatStrip {...strip} />
|
|
64
|
+
}
|
|
65
|
+
return <StatGrid {...props} />
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function StatGrid({ cols = 4, divided = false, children, className, style }: StatGridProps) {
|
|
58
69
|
// `4 -> 2`, not `4 -> 3`. `min(cols, 3)` is the general rule and it is right for 2, 3 and 5, but
|
|
59
70
|
// FOUR is the default and the overwhelmingly common count, and three columns leave a four-KPI row
|
|
60
71
|
// as 3 + 1 — one orphan cell against two thirds of empty track. MEASURED on the playground
|