basalt-ui 2.19.0 → 2.20.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 +50 -0
- package/MIGRATING.md +174 -12
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +33 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +28 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +33 -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.map +1 -1
- package/dist/charts/state.js +32 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- 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 +15 -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 +19 -0
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +18 -1
- 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 +114 -74
- package/dist/dashboard/meter.d.ts +22 -1
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +4 -1
- package/dist/dashboard/meter.module.css +90 -12
- package/dist/dashboard/meter.module.css.d.ts +5 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +14 -9
- 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 +3 -6
- 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 +50 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +85 -0
- package/dist/dashboard/stat-strip.module.css +208 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +28 -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 +1 -1
- package/dist/guard/index.js +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/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/controls.module.css +3 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +23 -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/llms.txt +30 -6
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +70 -4
- 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 +44 -4
- package/src/charts/types.ts +6 -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 +86 -18
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +35 -0
- package/src/dashboard/meter-parts.tsx +119 -23
- package/src/dashboard/meter.module.css +90 -12
- package/src/dashboard/meter.module.css.d.ts +5 -0
- package/src/dashboard/meter.tsx +26 -2
- package/src/dashboard/query-state.tsx +28 -19
- 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 +5 -8
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +208 -0
- package/src/dashboard/stat-strip.module.css.d.ts +28 -0
- package/src/dashboard/stat-strip.tsx +183 -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 +1 -1
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +168 -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 +3 -0
- package/src/theme/index.ts +30 -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
|
@@ -12,11 +12,16 @@ import {
|
|
|
12
12
|
zoneBand,
|
|
13
13
|
zoneLabelsFit,
|
|
14
14
|
} from './meter-model'
|
|
15
|
-
import type { MeterSegment, MeterZone, Part, ZoneLabel } from './meter-model'
|
|
15
|
+
import type { MeterSegment, MeterTick, MeterZone, Part, TickMark, ZoneLabel } from './meter-model'
|
|
16
16
|
import classes from './meter.module.css'
|
|
17
17
|
import { toPct } from './scale'
|
|
18
18
|
|
|
19
|
-
export type Shell = {
|
|
19
|
+
export type Shell = {
|
|
20
|
+
className: string | undefined
|
|
21
|
+
style: CSSProperties | undefined
|
|
22
|
+
/** `size="row"`: one text line tall, no caption rows. */
|
|
23
|
+
row: boolean
|
|
24
|
+
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* The one root contract of every Meter state. `data-basalt-meter` is the handle `StatCard` keys its
|
|
@@ -24,7 +29,7 @@ export type Shell = { className: string | undefined; style: CSSProperties | unde
|
|
|
24
29
|
*/
|
|
25
30
|
function rootProps(shell: Shell) {
|
|
26
31
|
return {
|
|
27
|
-
className: cx(classes.root, shell.className),
|
|
32
|
+
className: cx(classes.root, shell.row && classes.row, shell.className),
|
|
28
33
|
style: shell.style,
|
|
29
34
|
'data-basalt-meter': '',
|
|
30
35
|
} as const
|
|
@@ -62,6 +67,22 @@ function RingSvg({ fraction, color }: { fraction?: number; color?: string | unde
|
|
|
62
67
|
)
|
|
63
68
|
}
|
|
64
69
|
|
|
70
|
+
/**
|
|
71
|
+
* A value and its unit stay on one line: a no-break space replaces the space between a digit and a
|
|
72
|
+
* known unit ("24 h", "7 d", "5 min", "40 %"), so a caption never wraps to a lone "d". Any other
|
|
73
|
+
* word ("3 of 7", "250 over") keeps its ordinary space.
|
|
74
|
+
*/
|
|
75
|
+
const UNITS = 'h|d|w|mo|y|s|ms|min|m|km|mi|g|kg|%|€|pts|bpm|AU|kcal|KB|MB|GB|TB'
|
|
76
|
+
const UNIT_AFTER_NUMBER = new RegExp(`(\\d) (?=(?:${UNITS})(?![\\p{L}\\d]))`, 'gu')
|
|
77
|
+
/** The last two words of a caption Meter composes are one unit when the last is short, so no
|
|
78
|
+
* line ends on a lone "budget" or "d". */
|
|
79
|
+
// Ordinary spaces only: an already-glued unit (`7\u00a0d`) counts as one word.
|
|
80
|
+
const SHORT_LAST_WORD = /([^ ]) ([^ ]{1,6})$/u
|
|
81
|
+
const glueUnits = (text: ReactNode): ReactNode =>
|
|
82
|
+
typeof text === 'string' ? text.replace(UNIT_AFTER_NUMBER, '$1\u00a0') : text
|
|
83
|
+
const glue = (text: ReactNode): ReactNode =>
|
|
84
|
+
typeof text === 'string' ? String(glueUnits(text)).replace(SHORT_LAST_WORD, '$1\u00a0$2') : text
|
|
85
|
+
|
|
65
86
|
export function MeterLoading({
|
|
66
87
|
label,
|
|
67
88
|
ring,
|
|
@@ -73,7 +94,7 @@ export function MeterLoading({
|
|
|
73
94
|
}) {
|
|
74
95
|
return (
|
|
75
96
|
<div {...rootProps(shell)} aria-busy="true">
|
|
76
|
-
<VisuallyHidden>{`Loading ${label}`}</VisuallyHidden>
|
|
97
|
+
<VisuallyHidden className={classes.summary}>{`Loading ${label}`}</VisuallyHidden>
|
|
77
98
|
{ring ? (
|
|
78
99
|
<Skeleton className={classes.skeletonRing} circle />
|
|
79
100
|
) : (
|
|
@@ -293,6 +314,54 @@ function ZoneLabels({ labels }: { labels: readonly ZoneLabel[] }) {
|
|
|
293
314
|
)
|
|
294
315
|
}
|
|
295
316
|
|
|
317
|
+
/** Ticks past the middle caption to the left of their mark, so a caption near the end stays on the row. */
|
|
318
|
+
const TICK_LABEL_FLIP_PCT = 50
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Captions the labelled ticks above the track, each hugging its mark. Same fit rule as the zone names:
|
|
322
|
+
* when two would overlap (or one would leave the row) the band hides and the labels wrap as a list in
|
|
323
|
+
* tick order. Decorative: the ticks are in the described-by text.
|
|
324
|
+
*/
|
|
325
|
+
function TickLabels({ ticks }: { ticks: readonly TickMark[] }) {
|
|
326
|
+
const rowRef = useRef<HTMLDivElement>(null)
|
|
327
|
+
const fits = useZoneLabelLayout(rowRef, ticks.map((t) => `${t.label}@${t.pct}`).join('\u0000'))
|
|
328
|
+
return (
|
|
329
|
+
<div className={classes.tickLabels}>
|
|
330
|
+
<div
|
|
331
|
+
ref={rowRef}
|
|
332
|
+
className={classes.tickBand}
|
|
333
|
+
data-meter-tick-band
|
|
334
|
+
data-collapsed={fits ? undefined : ''}
|
|
335
|
+
aria-hidden
|
|
336
|
+
>
|
|
337
|
+
{ticks.map((t) => (
|
|
338
|
+
<span
|
|
339
|
+
key={t.key}
|
|
340
|
+
className={classes.tickLabel}
|
|
341
|
+
data-meter-tick-label=""
|
|
342
|
+
style={
|
|
343
|
+
t.pct > TICK_LABEL_FLIP_PCT
|
|
344
|
+
? { insetInlineEnd: `${100 - t.pct}%` }
|
|
345
|
+
: { insetInlineStart: `${t.pct}%` }
|
|
346
|
+
}
|
|
347
|
+
>
|
|
348
|
+
{t.label}
|
|
349
|
+
</span>
|
|
350
|
+
))}
|
|
351
|
+
</div>
|
|
352
|
+
{!fits && (
|
|
353
|
+
<div className={classes.zoneList} data-meter-tick-list aria-hidden>
|
|
354
|
+
{ticks.map((t) => (
|
|
355
|
+
<span key={t.key} className={classes.zoneListItem}>
|
|
356
|
+
{t.label}
|
|
357
|
+
</span>
|
|
358
|
+
))}
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
</div>
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
|
|
296
365
|
export function MeterBar(props: {
|
|
297
366
|
label: string
|
|
298
367
|
reading: number
|
|
@@ -303,6 +372,8 @@ export function MeterBar(props: {
|
|
|
303
372
|
segments: readonly MeterSegment[] | undefined
|
|
304
373
|
zones: readonly MeterZone[] | undefined
|
|
305
374
|
target: number | undefined
|
|
375
|
+
ticks: readonly MeterTick[] | undefined
|
|
376
|
+
tone: 'muted' | undefined
|
|
306
377
|
forecastCaption: string | undefined
|
|
307
378
|
startCaption: ReactNode
|
|
308
379
|
endCaption: ReactNode
|
|
@@ -311,17 +382,24 @@ export function MeterBar(props: {
|
|
|
311
382
|
const { label, reading, min, max, format, zones, shell } = props
|
|
312
383
|
const describedId = useId()
|
|
313
384
|
const model = modelBar(props)
|
|
314
|
-
const
|
|
315
|
-
const
|
|
385
|
+
const compact = shell.row
|
|
386
|
+
const start = compact ? null : startCaptionText(model, props.startCaption)
|
|
387
|
+
const end = compact ? null : props.endCaption === undefined ? model.endText : props.endCaption
|
|
316
388
|
const anchored = model.markerPct !== undefined && start !== null
|
|
317
|
-
const hasCaptions =
|
|
318
|
-
|
|
389
|
+
const hasCaptions =
|
|
390
|
+
(start !== null && !anchored) || end !== null || (!compact && model.forecastText !== null)
|
|
391
|
+
const hasParts = !compact && model.partCaptions.length > 0
|
|
392
|
+
const tickLabels = compact ? [] : model.ticks.filter((t) => t.label !== undefined)
|
|
319
393
|
const describedBy =
|
|
320
394
|
model.describedByText === null ? {} : ({ 'aria-describedby': describedId } as const)
|
|
321
395
|
|
|
322
396
|
const root = rootProps(shell)
|
|
323
397
|
return (
|
|
324
|
-
<div
|
|
398
|
+
<div
|
|
399
|
+
{...root}
|
|
400
|
+
className={cx(root.className, !compact && model.zoneLabels.length > 0 && classes.zoned)}
|
|
401
|
+
>
|
|
402
|
+
{tickLabels.length > 0 && <TickLabels ticks={tickLabels} />}
|
|
325
403
|
<div
|
|
326
404
|
className={classes.trackBox}
|
|
327
405
|
aria-label={label}
|
|
@@ -343,18 +421,26 @@ export function MeterBar(props: {
|
|
|
343
421
|
key={i}
|
|
344
422
|
className={cx(classes.fill, p.forecast && classes.forecastFill)}
|
|
345
423
|
data-meter-fill={p.forecast ? 'forecast' : 'committed'}
|
|
424
|
+
data-tone={
|
|
425
|
+
props.tone === 'muted' && p.color === undefined && !p.forecast ? 'muted' : undefined
|
|
426
|
+
}
|
|
346
427
|
style={fillStyle(p)}
|
|
347
428
|
/>
|
|
348
429
|
))}
|
|
349
430
|
</div>
|
|
350
431
|
<Tick kind="marker" className={classes.marker} pct={model.markerPct} />
|
|
351
432
|
<Tick kind="boundary" className={classes.boundaryTick} pct={model.boundaryPct} />
|
|
433
|
+
{model.ticks.map((t) => (
|
|
434
|
+
<Tick key={t.key} kind="tick" className={classes.tick} pct={t.pct} />
|
|
435
|
+
))}
|
|
352
436
|
<Tick kind="target" className={classes.tick} pct={model.targetPct} />
|
|
353
437
|
</div>
|
|
354
|
-
{model.zoneLabels.length > 0 && <ZoneLabels labels={model.zoneLabels} />}
|
|
438
|
+
{!compact && model.zoneLabels.length > 0 && <ZoneLabels labels={model.zoneLabels} />}
|
|
355
439
|
{anchored && <ZoneReading pct={model.markerPct ?? 0}>{start}</ZoneReading>}
|
|
356
440
|
{model.describedByText !== null && (
|
|
357
|
-
<VisuallyHidden id={describedId}
|
|
441
|
+
<VisuallyHidden id={describedId} className={classes.summary}>
|
|
442
|
+
{model.describedByText}
|
|
443
|
+
</VisuallyHidden>
|
|
358
444
|
)}
|
|
359
445
|
{hasParts && (
|
|
360
446
|
// The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
@@ -368,40 +454,50 @@ export function MeterBar(props: {
|
|
|
368
454
|
style={{ background: c.color ?? 'var(--vx-line)' }}
|
|
369
455
|
aria-hidden
|
|
370
456
|
/>
|
|
371
|
-
{c.label} {c.text}
|
|
457
|
+
{glueUnits(`${c.label} ${c.text}`)}
|
|
372
458
|
</li>
|
|
373
459
|
))}
|
|
374
460
|
</ul>
|
|
375
461
|
)}
|
|
376
462
|
{hasCaptions && (
|
|
377
463
|
<div className={classes.captions} data-meter-captions>
|
|
378
|
-
{start !== null && !anchored && <span className={classes.caption}>{start}</span>}
|
|
379
|
-
{model.forecastText !== null && (
|
|
380
|
-
<span className={classes.caption}>{model.forecastText}</span>
|
|
464
|
+
{start !== null && !anchored && <span className={classes.caption}>{glue(start)}</span>}
|
|
465
|
+
{!compact && model.forecastText !== null && (
|
|
466
|
+
<span className={classes.caption}>{glue(model.forecastText)}</span>
|
|
381
467
|
)}
|
|
382
|
-
{end !== null && <span className={classes.captionEnd}>{end}</span>}
|
|
468
|
+
{end !== null && <span className={classes.captionEnd}>{glue(end)}</span>}
|
|
383
469
|
</div>
|
|
384
470
|
)}
|
|
385
471
|
</div>
|
|
386
472
|
)
|
|
387
473
|
}
|
|
388
474
|
|
|
475
|
+
/** A tick's width: the end tick's start edge sits this far inside the track. */
|
|
476
|
+
const TICK_WIDTH = '2px'
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Centred on its percent. A target or tick AT the track end is the exception: centred there it is
|
|
480
|
+
* half outside the track (and hidden by a full fill), so its end edge sits ON the track end and it
|
|
481
|
+
* reads inside. The marker is the reading itself and stays centred.
|
|
482
|
+
*/
|
|
483
|
+
function tickPosition(kind: TickKind, pct: number): CSSProperties {
|
|
484
|
+
if (pct < 100 || kind === 'marker' || kind === 'boundary') return { insetInlineStart: `${pct}%` }
|
|
485
|
+
return { insetInlineStart: `calc(100% - ${TICK_WIDTH})`, marginInlineStart: 0 }
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
type TickKind = 'marker' | 'boundary' | 'target' | 'tick'
|
|
489
|
+
|
|
389
490
|
function Tick({
|
|
390
491
|
kind,
|
|
391
492
|
className,
|
|
392
493
|
pct,
|
|
393
494
|
}: {
|
|
394
|
-
kind:
|
|
495
|
+
kind: TickKind
|
|
395
496
|
className: string
|
|
396
497
|
pct: number | undefined
|
|
397
498
|
}) {
|
|
398
499
|
if (pct === undefined) return null
|
|
399
500
|
return (
|
|
400
|
-
<div
|
|
401
|
-
className={className}
|
|
402
|
-
data-meter-tick={kind}
|
|
403
|
-
style={{ insetInlineStart: `${pct}%` }}
|
|
404
|
-
aria-hidden
|
|
405
|
-
/>
|
|
501
|
+
<div className={className} data-meter-tick={kind} style={tickPosition(kind, pct)} aria-hidden />
|
|
406
502
|
)
|
|
407
503
|
}
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
flex-direction: column;
|
|
10
10
|
gap: var(--vx-space-stack-xs, 0.25rem);
|
|
11
11
|
min-width: 0;
|
|
12
|
+
/* The ONE caption size: every caption below reads it. A host that wants captions at its own text
|
|
13
|
+
* size sets `--basalt-meter-caption: 1em` on the Meter. */
|
|
14
|
+
--basalt-meter-caption: var(--vx-text-micro);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
.root.zoned {
|
|
@@ -35,6 +38,14 @@
|
|
|
35
38
|
background: var(--vx-line);
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
/*
|
|
42
|
+
* A non-verdict reading: --vx-muted at 65%. 35% (argo's alpha) measures 1.7:1 (light) / 2.4:1 (dark)
|
|
43
|
+
* against the track; 65% clears 3:1 in both, and is not the near-white of --vx-line in dark.
|
|
44
|
+
*/
|
|
45
|
+
.fill[data-tone='muted'] {
|
|
46
|
+
background: color-mix(in srgb, var(--vx-muted) 65%, transparent);
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
/* The committed/forecast pair: the same neutral at two strengths. Flat, never hatched. */
|
|
39
50
|
.forecastFill {
|
|
40
51
|
background: color-mix(in srgb, var(--vx-line) 45%, transparent);
|
|
@@ -54,8 +65,9 @@
|
|
|
54
65
|
position: relative;
|
|
55
66
|
/* Labels are absolutely placed, so the row needs its own line height. */
|
|
56
67
|
height: 1.25em;
|
|
57
|
-
font-family: var(--basalt-font-
|
|
58
|
-
font-
|
|
68
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
69
|
+
font-variant-numeric: lining-nums;
|
|
70
|
+
font-size: var(--basalt-meter-caption);
|
|
59
71
|
color: var(--vx-muted);
|
|
60
72
|
}
|
|
61
73
|
|
|
@@ -86,8 +98,9 @@
|
|
|
86
98
|
display: flex;
|
|
87
99
|
flex-wrap: wrap;
|
|
88
100
|
gap: var(--vx-space-stack-xs) var(--vx-space-stack-sm);
|
|
89
|
-
font-family: var(--basalt-font-
|
|
90
|
-
font-
|
|
101
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
102
|
+
font-variant-numeric: lining-nums;
|
|
103
|
+
font-size: var(--basalt-meter-caption);
|
|
91
104
|
color: var(--vx-muted);
|
|
92
105
|
}
|
|
93
106
|
|
|
@@ -102,8 +115,9 @@
|
|
|
102
115
|
position: relative;
|
|
103
116
|
height: 1.25em;
|
|
104
117
|
overflow: clip;
|
|
105
|
-
font-family: var(--basalt-font-
|
|
106
|
-
font-
|
|
118
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
119
|
+
font-variant-numeric: lining-nums;
|
|
120
|
+
font-size: var(--basalt-meter-caption);
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
.zoneReadingRow:dir(rtl) {
|
|
@@ -144,6 +158,8 @@
|
|
|
144
158
|
margin-inline-start: -1px;
|
|
145
159
|
border-radius: var(--vx-radius-fine);
|
|
146
160
|
background: var(--vx-ink);
|
|
161
|
+
/* A track-coloured halo keeps an ink tick readable on a fill that is itself near-ink (dark). */
|
|
162
|
+
box-shadow: 0 0 0 1px var(--vx-surface-subtle);
|
|
147
163
|
}
|
|
148
164
|
|
|
149
165
|
.boundaryTick {
|
|
@@ -157,14 +173,17 @@
|
|
|
157
173
|
align-items: baseline;
|
|
158
174
|
justify-content: space-between;
|
|
159
175
|
gap: var(--vx-space-control-gap, 0.375rem);
|
|
160
|
-
font-family: var(--basalt-font-
|
|
161
|
-
font-
|
|
176
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
177
|
+
font-variant-numeric: lining-nums;
|
|
178
|
+
font-size: var(--basalt-meter-caption);
|
|
179
|
+
text-wrap: balance;
|
|
162
180
|
color: var(--vx-muted);
|
|
163
181
|
}
|
|
164
182
|
|
|
165
183
|
/* Captions never truncate: the row wraps, and a caption wider than the row wraps inside itself. */
|
|
166
184
|
.caption {
|
|
167
185
|
min-width: 0;
|
|
186
|
+
text-wrap: balance;
|
|
168
187
|
overflow-wrap: anywhere;
|
|
169
188
|
}
|
|
170
189
|
|
|
@@ -175,6 +194,12 @@
|
|
|
175
194
|
text-align: end;
|
|
176
195
|
}
|
|
177
196
|
|
|
197
|
+
/* The visually-hidden summary and loading text are still text: they read the caption size, not the
|
|
198
|
+
* body size they would inherit. */
|
|
199
|
+
.root .summary {
|
|
200
|
+
font-size: var(--basalt-meter-caption);
|
|
201
|
+
}
|
|
202
|
+
|
|
178
203
|
/* Categorical segments: one caption per part under the track, wrapping at narrow widths. */
|
|
179
204
|
.partCaptions {
|
|
180
205
|
display: flex;
|
|
@@ -183,8 +208,10 @@
|
|
|
183
208
|
margin: 0;
|
|
184
209
|
padding: 0;
|
|
185
210
|
list-style: none;
|
|
186
|
-
font-family: var(--basalt-font-
|
|
187
|
-
font-
|
|
211
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
212
|
+
font-variant-numeric: lining-nums;
|
|
213
|
+
font-size: var(--basalt-meter-caption);
|
|
214
|
+
text-wrap: balance;
|
|
188
215
|
color: var(--vx-muted);
|
|
189
216
|
}
|
|
190
217
|
|
|
@@ -205,7 +232,7 @@
|
|
|
205
232
|
}
|
|
206
233
|
|
|
207
234
|
.empty {
|
|
208
|
-
font-size: var(--
|
|
235
|
+
font-size: var(--basalt-meter-caption);
|
|
209
236
|
color: var(--vx-muted);
|
|
210
237
|
}
|
|
211
238
|
|
|
@@ -256,7 +283,8 @@
|
|
|
256
283
|
|
|
257
284
|
.ringValue {
|
|
258
285
|
position: relative;
|
|
259
|
-
font-family: var(--basalt-font-
|
|
286
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
287
|
+
font-variant-numeric: lining-nums;
|
|
260
288
|
font-size: var(--vx-text-kpi);
|
|
261
289
|
font-weight: 500;
|
|
262
290
|
color: var(--vx-ink);
|
|
@@ -266,3 +294,53 @@
|
|
|
266
294
|
width: 5rem;
|
|
267
295
|
height: 5rem;
|
|
268
296
|
}
|
|
297
|
+
|
|
298
|
+
/* ── tick captions ───────────────────────────────────────────────────────────────────────────── */
|
|
299
|
+
|
|
300
|
+
/* Above the track, so they never share a row with the zone names or the captions below it. */
|
|
301
|
+
.tickLabels {
|
|
302
|
+
position: relative;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.tickBand {
|
|
306
|
+
position: relative;
|
|
307
|
+
height: 1.25em;
|
|
308
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
309
|
+
font-variant-numeric: lining-nums;
|
|
310
|
+
font-size: var(--basalt-meter-caption);
|
|
311
|
+
color: var(--vx-muted);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* Hidden but laid out, so a resize can measure it again. */
|
|
315
|
+
.tickBand[data-collapsed] {
|
|
316
|
+
position: absolute;
|
|
317
|
+
top: 0;
|
|
318
|
+
inset-inline: 0;
|
|
319
|
+
visibility: hidden;
|
|
320
|
+
pointer-events: none;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.tickLabel {
|
|
324
|
+
position: absolute;
|
|
325
|
+
top: 0;
|
|
326
|
+
white-space: nowrap;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* ── size="row" ──────────────────────────────────────────────────────────────────────────────── */
|
|
330
|
+
|
|
331
|
+
.row {
|
|
332
|
+
gap: 0;
|
|
333
|
+
justify-content: center;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.row .track {
|
|
337
|
+
height: 1lh;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.row .skeletonTrack {
|
|
341
|
+
height: 1lh;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.row .skeletonCaption {
|
|
345
|
+
display: none;
|
|
346
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare const classes: {
|
|
6
6
|
readonly root: string
|
|
7
|
+
readonly summary: string
|
|
7
8
|
readonly zoned: string
|
|
8
9
|
readonly track: string
|
|
9
10
|
readonly trackBox: string
|
|
@@ -35,5 +36,9 @@ declare const classes: {
|
|
|
35
36
|
readonly ringArc: string
|
|
36
37
|
readonly ringValue: string
|
|
37
38
|
readonly skeletonRing: string
|
|
39
|
+
readonly tickLabels: string
|
|
40
|
+
readonly tickBand: string
|
|
41
|
+
readonly tickLabel: string
|
|
42
|
+
readonly row: string
|
|
38
43
|
}
|
|
39
44
|
export default classes
|
package/src/dashboard/meter.tsx
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
import type { ReactNode } from 'react'
|
|
54
54
|
import type { BasaltProps } from '../common/props'
|
|
55
55
|
import { isReading, normalizeSegments, segmentReading, spanOf } from './meter-model'
|
|
56
|
-
import type { MeterSegment, MeterZone } from './meter-model'
|
|
56
|
+
import type { MeterSegment, MeterTick, MeterZone } from './meter-model'
|
|
57
57
|
import { MeterBar, MeterEmpty, MeterLoading, MeterRing } from './meter-parts'
|
|
58
58
|
import { asText } from './scale'
|
|
59
59
|
|
|
@@ -76,6 +76,24 @@ type BarCommon = Common & {
|
|
|
76
76
|
shape?: 'bar'
|
|
77
77
|
/** Target position; draws a tick and states it in the end caption (with the overage past it). */
|
|
78
78
|
target?: number
|
|
79
|
+
/**
|
|
80
|
+
* More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
|
|
81
|
+
* above the track, wrapping to a list when two collide. A tick outside `[min, max]` is dropped, not
|
|
82
|
+
* clamped. All are listed in the accessible description. Works with `value`, `zones`, `segments`
|
|
83
|
+
* and `target`.
|
|
84
|
+
*/
|
|
85
|
+
ticks?: readonly MeterTick[]
|
|
86
|
+
/**
|
|
87
|
+
* `'muted'`: a non-verdict fill (a load, not a verdict) in `--vx-muted` at a strength that holds
|
|
88
|
+
* 3:1 against the track in both schemes — the neutral fill is near-white in dark. A `color` wins.
|
|
89
|
+
*/
|
|
90
|
+
tone?: 'muted'
|
|
91
|
+
/**
|
|
92
|
+
* `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
|
|
93
|
+
* part, zone and tick captions). The label stays as `aria-label`; the described-by text keeps the
|
|
94
|
+
* rest. Put the value beside it in your own layout.
|
|
95
|
+
*/
|
|
96
|
+
size?: 'row'
|
|
79
97
|
/** Start caption (default: the formatted reading). `null` drops it. */
|
|
80
98
|
startCaption?: ReactNode
|
|
81
99
|
/** End caption (default: `Target <target>`). `null` drops it. */
|
|
@@ -125,6 +143,9 @@ export type MeterProps =
|
|
|
125
143
|
segments?: never
|
|
126
144
|
zones?: never
|
|
127
145
|
target?: never
|
|
146
|
+
ticks?: never
|
|
147
|
+
tone?: never
|
|
148
|
+
size?: never
|
|
128
149
|
startCaption?: never
|
|
129
150
|
endCaption?: never
|
|
130
151
|
})
|
|
@@ -141,7 +162,8 @@ function warnInvalidTrack(min: number, max: number) {
|
|
|
141
162
|
|
|
142
163
|
export function Meter(props: MeterProps) {
|
|
143
164
|
const { label, min = 0, max = 100, format = asText, className, style } = props
|
|
144
|
-
const
|
|
165
|
+
const row = props.size === 'row'
|
|
166
|
+
const shell = { className, style, row }
|
|
145
167
|
const ring = props.shape === 'ring'
|
|
146
168
|
warnInvalidTrack(min, max)
|
|
147
169
|
|
|
@@ -165,6 +187,8 @@ export function Meter(props: MeterProps) {
|
|
|
165
187
|
segments={segments}
|
|
166
188
|
zones={props.zones}
|
|
167
189
|
target={isReading(props.target) ? props.target : undefined}
|
|
190
|
+
ticks={props.ticks}
|
|
191
|
+
tone={props.tone}
|
|
168
192
|
forecastCaption={props.segments === undefined ? undefined : props.forecastCaption}
|
|
169
193
|
startCaption={props.startCaption}
|
|
170
194
|
endCaption={props.endCaption}
|
|
@@ -14,11 +14,13 @@
|
|
|
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 { Button, 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
21
|
import type { BasaltProps, SlotStylesProps } from '../common/props'
|
|
22
|
+
import { VX } from '../tokens'
|
|
23
|
+
import { StatusDot } from '../theme/status-dot'
|
|
22
24
|
import { EmptyState } from './empty-state'
|
|
23
25
|
import { assertQueryStateLike } from '../common/query-state-like'
|
|
24
26
|
import type { QueryStateLike } from '../common/query-state-like'
|
|
@@ -126,28 +128,35 @@ export function ErrorState({
|
|
|
126
128
|
style,
|
|
127
129
|
}: ErrorStateProps): ReactNode {
|
|
128
130
|
const resolved = tier ?? 'page'
|
|
131
|
+
// D28: a status dot + a word + the message + the retry, on the neutral surface — never a
|
|
132
|
+
// red-tinted filled panel (SPEC § 6.12).
|
|
129
133
|
const alert = (
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
title={title}
|
|
134
|
+
<Stack
|
|
135
|
+
gap="xs"
|
|
136
|
+
role="alert"
|
|
134
137
|
{...(resolved === 'section' && className !== undefined && { className })}
|
|
135
138
|
{...(resolved === 'section' && style !== undefined && { style })}
|
|
136
139
|
>
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
<Group gap="xs" wrap="nowrap">
|
|
141
|
+
<StatusDot color={VX.status.bad} />
|
|
142
|
+
<Text size="sm" fw={500}>
|
|
143
|
+
{title}
|
|
144
|
+
</Text>
|
|
145
|
+
</Group>
|
|
146
|
+
<Text size="sm" c="dimmed">
|
|
147
|
+
{toErrorMessage(error, fallback)}
|
|
148
|
+
</Text>
|
|
149
|
+
{(onRetry ?? action) !== undefined && (
|
|
150
|
+
<Group gap="xs">
|
|
151
|
+
{onRetry && (
|
|
152
|
+
<Button size="xs" variant="default" loading={retrying} onClick={onRetry}>
|
|
153
|
+
Retry
|
|
154
|
+
</Button>
|
|
155
|
+
)}
|
|
156
|
+
{action}
|
|
157
|
+
</Group>
|
|
158
|
+
)}
|
|
159
|
+
</Stack>
|
|
151
160
|
)
|
|
152
161
|
if (resolved === 'section') return alert
|
|
153
162
|
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>
|