basalt-ui 2.22.0 → 2.24.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 +68 -0
- package/MIGRATING.md +400 -12
- package/agent/agents/basalt-design-reviewer.md +3 -3
- package/agent/skills/basalt-design/SKILL.md +2 -2
- package/agent/skills/basalt-design/references/catalogue.md +22 -19
- package/agent/skills/basalt-design/references/states.md +39 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +51 -5
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +19 -3
- package/dist/charts/CartesianChart.d.ts +2 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +7 -3
- package/dist/charts/ChartCard.d.ts +1 -1
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +25 -15
- package/dist/charts/Sparkline.d.ts +8 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +95 -15
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +5 -1
- package/dist/charts/band-fold.d.ts +22 -4
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +10 -2
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/chart-legend.module.css +16 -0
- package/dist/charts/compile.d.ts +10 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +77 -24
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +7 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +28 -17
- package/dist/charts/legend.d.ts +0 -6
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +87 -35
- package/dist/charts/ref-label.d.ts +17 -0
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +13 -1
- package/dist/charts/sparkline.module.css +62 -12
- package/dist/charts/sparkline.module.css.d.ts +1 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +4 -2
- package/dist/charts/types.d.ts +15 -3
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +9 -5
- package/dist/cli/shot/detect.js +8 -5
- package/dist/cli/shot/measure.js +19 -23
- package/dist/cli/shot/playwright.d.ts +8 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +2 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- package/dist/dashboard/bar-list.d.ts +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +8 -0
- package/dist/dashboard/bar-list.module.css +18 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +55 -21
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +98 -17
- package/dist/dashboard/meter-parts.d.ts +9 -2
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +99 -21
- package/dist/dashboard/meter.d.ts +21 -8
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +14 -3
- package/dist/dashboard/meter.module.css +57 -2
- package/dist/dashboard/meter.module.css.d.ts +5 -0
- package/dist/dashboard/query-state.d.ts +7 -3
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +15 -7
- package/dist/dashboard/section.d.ts +2 -1
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.module.css +12 -0
- package/dist/dashboard/settings-section.d.ts +1 -1
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +3 -3
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.module.css +43 -10
- package/dist/dashboard/stat-group.module.css +15 -0
- package/dist/dashboard/stat-strip.d.ts +16 -5
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +100 -74
- package/dist/dashboard/stat-strip.module.css +68 -62
- package/dist/dashboard/stat-strip.module.css.d.ts +1 -0
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +19 -1
- package/dist/dashboard/widget-header.module.css +6 -0
- package/dist/guard/index.d.ts +2 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +1 -17
- package/dist/styles.css +18 -11
- package/dist/table/data-table.js +1 -1
- package/dist/theme/controls.module.css +19 -0
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +12 -7
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- package/dist/tokens/palette.d.ts +7 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +7 -10
- package/llms.txt +7 -4
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +55 -5
- package/src/charts/Bars.tsx +31 -3
- package/src/charts/CartesianChart.tsx +9 -3
- package/src/charts/ChartCard.tsx +32 -19
- package/src/charts/Sparkline.tsx +139 -21
- package/src/charts/StackedArea.tsx +12 -1
- package/src/charts/band-fold.ts +25 -6
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/chart-legend.module.css +16 -0
- package/src/charts/compile.ts +148 -25
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +43 -22
- package/src/charts/legend.tsx +70 -3
- package/src/charts/ref-label.ts +27 -0
- package/src/charts/sparkline.module.css +62 -12
- package/src/charts/sparkline.module.css.d.ts +1 -0
- package/src/charts/state.tsx +7 -4
- package/src/charts/types.ts +13 -3
- package/src/cli/shot/capture.ts +15 -3
- package/src/cli/shot/detect.ts +9 -9
- package/src/cli/shot/measure.ts +27 -27
- package/src/cli/shot/playwright.ts +18 -2
- package/src/cli/shot/types.ts +2 -0
- package/src/cli/tokens-css.ts +18 -20
- package/src/dashboard/bar-list.module.css +18 -0
- package/src/dashboard/bar-list.tsx +29 -0
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/empty-state.tsx +4 -2
- package/src/dashboard/meter-model.ts +181 -47
- package/src/dashboard/meter-parts.tsx +187 -30
- package/src/dashboard/meter.module.css +57 -2
- package/src/dashboard/meter.module.css.d.ts +5 -0
- package/src/dashboard/meter.tsx +33 -10
- package/src/dashboard/query-state.tsx +20 -9
- package/src/dashboard/section.module.css +12 -0
- package/src/dashboard/section.tsx +2 -1
- package/src/dashboard/settings-section.tsx +4 -4
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +43 -10
- package/src/dashboard/stat-group.module.css +15 -0
- package/src/dashboard/stat-strip.module.css +68 -62
- package/src/dashboard/stat-strip.module.css.d.ts +1 -0
- package/src/dashboard/stat-strip.tsx +118 -59
- package/src/dashboard/widget-header.module.css +6 -0
- package/src/dashboard/widget-header.tsx +28 -1
- package/src/guard/index.ts +3 -19
- package/src/styles.css +18 -11
- package/src/table/data-table.tsx +1 -1
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +14 -8
- package/src/theme/controls.module.css +19 -0
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +12 -7
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/palette.ts +7 -10
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* The sparkline's hover / focus readout: one quiet chip, never a floating tooltip
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
2
|
+
* The sparkline's hover / focus readout: one quiet chip, never a floating tooltip. Inside a host that
|
|
3
|
+
* reserves a line for it (`StatCard`'s sparkline slot, a strip cell's visual: `data-basalt-hosted`,
|
|
4
|
+
* `--basalt-spark-readout-h`) it sits ABOVE the plot, so it never covers the plotted line, the dashed
|
|
5
|
+
* reference or the dot. A bare `Sparkline` has no such line, so its chip stays inside its own box
|
|
6
|
+
* (placed inline in `Sparkline.tsx`, away from the point). `Sparkline.tsx` slides it with the point
|
|
7
|
+
* (`left` + `translate` by one fraction), which keeps it inside the box at either edge at any width.
|
|
8
|
+
* `--basalt-spark-readout-lift: 0` on a host puts the chip back in the box.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
.root {
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
.readout {
|
|
16
16
|
position: absolute;
|
|
17
|
-
/* The layer is inset from the root by the line's plot margin; lifting by it puts the chip back
|
|
18
|
-
* on the root's top edge, the line a host slot reserves. */
|
|
19
|
-
bottom: calc(100% + var(--basalt-spark-lift, 0px));
|
|
20
17
|
z-index: 1;
|
|
18
|
+
max-height: 100%;
|
|
21
19
|
max-width: 100%;
|
|
22
20
|
box-sizing: border-box;
|
|
23
21
|
padding: 0 4px;
|
|
@@ -25,8 +23,8 @@
|
|
|
25
23
|
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
26
24
|
font-variant-numeric: lining-nums;
|
|
27
25
|
font-size: var(--vx-text-xs);
|
|
28
|
-
/* The
|
|
29
|
-
* value (`stat-card.module.css`, `stat-strip.module.css`)
|
|
26
|
+
/* The chip's height: hosts that reserve a line for it set `--basalt-spark-readout-h` to the same
|
|
27
|
+
* value (`stat-card.module.css`, `stat-strip.module.css`). */
|
|
30
28
|
block-size: var(--basalt-spark-readout-h, 1.125rem);
|
|
31
29
|
line-height: calc(var(--basalt-spark-readout-h, 1.125rem) - 2px);
|
|
32
30
|
color: var(--vx-tooltip-text);
|
|
@@ -38,10 +36,62 @@
|
|
|
38
36
|
border-radius: var(--vx-radius-ctrl);
|
|
39
37
|
}
|
|
40
38
|
|
|
39
|
+
/* The host's reserved line: above the plot. The chip's bottom meets the sparkline's own top edge (the
|
|
40
|
+
* layer sits `--basalt-spark-inset` below it). */
|
|
41
|
+
[data-basalt-hosted] .readout {
|
|
42
|
+
top: calc(
|
|
43
|
+
var(--basalt-spark-readout-lift, 1) * -1 *
|
|
44
|
+
(var(--basalt-spark-readout-h, 1.125rem) + var(--basalt-spark-inset, 0px))
|
|
45
|
+
);
|
|
46
|
+
max-height: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
.label {
|
|
42
50
|
opacity: 0.7;
|
|
43
51
|
}
|
|
44
52
|
|
|
53
|
+
.sep {
|
|
54
|
+
white-space: pre;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* A readout that overflows its box first drops the air round its separator and its padding. */
|
|
58
|
+
.readout[data-tight] {
|
|
59
|
+
padding-inline: 2px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.readout[data-tight] .sep {
|
|
63
|
+
letter-spacing: -0.15em;
|
|
64
|
+
word-spacing: -0.25em;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* A readout that still overflows stacks (set in `Sparkline.tsx`): the date on its own line, wrapped
|
|
68
|
+
* not clipped. It sits INSIDE the plot's top band (the lift-0 placement), hosted or bare: a hosted
|
|
69
|
+
* chip grown past the host's one reserved line would cover the figure's delta or qualifier above. */
|
|
70
|
+
.readout[data-stacked] {
|
|
71
|
+
block-size: auto;
|
|
72
|
+
max-height: none;
|
|
73
|
+
padding-block: 1px;
|
|
74
|
+
line-height: 1.25;
|
|
75
|
+
text-overflow: clip;
|
|
76
|
+
white-space: normal;
|
|
77
|
+
overflow-wrap: break-word;
|
|
78
|
+
/* Not the shrink-to-fit width an absolutely positioned box gets: at a point near the right edge
|
|
79
|
+
* that is the sliver right of `left`, and the date would wrap letter by letter. */
|
|
80
|
+
width: max-content;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[data-basalt-hosted] .readout[data-stacked] {
|
|
84
|
+
top: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.readout[data-stacked] .label {
|
|
88
|
+
display: block;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.readout[data-stacked] .sep {
|
|
92
|
+
display: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
45
95
|
.layer {
|
|
46
96
|
position: absolute;
|
|
47
97
|
pointer-events: none;
|
package/src/charts/state.tsx
CHANGED
|
@@ -53,6 +53,8 @@ const dotStyle: CSSProperties = {
|
|
|
53
53
|
const errorStyle: CSSProperties = {
|
|
54
54
|
...boxStyle,
|
|
55
55
|
alignItems: 'flex-start',
|
|
56
|
+
justifyContent: 'flex-start',
|
|
57
|
+
paddingBottom: VX.space.controlGap,
|
|
56
58
|
textAlign: 'start',
|
|
57
59
|
fontSize: VX.text.sm,
|
|
58
60
|
gap: VX.space.controlGap,
|
|
@@ -68,7 +70,7 @@ const errorHeadStyle: CSSProperties = {
|
|
|
68
70
|
const errorMessageStyle: CSSProperties = { color: VX.muted }
|
|
69
71
|
|
|
70
72
|
const emptyLabel = (state: ChartState | undefined): string =>
|
|
71
|
-
typeof state?.empty === 'string' ? state.empty : '
|
|
73
|
+
typeof state?.empty === 'string' ? state.empty : 'Nothing recorded in this range.'
|
|
72
74
|
|
|
73
75
|
/** Fills the same {@link ChartBox} the chart will, so a pending, failed or empty chart (and a
|
|
74
76
|
* `<Suspense>` fallback built from one) occupies the final chart's height. */
|
|
@@ -90,8 +92,9 @@ export function ChartPlaceholder(props: {
|
|
|
90
92
|
const kind = resolveChartState(props.state)
|
|
91
93
|
if (kind === null) return null
|
|
92
94
|
const style = kind === 'pending' ? pendingStyle : kind === 'error' ? errorStyle : boxStyle
|
|
93
|
-
// An error
|
|
94
|
-
//
|
|
95
|
+
// An error keeps the chart's height as a floor (the frame does not jump, `ssr-contract`) and may
|
|
96
|
+
// grow past it rather than clip its action; its anatomy is top-aligned, so the room is plain
|
|
97
|
+
// card below the content, not a block of text floating mid-card.
|
|
95
98
|
const fit = (node: ReactElement): ReactElement => (
|
|
96
99
|
<ChartBox height={props.height} {...(kind === 'error' && { className: growClass })}>
|
|
97
100
|
{node}
|
|
@@ -103,7 +106,7 @@ export function ChartPlaceholder(props: {
|
|
|
103
106
|
)
|
|
104
107
|
const label =
|
|
105
108
|
kind === 'error'
|
|
106
|
-
? toErrorMessage(props.state?.error, 'The
|
|
109
|
+
? toErrorMessage(props.state?.error, 'The request failed.')
|
|
107
110
|
: emptyLabel(props.state)
|
|
108
111
|
const body = props.compact ? (
|
|
109
112
|
<span aria-hidden="true">—</span>
|
package/src/charts/types.ts
CHANGED
|
@@ -132,6 +132,15 @@ export type ZoneSpec = {
|
|
|
132
132
|
to: number
|
|
133
133
|
fill: string
|
|
134
134
|
axisSide?: 'left' | 'right' | undefined
|
|
135
|
+
/**
|
|
136
|
+
* Names the band in the legend (its fill as the swatch, a bar by default), so a zone chart keeps
|
|
137
|
+
* a key at 390 and needs no always-`null` series. `mark` is the swatch shape. `color` is the
|
|
138
|
+
* swatch when the fill is a whisper-alpha wash a 10px swatch would lose (default: the fill, a
|
|
139
|
+
* status tint mapped to its solid).
|
|
140
|
+
*/
|
|
141
|
+
legend?:
|
|
142
|
+
| { label: string; mark?: 'line' | 'bar' | undefined; color?: string | undefined }
|
|
143
|
+
| undefined
|
|
135
144
|
/** A rule on the band's visual `top` (the larger bound) and/or `bottom` (the smaller), whichever
|
|
136
145
|
* of `from`/`to` that is. */
|
|
137
146
|
edge?: ZoneEdge<'top' | 'bottom'> | undefined
|
|
@@ -199,8 +208,9 @@ export type ChartTooltipRow = {
|
|
|
199
208
|
}
|
|
200
209
|
|
|
201
210
|
export type ChartTooltipConfig<T, X extends ChartX = ChartX> = {
|
|
202
|
-
/** The tooltip title. Default:
|
|
203
|
-
* `
|
|
211
|
+
/** The tooltip title. Default: a Date x reads weekday, day, month and year in the page locale
|
|
212
|
+
* (`Tue 1 Sep 2026`; a non-day instant adds its time) whatever `formatX` shortens the ticks to;
|
|
213
|
+
* any other x goes through `formatX`. */
|
|
204
214
|
formatHeader?: ((x: X, d: T) => string) | undefined
|
|
205
215
|
/** Rows after the per-series rows (a total, a zone badge, a context line). `visible`/`hidden` are
|
|
206
216
|
* the legend's split, so a row never names a series the plot no longer draws. */
|
|
@@ -320,7 +330,7 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
320
330
|
xDomain?: readonly [X, X] | undefined
|
|
321
331
|
/**
|
|
322
332
|
* Tick label for an x value. Default: compact numbers, strings verbatim, and dates by tick step
|
|
323
|
-
* (`HH:MM` with the day on midnight, `
|
|
333
|
+
* (`HH:MM` with the day on midnight, the day (`4 Oct`, in the page locale), a month with the year on January; a label recurs
|
|
324
334
|
* only behind a day or year label).
|
|
325
335
|
*/
|
|
326
336
|
formatX?: ((x: X) => string) | undefined
|
package/src/cli/shot/capture.ts
CHANGED
|
@@ -64,6 +64,8 @@ export type CaptureInput = {
|
|
|
64
64
|
type PageFacts = {
|
|
65
65
|
anchors: string[]
|
|
66
66
|
declared: string[]
|
|
67
|
+
/** Anchors that hold a basalt state surface (ChartCard, StatCard, a chart state). */
|
|
68
|
+
stateful?: string[]
|
|
67
69
|
/** Anchor → the URL states it declares itself absent in (`data-shot-absent="empty error"`). */
|
|
68
70
|
absent?: Record<string, string[]>
|
|
69
71
|
}
|
|
@@ -94,6 +96,7 @@ type Outcome = {
|
|
|
94
96
|
status: ShotRecord['status']
|
|
95
97
|
file?: string
|
|
96
98
|
note?: string
|
|
99
|
+
stateful?: true
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
/** Thrown inside a capture when the anchor simply has no such target: recorded `not-declared`, not `error`. */
|
|
@@ -167,7 +170,7 @@ const snap = (
|
|
|
167
170
|
...extra,
|
|
168
171
|
})
|
|
169
172
|
|
|
170
|
-
function record(c: Ctx, { name, state, status, file, note }: Outcome): void {
|
|
173
|
+
function record(c: Ctx, { name, state, status, file, note, stateful }: Outcome): void {
|
|
171
174
|
const { route, scheme, viewport } = c
|
|
172
175
|
c.shots.push({
|
|
173
176
|
route,
|
|
@@ -178,6 +181,7 @@ function record(c: Ctx, { name, state, status, file, note }: Outcome): void {
|
|
|
178
181
|
file: file ?? null,
|
|
179
182
|
status,
|
|
180
183
|
...(note ? { note } : {}),
|
|
184
|
+
...(stateful ? { stateful } : {}),
|
|
181
185
|
})
|
|
182
186
|
if (status === 'error')
|
|
183
187
|
c.input.log(`[shot] ${route} ${name} ${scheme}/${viewport}/${state}: ${note}`)
|
|
@@ -199,12 +203,17 @@ export function tagAutoAnchors(): void {
|
|
|
199
203
|
})
|
|
200
204
|
}
|
|
201
205
|
|
|
206
|
+
/** The DOM marks of a basalt state surface: `ChartCard` and the chart state write theirs; `StatCard` has none but its `basalt-card` container. */
|
|
207
|
+
const STATE_SURFACE =
|
|
208
|
+
'[data-basalt-chart-card], [data-basalt-chart-state], [style*="container-name: basalt-card"]'
|
|
209
|
+
|
|
202
210
|
const readFacts = (page: PwPage): Promise<PageFacts> =>
|
|
203
|
-
page.evaluate(`(() => ({
|
|
211
|
+
page.evaluate(`(() => { const STATE_SURFACE = ${JSON.stringify(STATE_SURFACE)}; return {
|
|
204
212
|
anchors: [...new Set([...document.querySelectorAll('[data-shot]')].map((e) => e.getAttribute('data-shot')).filter(Boolean))],
|
|
205
213
|
declared: [...document.querySelectorAll('[data-shot-states]')].flatMap((e) => (e.getAttribute('data-shot-states') ?? '').split(/\\s+/)).filter(Boolean),
|
|
214
|
+
stateful: [...new Set([...document.querySelectorAll('[data-shot]')].filter((e) => e.matches(STATE_SURFACE) || e.querySelector(STATE_SURFACE)).map((e) => e.getAttribute('data-shot')).filter(Boolean))],
|
|
206
215
|
absent: Object.fromEntries([...document.querySelectorAll('[data-shot][data-shot-absent]')].map((e) => [e.getAttribute('data-shot'), (e.getAttribute('data-shot-absent') ?? '').split(/\\s+/).filter(Boolean)])),
|
|
207
|
-
})
|
|
216
|
+
}; })()`)
|
|
208
217
|
|
|
209
218
|
const addProblem = (c: Ctx, problem: string): void => {
|
|
210
219
|
if (!c.problems.includes(problem)) c.problems.push(problem)
|
|
@@ -679,6 +688,9 @@ async function captureUrlState(c: Ctx, state: ShotState): Promise<void> {
|
|
|
679
688
|
state,
|
|
680
689
|
status: 'not-declared',
|
|
681
690
|
note: c.facts.declared.length === 0 ? NO_STATES_NOTE : 'page does not declare this state',
|
|
691
|
+
...(c.facts.declared.length === 0 && c.facts.stateful?.includes(name)
|
|
692
|
+
? { stateful: true as const }
|
|
693
|
+
: {}),
|
|
682
694
|
})
|
|
683
695
|
}
|
|
684
696
|
return
|
package/src/cli/shot/detect.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* |-|-|-|
|
|
10
10
|
* | scan/shot-error | content | P0 |
|
|
11
11
|
* | scan/no-anchors | content | P0 |
|
|
12
|
-
* | craft-7/no-declared-states | content |
|
|
12
|
+
* | craft-7/no-declared-states | content | P2 (only when an anchor renders a state surface) |
|
|
13
13
|
* | craft-5/contrast | content | P0 |
|
|
14
14
|
* | craft-5/assumed-backdrop | content | P2 |
|
|
15
15
|
* | craft-1/scale-error, -missing| layout | P1 |
|
|
@@ -291,20 +291,20 @@ export function detectFindings(m: ShotMetrics, lint?: LintReport): Finding[] {
|
|
|
291
291
|
defect: `The shot failed${s.note ? `: ${s.note}` : ''}.`,
|
|
292
292
|
})
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
294
|
+
const stateful = new Map<string, Set<string>>()
|
|
295
|
+
for (const s of m.shots) {
|
|
296
|
+
if (s.status !== 'not-declared' || s.note !== NO_STATES_NOTE || !s.stateful) continue
|
|
297
|
+
stateful.set(s.route, (stateful.get(s.route) ?? new Set()).add(s.name))
|
|
298
|
+
}
|
|
299
|
+
for (const [route, names] of stateful) {
|
|
299
300
|
drafts.push({
|
|
300
301
|
...scan,
|
|
301
302
|
rule: 'craft-7/no-declared-states',
|
|
302
|
-
severity: '
|
|
303
|
+
severity: 'P2',
|
|
303
304
|
anchor: '—',
|
|
304
305
|
route,
|
|
305
306
|
cite: `metrics.json shots[${route} not-declared]`,
|
|
306
|
-
defect:
|
|
307
|
-
'No anchor declares data-shot-states, so empty, loading and error were never rendered or scored: declare them with data-shot-states.',
|
|
307
|
+
defect: `${[...names].join(', ')} render${names.size === 1 ? 's' : ''} a state surface but no anchor declares data-shot-states, so empty, loading and error were never scored: add data-shot-states="empty loading error" to ${names.size === 1 ? 'it' : 'each'}.`,
|
|
308
308
|
})
|
|
309
309
|
}
|
|
310
310
|
if (m.scaleError || m.scale.length === 0) {
|
package/src/cli/shot/measure.ts
CHANGED
|
@@ -94,12 +94,12 @@ export function finishMeasurement({ texts, radius, nested, ...rest }: Reading):
|
|
|
94
94
|
/* oxlint-disable unicorn/consistent-function-scoping -- the helpers below are serialised into the page with it: no outer scope */
|
|
95
95
|
export function measureAnchor(root: Element): Reading {
|
|
96
96
|
const px = (v: string | number): number => Math.round(parseFloat(String(v)) * 100) / 100
|
|
97
|
-
const
|
|
98
|
-
top
|
|
99
|
-
|
|
100
|
-
bottom
|
|
101
|
-
left
|
|
102
|
-
}
|
|
97
|
+
const edges = (s: CSSStyleDeclaration, p: string, x = ''): number[] =>
|
|
98
|
+
['top', 'right', 'bottom', 'left'].map((e) => px(s.getPropertyValue(`${p}-${e}${x}`)))
|
|
99
|
+
const sides = (s: CSSStyleDeclaration): Measurement['padding'] => {
|
|
100
|
+
const [top = 0, right = 0, bottom = 0, left = 0] = edges(s, 'padding')
|
|
101
|
+
return { top, right, bottom, left }
|
|
102
|
+
}
|
|
103
103
|
const ctx = document.createElement('canvas').getContext('2d', { willReadFrequently: true })
|
|
104
104
|
if (!ctx) throw new Error('no 2d canvas context: cannot read colours')
|
|
105
105
|
const parsed = new Map<string, number[]>()
|
|
@@ -126,12 +126,13 @@ export function measureAnchor(root: Element): Reading {
|
|
|
126
126
|
const a = top[3] ?? 1
|
|
127
127
|
return [0, 1, 2, 3].map((i) => (i === 3 ? 1 : (top[i] ?? 0) * a + (under[i] ?? 0) * (1 - a)))
|
|
128
128
|
}
|
|
129
|
+
const shown = (s: CSSStyleDeclaration): boolean =>
|
|
130
|
+
s.visibility !== 'hidden' && s.display !== 'none' && s.opacity !== '0'
|
|
131
|
+
const fills = (s: CSSStyleDeclaration): boolean =>
|
|
132
|
+
shown(s) && s.content !== 'none' && (rgba(s.backgroundColor)[3] ?? 0) > 0
|
|
129
133
|
const visible = (el: Element): CSSStyleDeclaration | null => {
|
|
130
134
|
const s = getComputedStyle(el)
|
|
131
|
-
|
|
132
|
-
return s.visibility === 'hidden' || s.display === 'none' || s.opacity === '0' || r.width === 0
|
|
133
|
-
? null
|
|
134
|
-
: s
|
|
135
|
+
return shown(s) && el.getBoundingClientRect().width !== 0 ? s : null
|
|
135
136
|
}
|
|
136
137
|
/** The effective background: layers up to the first opaque ancestor (html/body included), composited. */
|
|
137
138
|
const backdrop = (el: Element): { color: number[]; assumedWhite: boolean } => {
|
|
@@ -148,18 +149,13 @@ export function measureAnchor(root: Element): Reading {
|
|
|
148
149
|
|
|
149
150
|
const cs = getComputedStyle(root)
|
|
150
151
|
const rect = root.getBoundingClientRect()
|
|
151
|
-
const widest = Math.max(
|
|
152
|
-
...['Top', 'Right', 'Bottom', 'Left'].map((e) =>
|
|
153
|
-
px(cs.getPropertyValue(`border-${e.toLowerCase()}-width`)),
|
|
154
|
-
),
|
|
155
|
-
)
|
|
152
|
+
const widest = Math.max(...edges(cs, 'border', '-width'))
|
|
156
153
|
|
|
157
154
|
// gap: the first flex/grid box (breadth-first) that actually spaces its children.
|
|
158
155
|
let gap = { row: 0, column: 0 }
|
|
159
156
|
const queue: Element[] = [root]
|
|
160
157
|
for (let i = 0; i < queue.length && i < 80; i++) {
|
|
161
|
-
const item = queue[i]
|
|
162
|
-
if (!item) break
|
|
158
|
+
const item = queue[i] as Element
|
|
163
159
|
const s = getComputedStyle(item)
|
|
164
160
|
const row = px(s.rowGap) || 0
|
|
165
161
|
const column = px(s.columnGap) || 0
|
|
@@ -187,22 +183,27 @@ export function measureAnchor(root: Element): Reading {
|
|
|
187
183
|
const s = visible(el)
|
|
188
184
|
if (!s) continue
|
|
189
185
|
const r = el.getBoundingClientRect()
|
|
190
|
-
const hasBg = (
|
|
191
|
-
const hasBorder =
|
|
192
|
-
(e) => px(s.getPropertyValue(`border-${e.toLowerCase()}-width`)) > 0,
|
|
193
|
-
)
|
|
186
|
+
const hasBg = fills(s)
|
|
187
|
+
const hasBorder = edges(s, 'border', '-width').some((w) => w > 0)
|
|
194
188
|
if (el !== root && (hasBg || hasBorder) && nested.length < 60) {
|
|
195
189
|
nested.push({
|
|
196
190
|
path: pathOf(el),
|
|
197
191
|
radius: { value: s.borderTopLeftRadius, width: px(r.width), height: px(r.height) },
|
|
198
|
-
padding: sides(s
|
|
192
|
+
padding: sides(s),
|
|
199
193
|
})
|
|
200
194
|
}
|
|
201
|
-
//
|
|
195
|
+
// Only boxes smaller than the anchor count (wrappers are layout); a pseudo fill is paint (Skeleton) only if it covers its host.
|
|
196
|
+
const pseudo = ['::before', '::after'].some((p) => {
|
|
197
|
+
const ps = getComputedStyle(el, p)
|
|
198
|
+
return (
|
|
199
|
+
fills(ps) &&
|
|
200
|
+
[px(ps.width) - r.width, px(ps.height) - r.height].every((d) => Math.abs(d) <= 2)
|
|
201
|
+
)
|
|
202
|
+
})
|
|
202
203
|
if (
|
|
203
204
|
el !== root &&
|
|
204
205
|
(/^(svg|img|canvas|video|input|textarea)$/i.test(el.tagName) ||
|
|
205
|
-
((hasBg || hasBorder) && r.height < rect.height * 0.9))
|
|
206
|
+
((hasBg || hasBorder || pseudo) && r.height < rect.height * 0.9))
|
|
206
207
|
) {
|
|
207
208
|
painted.push([r.top, r.bottom])
|
|
208
209
|
}
|
|
@@ -230,8 +231,7 @@ export function measureAnchor(root: Element): Reading {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
// emptyRatio: the largest vertical run (edges included) with nothing painted in it.
|
|
233
|
-
const top = rect
|
|
234
|
-
const bottom = rect.bottom
|
|
234
|
+
const { top, bottom } = rect
|
|
235
235
|
let cursor = top
|
|
236
236
|
let longest = 0
|
|
237
237
|
for (const [a, b] of painted.toSorted((x, y) => x[0] - y[0])) {
|
|
@@ -244,7 +244,7 @@ export function measureAnchor(root: Element): Reading {
|
|
|
244
244
|
|
|
245
245
|
return {
|
|
246
246
|
box: { width: px(rect.width), height: px(rect.height) },
|
|
247
|
-
padding: sides(cs
|
|
247
|
+
padding: sides(cs),
|
|
248
248
|
gap,
|
|
249
249
|
radius: { value: cs.borderTopLeftRadius, width: px(rect.width), height: px(rect.height) },
|
|
250
250
|
borderWidth: widest,
|
|
@@ -13,6 +13,16 @@ export const INSTALL_LINE =
|
|
|
13
13
|
|
|
14
14
|
const KILL_TIMEOUT_MS = 10_000
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A headless Chromium with no pointing device reports `(hover: none) (pointer: coarse)`, so no
|
|
18
|
+
* `@media (hover: hover)` rule applies in a desktop hover shot. These blink settings make the
|
|
19
|
+
* browser's primary input a mouse (hover 2, fine 4); a `hasTouch` mobile context still emulates
|
|
20
|
+
* touch over them.
|
|
21
|
+
*/
|
|
22
|
+
export const POINTER_ARGS = [
|
|
23
|
+
'--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4',
|
|
24
|
+
]
|
|
25
|
+
|
|
16
26
|
export type Box = { x: number; y: number; width: number; height: number }
|
|
17
27
|
|
|
18
28
|
export type ShotOptions = {
|
|
@@ -69,7 +79,11 @@ export type PwBrowser<C extends PwContext = PwContext> = {
|
|
|
69
79
|
type PwServer = { wsEndpoint(): string; kill(): Promise<void> }
|
|
70
80
|
export type Playwright<B extends PwBrowser = PwBrowser> = {
|
|
71
81
|
chromium: {
|
|
72
|
-
launchServer(options: {
|
|
82
|
+
launchServer(options: {
|
|
83
|
+
channel?: string
|
|
84
|
+
chromiumSandbox: boolean
|
|
85
|
+
args: string[]
|
|
86
|
+
}): Promise<PwServer>
|
|
73
87
|
connect(wsEndpoint: string): Promise<B>
|
|
74
88
|
}
|
|
75
89
|
}
|
|
@@ -132,7 +146,9 @@ export async function withBrowser<B extends PwBrowser, T>(
|
|
|
132
146
|
let browser: B
|
|
133
147
|
try {
|
|
134
148
|
server = await pw.chromium.launchServer(
|
|
135
|
-
channel
|
|
149
|
+
channel
|
|
150
|
+
? { channel, chromiumSandbox, args: POINTER_ARGS }
|
|
151
|
+
: { chromiumSandbox, args: POINTER_ARGS },
|
|
136
152
|
)
|
|
137
153
|
browser = await pw.chromium.connect(server.wsEndpoint())
|
|
138
154
|
} catch (error) {
|
package/src/cli/shot/types.ts
CHANGED
|
@@ -72,6 +72,8 @@ export type ShotRecord = {
|
|
|
72
72
|
/** `absent`: the anchor declared itself missing in this state (`data-shot-absent`): not a defect. */
|
|
73
73
|
status: 'ok' | 'not-declared' | 'absent' | 'skipped' | 'error'
|
|
74
74
|
note?: string
|
|
75
|
+
/** The anchor renders a basalt state surface (a ChartCard, StatCard or chart state): set on the `not-declared` shots of a route that declares no `data-shot-states`. */
|
|
76
|
+
stateful?: true
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
/** The theme's resolved steps (px) for one scheme × viewport; a missing custom property is omitted. */
|
package/src/cli/tokens-css.ts
CHANGED
|
@@ -183,17 +183,17 @@ export function tokensCss(flags: string[], cwd: string = process.cwd()): number
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/** Every `--basalt-font-*` declaration in the shipped stylesheet, in source order. */
|
|
186
|
-
function readShippedFontDecls(pkgRoot: string): {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return decls
|
|
186
|
+
function readShippedFontDecls(pkgRoot: string): {
|
|
187
|
+
face: string
|
|
188
|
+
decls: { name: string; value: string }[]
|
|
189
|
+
} {
|
|
190
|
+
const css = readSource(pkgRoot, 'dist/styles.css') ?? readSource(pkgRoot, 'src/styles.css') ?? ''
|
|
191
|
+
const face = css.match(/@font-face\s*\{[^}]*'Basalt Head Digits'[^}]*\}\n*/)?.[0] ?? ''
|
|
192
|
+
const decls = [...css.matchAll(/(--basalt-font[\w-]*)\s*:\s*([^;]+);/g)].map((m) => ({
|
|
193
|
+
name: m[1] as string,
|
|
194
|
+
value: (m[2] as string).replace(/\s+/g, ' ').trim(),
|
|
195
|
+
}))
|
|
196
|
+
return { face: face && `${face.trim()}\n\n`, decls }
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
@@ -202,17 +202,15 @@ function readShippedFontDecls(pkgRoot: string): { name: string; value: string }[
|
|
|
202
202
|
* The typeface half of the framework-free route, which had no supported path at all: `tokens.css`
|
|
203
203
|
* emits no font vars, `styles.css` is the one place the defaults live and a framework-free consumer
|
|
204
204
|
* is told not to import it, and `buildFontsCss` returns `''` unless the caller already knows the
|
|
205
|
-
* stacks. The one non-Mantine consumer lost its font identity entirely and hardcoded the stacks
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* The
|
|
209
|
-
*
|
|
210
|
-
* `@fontsource-variable/*` packages: without them the stacks fall through to their own system
|
|
211
|
-
* fallbacks, which is the intended framework-free behaviour.
|
|
205
|
+
* stacks. The one non-Mantine consumer lost its font identity entirely and hardcoded the stacks.
|
|
206
|
+
* The declarations (and the `Basalt Head Digits` face the head stack leads with) are READ from the
|
|
207
|
+
* shipped stylesheet, so this command and `basalt-ui/styles.css` can never name different
|
|
208
|
+
* typefaces. The fonts are `@fontsource-variable/*` packages (the face's `url()` is a bare package
|
|
209
|
+
* specifier for a bundler); without them the stacks fall back to system fonts.
|
|
212
210
|
*/
|
|
213
211
|
export function fontsCss(flags: string[], cwd: string = process.cwd()): number {
|
|
214
212
|
const pkgRoot = packageRoot()
|
|
215
|
-
const decls = readShippedFontDecls(pkgRoot)
|
|
213
|
+
const { face, decls } = readShippedFontDecls(pkgRoot)
|
|
216
214
|
if (decls.length === 0) {
|
|
217
215
|
console.error(
|
|
218
216
|
'fonts:css: could not read the shipped font stacks from styles.css — this is a packaging ' +
|
|
@@ -220,7 +218,7 @@ export function fontsCss(flags: string[], cwd: string = process.cwd()): number {
|
|
|
220
218
|
)
|
|
221
219
|
return 1
|
|
222
220
|
}
|
|
223
|
-
const body =
|
|
221
|
+
const body = `${face}:root {\n${decls.map((d) => ` ${d.name}: ${d.value};`).join('\n')}\n}\n`
|
|
224
222
|
const header = generatedHeader(readFrameworkVersion(pkgRoot), 'fonts:css', flags)
|
|
225
223
|
return emitGeneratedCss(`${header}${body}`, flags, cwd, 'fonts:css')
|
|
226
224
|
}
|
|
@@ -171,6 +171,11 @@
|
|
|
171
171
|
text-overflow: ellipsis;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
/* The dot + word never outgrows its cell: the word truncates (its cell carries the full text in `title`). */
|
|
175
|
+
.root[data-variant='thin'] .secondary > :first-child {
|
|
176
|
+
max-inline-size: 100%;
|
|
177
|
+
}
|
|
178
|
+
|
|
174
179
|
.root[data-variant='thin'] .secondary [data-verdict-word] {
|
|
175
180
|
min-width: 0;
|
|
176
181
|
overflow: hidden;
|
|
@@ -216,4 +221,17 @@
|
|
|
216
221
|
.root[data-variant='thin'] .secondary {
|
|
217
222
|
text-align: end;
|
|
218
223
|
}
|
|
224
|
+
|
|
225
|
+
.root[data-variant='thin'][data-secondary-align='start'] .secondary {
|
|
226
|
+
text-align: start;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/*
|
|
231
|
+
* A column of DeltaBadges: glyph and figure are ONE unit, end-aligned as a whole, so the glyph never drifts
|
|
232
|
+
* from its figure however wide the column ("▲ 9%" and "▲13%" share their right edge and keep the badge's own
|
|
233
|
+
* gap). Tabular figures keep the right edges even (D33: only in a table-like column, not a hero metric).
|
|
234
|
+
*/
|
|
235
|
+
.secondary [data-delta] {
|
|
236
|
+
font-variant-numeric: tabular-nums;
|
|
219
237
|
}
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
* label, the value and secondary columns are right-aligned and shared, and the track takes the rest on
|
|
18
18
|
* the one scale, so a name stays beside its value and a full-scale bar ends at the track end.
|
|
19
19
|
*
|
|
20
|
+
* The secondary column aligns by content (override: `secondaryAlign`): a text secondary (a status word,
|
|
21
|
+
* `StatusVerdict`/`StatusDot`) starts on one x so the dots line up; figures ("41%", "+€7"), numbers and a
|
|
22
|
+
* `DeltaBadge` end. A delta column also gets a fixed-width glyph slot and a tabular figure slot, so the
|
|
23
|
+
* glyphs AND the figures' right edges line up (a column of deltas is table-like, D33 allows tabular there).
|
|
24
|
+
*
|
|
20
25
|
* Colour law: bars are neutral. `accentLeader` (opt-in) lets the top row take the accent — the
|
|
21
26
|
* leader bar, and nothing else. Each value is rendered as text, never only a bar length.
|
|
22
27
|
*
|
|
@@ -41,10 +46,13 @@
|
|
|
41
46
|
* />
|
|
42
47
|
*/
|
|
43
48
|
import { Skeleton, VisuallyHidden } from '@mantine/core'
|
|
49
|
+
import { isValidElement } from 'react'
|
|
44
50
|
import type { ReactNode } from 'react'
|
|
45
51
|
import { cx } from '../common/props'
|
|
46
52
|
import type { BasaltProps } from '../common/props'
|
|
47
53
|
import classes from './bar-list.module.css'
|
|
54
|
+
import { StatusDot } from '../theme/status-dot'
|
|
55
|
+
import { StatusVerdict } from '../theme/status-verdict'
|
|
48
56
|
import { asText, barPercent } from './scale'
|
|
49
57
|
|
|
50
58
|
type BarListItem = {
|
|
@@ -79,6 +87,11 @@ export type BarListProps = BasaltProps & {
|
|
|
79
87
|
variant?: 'thin' | 'inline'
|
|
80
88
|
/** The first row's bar takes the accent. Off by default. */
|
|
81
89
|
accentLeader?: boolean
|
|
90
|
+
/**
|
|
91
|
+
* Which edge the secondary column aligns to. Default: by content — text (a status word, a status
|
|
92
|
+
* mark) starts, figures and other elements end.
|
|
93
|
+
*/
|
|
94
|
+
secondaryAlign?: 'start' | 'end'
|
|
82
95
|
/** Renders row-shaped skeletons. */
|
|
83
96
|
loading?: boolean
|
|
84
97
|
/** Skeleton rows while loading. Default 5. */
|
|
@@ -91,6 +104,19 @@ export type BarListProps = BasaltProps & {
|
|
|
91
104
|
const hasContent = (node: ReactNode): boolean =>
|
|
92
105
|
node !== undefined && node !== null && typeof node !== 'boolean'
|
|
93
106
|
|
|
107
|
+
const isFigure = (node: ReactNode): boolean =>
|
|
108
|
+
typeof node === 'number' || (typeof node === 'string' && /^[\s+\-−±▲▼]*[€$£¥]?\d/.test(node))
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The column's edge by content. A string that is not a figure and a status mark (`StatusVerdict`,
|
|
112
|
+
* `StatusDot`) are text and start on one x so the dots line up; a number, a numeric string and any other
|
|
113
|
+
* element (a `DeltaBadge`) are figures and keep the end edge.
|
|
114
|
+
*/
|
|
115
|
+
const isText = (node: ReactNode): boolean =>
|
|
116
|
+
typeof node === 'string'
|
|
117
|
+
? !isFigure(node)
|
|
118
|
+
: isValidElement(node) && (node.type === StatusVerdict || node.type === StatusDot)
|
|
119
|
+
|
|
94
120
|
export function BarList({
|
|
95
121
|
label,
|
|
96
122
|
items,
|
|
@@ -98,6 +124,7 @@ export function BarList({
|
|
|
98
124
|
max,
|
|
99
125
|
variant = 'thin',
|
|
100
126
|
accentLeader = false,
|
|
127
|
+
secondaryAlign,
|
|
101
128
|
loading = false,
|
|
102
129
|
loadingRows = 5,
|
|
103
130
|
emptyText = 'No data',
|
|
@@ -134,6 +161,7 @@ export function BarList({
|
|
|
134
161
|
)
|
|
135
162
|
const thin = variant === 'thin'
|
|
136
163
|
const hasSecondary = items.some((i) => hasContent(i.secondary))
|
|
164
|
+
const align = secondaryAlign ?? (items.some((i) => isText(i.secondary)) ? 'start' : 'end')
|
|
137
165
|
return (
|
|
138
166
|
// The frame is the width container the wide layout keys on (a container cannot restyle its own grid).
|
|
139
167
|
<div className={cx(classes.frame, className)} style={style}>
|
|
@@ -144,6 +172,7 @@ export function BarList({
|
|
|
144
172
|
role="list"
|
|
145
173
|
aria-label={label}
|
|
146
174
|
data-secondary={hasSecondary ? '' : undefined}
|
|
175
|
+
data-secondary-align={hasSecondary ? align : undefined}
|
|
147
176
|
data-variant={variant}
|
|
148
177
|
>
|
|
149
178
|
{items.map((item, i) => {
|
|
@@ -87,8 +87,12 @@ export function DeltaBadge({
|
|
|
87
87
|
const showGlyph = withGlyph && glyph !== undefined
|
|
88
88
|
|
|
89
89
|
return (
|
|
90
|
-
<span className={classes.deltaBadge} style={{ color: tone }}>
|
|
91
|
-
{showGlyph &&
|
|
90
|
+
<span className={classes.deltaBadge} style={{ color: tone }} data-delta="">
|
|
91
|
+
{showGlyph && (
|
|
92
|
+
<span className={classes.deltaGlyph} data-delta-glyph="">
|
|
93
|
+
{glyph}
|
|
94
|
+
</span>
|
|
95
|
+
)}
|
|
92
96
|
{format(value)}
|
|
93
97
|
{period !== undefined && ' '}
|
|
94
98
|
{period !== undefined && (
|