basalt-ui 2.27.2 → 2.29.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 +466 -307
- package/MIGRATING.md +358 -12
- package/agent/rules/basalt-batteries.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 +3 -3
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +12 -6
- package/agent/skills/basalt-design/references/catalogue.md +42 -36
- package/agent/skills/basalt-design/references/recipes.md +47 -0
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-basalt.json +2 -1
- package/configs/oxlint-plugin.js +112 -3
- package/configs/oxlint-plugin.test.ts +99 -4
- package/configs/oxlint.json +1 -0
- package/dist/agent/chat/thread-message.d.ts +1 -160
- package/dist/agent/chat/thread-message.d.ts.map +1 -1
- package/dist/agent/chat/thread-message.js +7 -162
- package/dist/agent/chat/virtualize.d.ts +5 -5
- package/dist/charts/ChartCard.d.ts +14 -7
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +112 -23
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +11 -4
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +155 -44
- package/dist/charts/chart-box.module.css +59 -2
- package/dist/charts/chart-box.module.css.d.ts +5 -0
- package/dist/charts/chart-card.module.css +28 -17
- package/dist/charts/chart-card.module.css.d.ts +3 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +38 -27
- package/dist/charts/labels.d.ts +13 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +131 -20
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +1 -1
- package/dist/charts/ref-label.d.ts +37 -8
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +55 -10
- package/dist/charts/sparkline.module.css +50 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +4 -4
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +23 -5
- package/dist/cli/doctor-upgrade.d.ts +11 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +54 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -3
- package/dist/cli/index.d.ts +13 -13
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +36 -2
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +118 -27
- package/dist/cli/router-wiring.d.ts +3 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/shot/capture.d.ts +34 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +95 -12
- package/dist/cli/shot/detect.d.ts +4 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +38 -16
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +9 -2
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +11 -2
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +10 -2
- package/dist/common/could-not-load.d.ts +13 -0
- package/dist/common/could-not-load.d.ts.map +1 -0
- package/dist/common/could-not-load.js +14 -0
- package/dist/common/empty-copy.d.ts +16 -0
- package/dist/common/empty-copy.d.ts.map +1 -0
- package/dist/common/empty-copy.js +9 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -0
- package/dist/common/props.d.ts +20 -0
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/props.js +13 -1
- package/dist/common/retry-button.module.css +7 -3
- package/dist/common/virtual-rows.d.ts +196 -0
- package/dist/common/virtual-rows.d.ts.map +1 -0
- package/dist/common/virtual-rows.js +290 -0
- package/dist/controls/controls.module.css +33 -1
- package/dist/controls/controls.module.css.d.ts +2 -0
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +8 -2
- package/dist/controls/filter-pill.d.ts +27 -3
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +15 -4
- package/dist/controls/form-layout.d.ts +9 -3
- package/dist/controls/form-layout.d.ts.map +1 -1
- package/dist/controls/form-layout.js +74 -12
- package/dist/controls/form-layout.module.css +112 -7
- package/dist/controls/form-layout.module.css.d.ts +1 -0
- package/dist/controls/multi-select-filter.d.ts +2 -2
- package/dist/controls/multi-select-filter.d.ts.map +1 -1
- package/dist/controls/multi-select-filter.js +12 -6
- package/dist/controls/range-filter.d.ts +1 -1
- package/dist/controls/range-filter.d.ts.map +1 -1
- package/dist/controls/range-filter.js +8 -2
- package/dist/dashboard/bar-list.d.ts +5 -5
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +21 -5
- package/dist/dashboard/board-nav.d.ts +22 -0
- package/dist/dashboard/board-nav.d.ts.map +1 -0
- package/dist/dashboard/board-nav.js +49 -0
- package/dist/dashboard/board.d.ts +52 -0
- package/dist/dashboard/board.d.ts.map +1 -0
- package/dist/dashboard/board.js +247 -0
- package/dist/dashboard/board.module.css +179 -0
- package/dist/dashboard/board.module.css.d.ts +28 -0
- package/dist/dashboard/empty-state.d.ts +6 -6
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +17 -8
- package/dist/dashboard/event-list-model.d.ts +54 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -0
- package/dist/dashboard/event-list-model.js +76 -0
- package/dist/dashboard/event-list-rows.d.ts +23 -0
- package/dist/dashboard/event-list-rows.d.ts.map +1 -0
- package/dist/dashboard/event-list-rows.js +89 -0
- package/dist/dashboard/event-list-scroll.d.ts +55 -0
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
- package/dist/dashboard/event-list-scroll.js +216 -0
- package/dist/dashboard/event-list-skeleton.d.ts +10 -0
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
- package/dist/dashboard/event-list-skeleton.js +34 -0
- package/dist/dashboard/event-list.d.ts +65 -0
- package/dist/dashboard/event-list.d.ts.map +1 -0
- package/dist/dashboard/event-list.js +208 -0
- package/dist/dashboard/event-list.module.css +336 -0
- package/dist/dashboard/event-list.module.css.d.ts +34 -0
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -0
- package/dist/dashboard/meter-model.d.ts +6 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +9 -4
- package/dist/dashboard/meter-parts.d.ts +3 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +36 -6
- package/dist/dashboard/meter.d.ts +3 -3
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -2
- package/dist/dashboard/meter.module.css +20 -12
- package/dist/dashboard/meter.module.css.d.ts +0 -1
- package/dist/dashboard/page-summary.d.ts +3 -3
- package/dist/dashboard/page-summary.d.ts.map +1 -1
- package/dist/dashboard/page-summary.js +7 -2
- package/dist/dashboard/page-summary.module.css +5 -2
- package/dist/dashboard/query-state.d.ts +9 -8
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +29 -11
- package/dist/dashboard/section.d.ts +11 -3
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +34 -7
- package/dist/dashboard/settings-section.d.ts +8 -5
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +12 -8
- package/dist/dashboard/settings-section.module.css +25 -4
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts +5 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +8 -3
- package/dist/dashboard/stat-card.d.ts +3 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +47 -12
- package/dist/dashboard/stat-card.module.css +42 -7
- package/dist/dashboard/stat-card.module.css.d.ts +3 -0
- package/dist/dashboard/stat-group.d.ts +2 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +10 -3
- package/dist/dashboard/stat-strip.d.ts +5 -4
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +41 -31
- package/dist/dashboard/stat-strip.module.css +8 -6
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.d.ts +6 -6
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +4 -2
- package/dist/dashboard/widget-header.module.css +12 -15
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +24 -1
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/shell/app-main.module.css +18 -0
- package/dist/styles.css +69 -0
- package/dist/surfaces.d.ts +2 -2
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +8 -2
- package/dist/table/cell-kinds.d.ts +47 -0
- package/dist/table/cell-kinds.d.ts.map +1 -0
- package/dist/table/cell-kinds.js +180 -0
- package/dist/table/cell-kinds.module.css +55 -0
- package/dist/table/cell-kinds.module.css.d.ts +15 -0
- package/dist/table/data-table-fold.d.ts +155 -0
- package/dist/table/data-table-fold.d.ts.map +1 -0
- package/dist/table/data-table-fold.js +320 -0
- package/dist/table/data-table-state.d.ts +10 -3
- package/dist/table/data-table-state.d.ts.map +1 -1
- package/dist/table/data-table-state.js +11 -6
- package/dist/table/data-table.d.ts +13 -28
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +362 -255
- package/dist/table/data-table.module.css +282 -3
- package/dist/table/data-table.module.css.d.ts +16 -0
- package/dist/table/table-features.d.ts +34 -4
- package/dist/table/table-features.d.ts.map +1 -1
- package/dist/table/table-features.js +10 -0
- package/dist/theme/card-inset.module.css +35 -0
- package/dist/theme/controls.module.css +55 -2
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +5 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +14 -10
- package/dist/tokens/core.d.ts +1 -0
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +1 -0
- package/dist/tokens/derive.js +1 -1
- package/dist/tokens/palette.d.ts +2 -1
- package/dist/tokens/palette.d.ts.map +1 -1
- package/llms.txt +295 -5
- package/package.json +1 -1
- package/src/agent/chat/thread-message.tsx +10 -403
- package/src/agent/chat/virtualize.ts +5 -5
- package/src/charts/ChartCard.tsx +175 -31
- package/src/charts/Lines.tsx +13 -4
- package/src/charts/Sparkline.tsx +213 -48
- package/src/charts/chart-box.module.css +59 -2
- package/src/charts/chart-box.module.css.d.ts +5 -0
- package/src/charts/chart-card.module.css +28 -17
- package/src/charts/chart-card.module.css.d.ts +3 -0
- package/src/charts/compile.ts +59 -33
- package/src/charts/labels.ts +175 -24
- package/src/charts/legend.tsx +3 -2
- package/src/charts/ref-label.ts +114 -18
- package/src/charts/sparkline.module.css +50 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +40 -10
- package/src/cli/doctor-upgrade.ts +75 -0
- package/src/cli/doctor.ts +36 -0
- package/src/cli/help.ts +16 -6
- package/src/cli/index.ts +73 -67
- package/src/cli/init.ts +157 -36
- package/src/cli/router-wiring.ts +2 -2
- package/src/cli/shot/capture.ts +138 -16
- package/src/cli/shot/detect.ts +46 -22
- package/src/cli/shot/index.ts +8 -2
- package/src/cli/shot/measure.ts +11 -2
- package/src/cli/shot/types.ts +4 -1
- package/src/cli/sync.ts +12 -2
- package/src/common/could-not-load.ts +22 -0
- package/src/common/empty-copy.ts +17 -0
- package/src/common/index.ts +1 -0
- package/src/common/props.ts +30 -0
- package/src/common/retry-button.module.css +7 -3
- package/src/common/virtual-rows.tsx +682 -0
- package/src/controls/controls.module.css +33 -1
- package/src/controls/controls.module.css.d.ts +2 -0
- package/src/controls/enum-filter.tsx +8 -2
- package/src/controls/filter-pill.tsx +80 -27
- package/src/controls/form-layout.module.css +112 -7
- package/src/controls/form-layout.module.css.d.ts +1 -0
- package/src/controls/form-layout.tsx +115 -22
- package/src/controls/multi-select-filter.tsx +22 -11
- package/src/controls/range-filter.tsx +9 -3
- package/src/dashboard/bar-list.module.css +21 -5
- package/src/dashboard/bar-list.tsx +53 -45
- package/src/dashboard/board-nav.ts +67 -0
- package/src/dashboard/board.module.css +179 -0
- package/src/dashboard/board.module.css.d.ts +28 -0
- package/src/dashboard/board.tsx +415 -0
- package/src/dashboard/empty-state.tsx +21 -11
- package/src/dashboard/event-list-model.ts +125 -0
- package/src/dashboard/event-list-rows.tsx +117 -0
- package/src/dashboard/event-list-scroll.ts +291 -0
- package/src/dashboard/event-list-skeleton.tsx +62 -0
- package/src/dashboard/event-list.module.css +336 -0
- package/src/dashboard/event-list.module.css.d.ts +34 -0
- package/src/dashboard/event-list.tsx +336 -0
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +53 -14
- package/src/dashboard/meter.module.css +20 -12
- package/src/dashboard/meter.module.css.d.ts +0 -1
- package/src/dashboard/meter.tsx +36 -18
- package/src/dashboard/page-summary.module.css +5 -2
- package/src/dashboard/page-summary.tsx +13 -6
- package/src/dashboard/query-state.tsx +55 -30
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +25 -4
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +18 -8
- package/src/dashboard/stat-card-parts.tsx +20 -3
- package/src/dashboard/stat-card.module.css +42 -7
- package/src/dashboard/stat-card.module.css.d.ts +3 -0
- package/src/dashboard/stat-card.tsx +55 -13
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +8 -6
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +12 -15
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +7 -1
- package/src/index.ts +4 -0
- package/src/shell/app-main.module.css +18 -0
- package/src/styles.css +69 -0
- package/src/surfaces.ts +7 -1
- package/src/table/cell-kinds.module.css +55 -0
- package/src/table/cell-kinds.module.css.d.ts +15 -0
- package/src/table/cell-kinds.tsx +263 -0
- package/src/table/data-table-fold.tsx +567 -0
- package/src/table/data-table-state.ts +24 -13
- package/src/table/data-table.module.css +282 -3
- package/src/table/data-table.module.css.d.ts +16 -0
- package/src/table/data-table.tsx +430 -362
- package/src/table/table-features.ts +44 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
- package/src/theme/card-inset.module.css +35 -0
- package/src/theme/controls.module.css +55 -2
- package/src/theme/ctl-theme.tsx +8 -0
- package/src/theme/index.ts +12 -8
- package/src/tokens/core.ts +1 -0
- package/src/tokens/derive.ts +1 -1
- package/src/tokens/palette.ts +4 -1
package/src/charts/Sparkline.tsx
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { dot } from '@tanstack/charts/dot'
|
|
9
9
|
import { decorative } from '@tanstack/charts/mark/decorative'
|
|
10
10
|
import { lineY } from '@tanstack/charts/line'
|
|
11
|
+
import { rect } from '@tanstack/charts/rect'
|
|
11
12
|
import { ruleY } from '@tanstack/charts/rule'
|
|
12
13
|
import { scaleBand } from '@tanstack/charts/scales/band'
|
|
13
14
|
import { scaleLinear } from '@tanstack/charts/scales/linear'
|
|
@@ -21,6 +22,7 @@ import type { CartesianDefinition } from './compile'
|
|
|
21
22
|
import { chartCurve } from './curves'
|
|
22
23
|
import { barMark } from './marks'
|
|
23
24
|
import { VisualSlotContext } from '../dashboard/visual-slot'
|
|
25
|
+
import type { VisualSlot } from '../dashboard/visual-slot'
|
|
24
26
|
import { bucketDay, dayGranular, defaultNumberFormat } from './compile'
|
|
25
27
|
import { referenceLabelPlacement } from './ref-label'
|
|
26
28
|
import { readoutClock, readoutDay } from './chart-dates'
|
|
@@ -59,15 +61,24 @@ export type SparklineProps = BasaltProps & {
|
|
|
59
61
|
/** A quiet dashed hairline at a value, or at the mean of the plotted values (`'mean'`). The y
|
|
60
62
|
* domain widens to include it. Not a legend item, never a status colour. */
|
|
61
63
|
reference?: number | 'mean' | undefined
|
|
62
|
-
/** A short caption for the `reference` line (`PR`, `30 d mean`), drawn at the plot
|
|
63
|
-
* above the
|
|
64
|
+
/** A short caption for the `reference` line (`PR`, `30 d mean`), drawn at the plot end the line
|
|
65
|
+
* is not near, just above the reference (below when there is no room above). */
|
|
64
66
|
referenceLabel?: string | undefined
|
|
67
|
+
/** A productive range (`{ from: 0.6, to: 1 }`) drawn as a quiet band behind the line. The y
|
|
68
|
+
* domain widens to include it. Not a series: no legend item, no tooltip row. A non-finite bound or
|
|
69
|
+
* an empty range (`from === to`) draws nothing and leaves the domain alone. */
|
|
70
|
+
band?: { from: number; to: number } | undefined
|
|
65
71
|
/** Formats the readout's value. Default: the compact number format. */
|
|
66
72
|
format?: ((value: number) => string) | undefined
|
|
67
73
|
/** The readout's x label per point, index-aligned with `data`: pass the point's day ("12 Oct"),
|
|
68
74
|
* and the readout reads `3 items · 12 Oct` beside the point. Omitted: the moment of an `{ at }`
|
|
69
75
|
* point, else the value alone. */
|
|
70
76
|
labels?: readonly string[] | undefined
|
|
77
|
+
/** The span the series covers, stated quietly under the plot (`12 wk`). Default inside a `StatCard`
|
|
78
|
+
* or strip cell: the first and last of `labels`, or of an `{ at }` series' days (`3 Aug – 19 Oct`; an hourly series states none);
|
|
79
|
+
* plain values state none. `false` or a blank string states none. With a `referenceLabel`, a stated window also takes
|
|
80
|
+
* that label out of the plot into the same row, where no line can run through it. */
|
|
81
|
+
window?: string | false | undefined
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
type Point = { i: number; v: number | null }
|
|
@@ -85,6 +96,12 @@ const LINE_INSET = 3
|
|
|
85
96
|
const SHORT_BOX = 36
|
|
86
97
|
/** The muted tone's line: the same alpha the consumers hand-built (`alpha(VX.muted, .35)`). */
|
|
87
98
|
const MUTED_LINE = alpha(VX.muted, 0.35)
|
|
99
|
+
/** The productive band: the chart layer's neutral wash (`BandStrip`'s), under the line in the paint order. */
|
|
100
|
+
/** The unit x scale (`zx`) a band is drawn on, whatever the series' own x is. */
|
|
101
|
+
const ZONE_X = {
|
|
102
|
+
zx: { channel: 'x' as const, scale: scaleLinear().domain([0, 1]), axis: false as const },
|
|
103
|
+
}
|
|
104
|
+
const BAND_FILL = alpha(VX.neutral, 0.2)
|
|
88
105
|
/** Air between the plot's start and the reference label, so the focus outline never covers it. */
|
|
89
106
|
const REFERENCE_LABEL_DX = 3
|
|
90
107
|
// Pixel policy of the self-pooling (`poolSparkline`): the densest a series may draw.
|
|
@@ -126,6 +143,44 @@ function momentsOf(data: SparklineProps['data']): readonly (string | undefined)[
|
|
|
126
143
|
})
|
|
127
144
|
}
|
|
128
145
|
|
|
146
|
+
/** Whether `{ at }` points are a day or more apart: the span of an hourly series is the host's to state. */
|
|
147
|
+
function isDayWindow(data: SparklineProps['data']): boolean {
|
|
148
|
+
const known: Date[] = []
|
|
149
|
+
for (const d of data) {
|
|
150
|
+
const at = typeof d === 'object' && d !== null ? toDate(d.at) : null
|
|
151
|
+
if (at !== null) known.push(at)
|
|
152
|
+
}
|
|
153
|
+
return known.length > 0 && dayGranular(known)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** `first – last` of a series' day labels, or `undefined` when there are fewer than two distinct ones. */
|
|
157
|
+
function spanOf(names: readonly (string | undefined)[] | undefined): string | undefined {
|
|
158
|
+
const first = names?.find((n) => n !== undefined)
|
|
159
|
+
const last = names?.findLast((n) => n !== undefined)
|
|
160
|
+
return first === undefined || last === undefined || first === last
|
|
161
|
+
? undefined
|
|
162
|
+
: `${first} – ${last}`
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The window caption under a hosted plot, or `undefined`. A stated `window` wins (blank or `false`:
|
|
167
|
+
* none); otherwise a host with room for it (not `compact`) gets `first – last` of the `labels`, or of a
|
|
168
|
+
* day-dated series' days.
|
|
169
|
+
*/
|
|
170
|
+
function windowCaption(opts: {
|
|
171
|
+
prop: string | false | undefined
|
|
172
|
+
slot: VisualSlot | null
|
|
173
|
+
data: SparklineProps['data']
|
|
174
|
+
labels: readonly string[] | undefined
|
|
175
|
+
moments: readonly (string | undefined)[] | undefined
|
|
176
|
+
}): string | undefined {
|
|
177
|
+
const { prop, slot, data, labels, moments } = opts
|
|
178
|
+
if (prop === false) return undefined
|
|
179
|
+
if (prop !== undefined) return prop.trim() === '' ? undefined : prop.trim()
|
|
180
|
+
if (slot === null || slot.compact === true) return undefined
|
|
181
|
+
return spanOf(labels ?? (isDayWindow(data) ? moments : undefined))
|
|
182
|
+
}
|
|
183
|
+
|
|
129
184
|
/** Min and max of the finite values, by loop (a spread overflows the stack on long series). */
|
|
130
185
|
function extent(rows: readonly Point[]): readonly [number, number] | null {
|
|
131
186
|
let lo = Number.POSITIVE_INFINITY
|
|
@@ -242,10 +297,12 @@ function frameOf(
|
|
|
242
297
|
mark: 'line' | 'bar',
|
|
243
298
|
count: number,
|
|
244
299
|
hasEnd: boolean,
|
|
300
|
+
banded = false,
|
|
245
301
|
): Frame {
|
|
246
302
|
if (mark === 'bar') return { x: [0, count], y: [Math.min(lo, 0), Math.max(hi, 0) || 1] }
|
|
247
303
|
// A flat or single-point series needs an extent; 10% air keeps the stroke inside the box.
|
|
248
|
-
|
|
304
|
+
// A band edge that sets the domain needs air to read as an edge: a quarter of the span, not a tenth.
|
|
305
|
+
const pad = (hi - lo) * (banded ? 0.25 : 0.1) || 1
|
|
249
306
|
// Half a dot of air at each end, in index units, so the last-point dot is not clipped.
|
|
250
307
|
const xPad = hasEnd ? (count - 1) * 0.04 || 0.5 : 0
|
|
251
308
|
return { x: [-xPad, Math.max(count - 1, 1) + xPad], y: [lo - pad, hi + pad] }
|
|
@@ -259,43 +316,76 @@ function compileSparkline(
|
|
|
259
316
|
emphasisColor: string | null,
|
|
260
317
|
reference: number | null,
|
|
261
318
|
referenceLabel: string | undefined,
|
|
319
|
+
band: { from: number; to: number } | null,
|
|
320
|
+
bandEdges: boolean,
|
|
262
321
|
): CartesianDefinition {
|
|
263
|
-
const frame = frameOf(extentOf, mark, source.length, emphasisColor !== null)
|
|
264
|
-
const
|
|
265
|
-
|
|
322
|
+
const frame = frameOf(extentOf, mark, source.length, emphasisColor !== null, bandEdges)
|
|
323
|
+
const bandMark = (): ChartMarks =>
|
|
324
|
+
band === null
|
|
266
325
|
? []
|
|
267
326
|
: [
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
id: 'reference-label',
|
|
281
|
-
x: () => (mark === 'bar' ? 0 : frame.x[0]),
|
|
282
|
-
y: (v: number) => v,
|
|
283
|
-
text: () => referenceLabel,
|
|
284
|
-
fill: VX.ink2,
|
|
285
|
-
fontSize: VX.text.micro,
|
|
286
|
-
anchor: 'start',
|
|
287
|
-
dx: REFERENCE_LABEL_DX,
|
|
288
|
-
dy: referenceLabelPlacement({
|
|
289
|
-
value: reference,
|
|
290
|
-
domain: frame.y,
|
|
291
|
-
height,
|
|
292
|
-
inset: mark === 'bar' ? 0 : LINE_INSET,
|
|
293
|
-
fontSize: VX.text.micro,
|
|
294
|
-
}).dy,
|
|
295
|
-
}),
|
|
296
|
-
),
|
|
297
|
-
]),
|
|
327
|
+
decorative(
|
|
328
|
+
rect([band], {
|
|
329
|
+
id: 'band',
|
|
330
|
+
x1: () => 0,
|
|
331
|
+
x2: () => 1,
|
|
332
|
+
xScale: 'zx',
|
|
333
|
+
y1: 'from',
|
|
334
|
+
y2: 'to',
|
|
335
|
+
fill: BAND_FILL,
|
|
336
|
+
inset: 0,
|
|
337
|
+
}),
|
|
338
|
+
),
|
|
298
339
|
]
|
|
340
|
+
const referenceMark = (height: number, width: number, rows: readonly Point[]): ChartMarks => {
|
|
341
|
+
if (reference === null) return []
|
|
342
|
+
const place =
|
|
343
|
+
referenceLabel === undefined
|
|
344
|
+
? null
|
|
345
|
+
: referenceLabelPlacement({
|
|
346
|
+
value: reference,
|
|
347
|
+
domain: frame.y,
|
|
348
|
+
height,
|
|
349
|
+
width,
|
|
350
|
+
inset: mark === 'bar' ? 0 : LINE_INSET,
|
|
351
|
+
fontSize: VX.text.micro,
|
|
352
|
+
label: referenceLabel,
|
|
353
|
+
line:
|
|
354
|
+
mark === 'bar'
|
|
355
|
+
? undefined
|
|
356
|
+
: rows.flatMap((r) =>
|
|
357
|
+
r.v === null
|
|
358
|
+
? []
|
|
359
|
+
: [{ fx: (r.i - frame.x[0]) / (frame.x[1] - frame.x[0]), y: r.v }],
|
|
360
|
+
),
|
|
361
|
+
})
|
|
362
|
+
return [
|
|
363
|
+
ruleY([reference], {
|
|
364
|
+
id: 'reference',
|
|
365
|
+
stroke: VX.line,
|
|
366
|
+
strokeOpacity: 1,
|
|
367
|
+
strokeWidth: 1,
|
|
368
|
+
strokeDasharray: DASH,
|
|
369
|
+
}),
|
|
370
|
+
...(referenceLabel === undefined || place === null
|
|
371
|
+
? []
|
|
372
|
+
: [
|
|
373
|
+
decorative(
|
|
374
|
+
text([reference], {
|
|
375
|
+
id: 'reference-label',
|
|
376
|
+
x: () => (place.end === 'end' ? frame.x[1] : mark === 'bar' ? 0 : frame.x[0]),
|
|
377
|
+
y: (v: number) => v,
|
|
378
|
+
text: () => referenceLabel,
|
|
379
|
+
fill: VX.ink2,
|
|
380
|
+
fontSize: VX.text.micro,
|
|
381
|
+
anchor: place.end,
|
|
382
|
+
dx: place.end === 'end' ? -REFERENCE_LABEL_DX : REFERENCE_LABEL_DX,
|
|
383
|
+
dy: place.dy,
|
|
384
|
+
}),
|
|
385
|
+
),
|
|
386
|
+
]),
|
|
387
|
+
]
|
|
388
|
+
}
|
|
299
389
|
return {
|
|
300
390
|
// A bar's hover is the bar and the readout chip: no engine point marker (bar chrome only, as
|
|
301
391
|
// `Bars`).
|
|
@@ -306,7 +396,8 @@ function compileSparkline(
|
|
|
306
396
|
if (mark === 'bar') {
|
|
307
397
|
return {
|
|
308
398
|
marks: [
|
|
309
|
-
...
|
|
399
|
+
...bandMark(),
|
|
400
|
+
...referenceMark(height, width, rows),
|
|
310
401
|
barMark(rows, {
|
|
311
402
|
id: 'bars',
|
|
312
403
|
x: 'i',
|
|
@@ -322,6 +413,8 @@ function compileSparkline(
|
|
|
322
413
|
.padding(BAR_GAP),
|
|
323
414
|
axis: false as const,
|
|
324
415
|
},
|
|
416
|
+
// The band spans the whole plot, outer half-bars included: a unit scale, not the band x.
|
|
417
|
+
...ZONE_X,
|
|
325
418
|
y: {
|
|
326
419
|
scale: scaleLinear().domain(frame.y),
|
|
327
420
|
axis: false as const,
|
|
@@ -334,7 +427,8 @@ function compileSparkline(
|
|
|
334
427
|
}
|
|
335
428
|
return {
|
|
336
429
|
marks: [
|
|
337
|
-
...
|
|
430
|
+
...bandMark(),
|
|
431
|
+
...referenceMark(height, width, rows),
|
|
338
432
|
lineY(rows, {
|
|
339
433
|
id: 'line',
|
|
340
434
|
x: 'i',
|
|
@@ -356,6 +450,7 @@ function compileSparkline(
|
|
|
356
450
|
scale: scaleLinear().domain(frame.x),
|
|
357
451
|
axis: false as const,
|
|
358
452
|
},
|
|
453
|
+
...ZONE_X,
|
|
359
454
|
y: { scale: scaleLinear().domain(frame.y), axis: false as const },
|
|
360
455
|
},
|
|
361
456
|
theme: CHART_THEME,
|
|
@@ -581,18 +676,31 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
581
676
|
state,
|
|
582
677
|
reference,
|
|
583
678
|
referenceLabel,
|
|
679
|
+
band,
|
|
584
680
|
format = defaultNumberFormat,
|
|
585
681
|
labels,
|
|
682
|
+
window: windowProp,
|
|
586
683
|
className,
|
|
587
684
|
style,
|
|
588
685
|
} = props
|
|
589
686
|
const id = useId()
|
|
590
|
-
const
|
|
687
|
+
const slot = useContext(VisualSlotContext)
|
|
688
|
+
const hosted = slot !== null
|
|
689
|
+
const moments = useMemo(() => momentsOf(data), [data])
|
|
690
|
+
const windowText = useMemo(
|
|
691
|
+
() => windowCaption({ prop: windowProp, slot, data, labels, moments }),
|
|
692
|
+
[windowProp, slot, data, labels, moments],
|
|
693
|
+
)
|
|
694
|
+
// The window's row also holds the reference label: out of the plot, no line can run through it.
|
|
695
|
+
const labelInRow = windowText !== undefined && referenceLabel !== undefined
|
|
696
|
+
const plotLabel = labelInRow ? undefined : referenceLabel
|
|
591
697
|
// Two sources, so a pointer leaving a focused chart hands the readout back to the focused point.
|
|
592
698
|
const [hover, setHover] = useState<number | null>(null)
|
|
593
699
|
const [keyed, setKeyed] = useState<number | null>(null)
|
|
594
700
|
const active = hover ?? keyed
|
|
595
701
|
const readoutRef = useRef<HTMLOutputElement>(null)
|
|
702
|
+
const bandFrom = band?.from
|
|
703
|
+
const bandTo = band?.to
|
|
596
704
|
const model = useMemo(() => {
|
|
597
705
|
const rows: Point[] = data.map((d, i) => ({
|
|
598
706
|
i,
|
|
@@ -604,16 +712,51 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
604
712
|
const at = reference === 'mean' ? meanOf(rows) : (reference ?? null)
|
|
605
713
|
const ref = at !== null && Number.isFinite(at) ? at : null
|
|
606
714
|
// The reference is part of the extent, so it is never clipped.
|
|
607
|
-
const
|
|
608
|
-
|
|
715
|
+
const bandSpan =
|
|
716
|
+
bandFrom !== undefined &&
|
|
717
|
+
bandTo !== undefined &&
|
|
718
|
+
Number.isFinite(bandFrom + bandTo) &&
|
|
719
|
+
bandFrom !== bandTo
|
|
720
|
+
? { from: Math.min(bandFrom, bandTo), to: Math.max(bandFrom, bandTo) }
|
|
721
|
+
: null
|
|
722
|
+
const edges = [ref, bandSpan?.from, bandSpan?.to].filter(
|
|
723
|
+
(v): v is number => typeof v === 'number',
|
|
724
|
+
)
|
|
725
|
+
const full: readonly [number, number] = [
|
|
726
|
+
Math.min(range[0], ...edges),
|
|
727
|
+
Math.max(range[1], ...edges),
|
|
728
|
+
]
|
|
609
729
|
const end = emphasizeLast ? emphasisColor : null
|
|
730
|
+
// A band that sets the domain's edge gets the wider air; one inside the data leaves it alone.
|
|
731
|
+
const bandEdges = full[0] < range[0] || full[1] > range[1]
|
|
610
732
|
return {
|
|
611
733
|
rows,
|
|
612
|
-
moments
|
|
613
|
-
frame: frameOf(full, mark, rows.length, end !== null),
|
|
614
|
-
definition: compileSparkline(
|
|
734
|
+
moments,
|
|
735
|
+
frame: frameOf(full, mark, rows.length, end !== null, bandSpan !== null && bandEdges),
|
|
736
|
+
definition: compileSparkline(
|
|
737
|
+
rows,
|
|
738
|
+
full,
|
|
739
|
+
mark,
|
|
740
|
+
color,
|
|
741
|
+
end,
|
|
742
|
+
ref,
|
|
743
|
+
plotLabel,
|
|
744
|
+
bandSpan,
|
|
745
|
+
bandSpan !== null && bandEdges,
|
|
746
|
+
),
|
|
615
747
|
}
|
|
616
|
-
}, [
|
|
748
|
+
}, [
|
|
749
|
+
data,
|
|
750
|
+
moments,
|
|
751
|
+
mark,
|
|
752
|
+
color,
|
|
753
|
+
emphasizeLast,
|
|
754
|
+
emphasisColor,
|
|
755
|
+
reference,
|
|
756
|
+
plotLabel,
|
|
757
|
+
bandFrom,
|
|
758
|
+
bandTo,
|
|
759
|
+
])
|
|
617
760
|
const resolved = resolveChartState(state)
|
|
618
761
|
const rows = model?.rows
|
|
619
762
|
const interactive = resolved === null && model !== null
|
|
@@ -732,10 +875,11 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
732
875
|
}),
|
|
733
876
|
...(at.fy > 0.5 ? { top: 0 } : { bottom: 0 }),
|
|
734
877
|
}
|
|
735
|
-
|
|
878
|
+
const plot = (
|
|
736
879
|
<div
|
|
737
880
|
data-basalt-sparkline=""
|
|
738
881
|
{...(hosted && { 'data-basalt-hosted': '' })}
|
|
882
|
+
{...(shown && { 'data-basalt-readout': '' })}
|
|
739
883
|
role="presentation"
|
|
740
884
|
className={cx(classes.root, className)}
|
|
741
885
|
style={{ width: width ?? '100%', height, minWidth: 0, ...style }}
|
|
@@ -748,7 +892,14 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
748
892
|
setKeyed(null)
|
|
749
893
|
}}
|
|
750
894
|
>
|
|
751
|
-
{resolved !== null &&
|
|
895
|
+
{resolved !== null && (
|
|
896
|
+
<ChartPlaceholder
|
|
897
|
+
state={state}
|
|
898
|
+
height={height}
|
|
899
|
+
compact
|
|
900
|
+
ghost={mark === 'bar' ? 'bars' : 'line'}
|
|
901
|
+
/>
|
|
902
|
+
)}
|
|
752
903
|
{resolved === null && model !== null && (
|
|
753
904
|
<ChartEngine
|
|
754
905
|
definition={model.definition}
|
|
@@ -758,7 +909,7 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
758
909
|
coarse={false}
|
|
759
910
|
/>
|
|
760
911
|
)}
|
|
761
|
-
{at !== null && (
|
|
912
|
+
{shown && at !== null && (
|
|
762
913
|
// One layer on the plot rect (inside a line's margin): the dot and the readout take their
|
|
763
914
|
// fractions of the same box, so both land where the mark did. A bar has no dot: the bar
|
|
764
915
|
// is the marker.
|
|
@@ -789,4 +940,18 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
789
940
|
)}
|
|
790
941
|
</div>
|
|
791
942
|
)
|
|
943
|
+
if (windowText === undefined) return plot
|
|
944
|
+
return (
|
|
945
|
+
<div className={classes.frame} style={{ width: width ?? '100%' }}>
|
|
946
|
+
{plot}
|
|
947
|
+
<div className={classes.caption} data-basalt-sparkline-caption="">
|
|
948
|
+
<span data-basalt-sparkline-window="">{windowText}</span>
|
|
949
|
+
{labelInRow && (
|
|
950
|
+
<span className={classes.key} data-basalt-sparkline-key="">
|
|
951
|
+
{referenceLabel}
|
|
952
|
+
</span>
|
|
953
|
+
)}
|
|
954
|
+
</div>
|
|
955
|
+
</div>
|
|
956
|
+
)
|
|
792
957
|
}
|
|
@@ -125,6 +125,16 @@
|
|
|
125
125
|
stroke-linejoin: round;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
.ghostBand {
|
|
129
|
+
flex: 1 1 0;
|
|
130
|
+
min-width: 0;
|
|
131
|
+
align-self: stretch;
|
|
132
|
+
/* The loaded strip is one row above its axis labels: the row keeps their room. */
|
|
133
|
+
margin-bottom: var(--basalt-ghost-band-axis, 1.5rem);
|
|
134
|
+
border-radius: 3px;
|
|
135
|
+
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
136
|
+
}
|
|
137
|
+
|
|
128
138
|
.ghostBar {
|
|
129
139
|
flex: 1 1 0;
|
|
130
140
|
min-width: 0;
|
|
@@ -132,6 +142,46 @@
|
|
|
132
142
|
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
133
143
|
}
|
|
134
144
|
|
|
145
|
+
/*
|
|
146
|
+
* The empty body (SPEC § 6.11): a ring-edged tile (one inset ring, set inline in `state.tsx` so the divider ledger does not read it as a rule; card radius) filling the chart's
|
|
147
|
+
* own box, so the D37 height holds, with its copy centred: the title at `sm` 500, the size of the
|
|
148
|
+
* host's own title in every chart host, and one muted line. `EmptyState`'s section anatomy, in plain CSS
|
|
149
|
+
* because `src/charts/**` is Mantine-free.
|
|
150
|
+
*/
|
|
151
|
+
.emptyTile {
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: column;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
gap: var(--vx-space-stack-xs, 0.25rem);
|
|
158
|
+
width: 100%;
|
|
159
|
+
height: 100%;
|
|
160
|
+
padding: var(--vx-space-stack-md) var(--vx-space-stack-lg);
|
|
161
|
+
overflow: hidden;
|
|
162
|
+
text-align: center;
|
|
163
|
+
border-radius: var(--vx-radius-card);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.emptyCopy {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
align-items: center;
|
|
170
|
+
gap: var(--vx-space-stack-xs, 0.25rem);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.emptyTitle {
|
|
174
|
+
font-size: var(--vx-text-sm);
|
|
175
|
+
font-weight: 500;
|
|
176
|
+
color: var(--vx-ink);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.emptyText {
|
|
180
|
+
max-width: 22.5rem;
|
|
181
|
+
font-size: var(--vx-text-sm);
|
|
182
|
+
color: var(--vx-muted);
|
|
183
|
+
}
|
|
184
|
+
|
|
135
185
|
/*
|
|
136
186
|
* The engine paints its tooltip rows as a grid of `.55rem | minmax(0, 1fr) | auto` with inline
|
|
137
187
|
* styles and `overflow-wrap: anywhere` on the card, so a narrow tooltip (a 390 viewport, a pointer
|
|
@@ -169,9 +219,16 @@
|
|
|
169
219
|
|
|
170
220
|
/* The engine focuses the plot's `svg.ts-chart` (tabindex 0), not the `.basalt-chart` wrapper
|
|
171
221
|
* `styles.css` rings, so the UA's `auto` ring paints (a 5px white double ring in dark): the same
|
|
172
|
-
* 2px accent ring
|
|
222
|
+
* 2px accent ring. The ring is INSET: an outer one is clipped by the card body's overflow at the
|
|
223
|
+
* plot's right and bottom edges (partial edges), an inset one is whole wherever the chart sits. */
|
|
173
224
|
:global(.basalt-chart .ts-chart:focus-visible) {
|
|
174
225
|
outline: 2px solid var(--vx-accent);
|
|
226
|
+
outline-offset: calc(-0.125rem * var(--mantine-scale));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* A Sparkline keeps the outer ring: its cell reserves the clearance (the readout chip and the end
|
|
230
|
+
* marker are placed against it) and an inset ring would cross the end marker. */
|
|
231
|
+
:global([data-basalt-sparkline] .basalt-chart .ts-chart:focus-visible) {
|
|
175
232
|
outline-offset: calc(0.125rem * var(--mantine-scale));
|
|
176
233
|
}
|
|
177
234
|
|
|
@@ -188,7 +245,7 @@
|
|
|
188
245
|
box-sizing: border-box;
|
|
189
246
|
width: max-content;
|
|
190
247
|
/* The line the cell reserves (1.125rem) less the focus ring's clearance (2px outline + 0.125rem offset) and 1px of air, so
|
|
191
|
-
* the chip sits clear of the ring and still inside the reserve. */
|
|
248
|
+
* the chip sits clear of the ring and still inside the reserve. The Sparkline's ring is the outer one. */
|
|
192
249
|
block-size: calc(1.125rem - 0.3125rem);
|
|
193
250
|
padding: 0 4px !important;
|
|
194
251
|
overflow: hidden;
|
|
@@ -11,6 +11,11 @@ declare const classes: {
|
|
|
11
11
|
readonly grow: string
|
|
12
12
|
readonly ghost: string
|
|
13
13
|
readonly ghostLine: string
|
|
14
|
+
readonly ghostBand: string
|
|
14
15
|
readonly ghostBar: string
|
|
16
|
+
readonly emptyTile: string
|
|
17
|
+
readonly emptyCopy: string
|
|
18
|
+
readonly emptyTitle: string
|
|
19
|
+
readonly emptyText: string
|
|
15
20
|
}
|
|
16
21
|
export default classes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* ChartCard's header inset, by the card's own inline size (W10 SSR contract). A card under 480px
|
|
3
|
-
* trims the header's top inset: the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* is CONTAINER_CLASSES.regular (`breakpoint-literals.test.ts`).
|
|
3
|
+
* trims the header's top inset: the chart below is sized by the 160–420px law, so a narrow card is
|
|
4
|
+
* a short one. Decided in CSS, not from a post-hydration height measurement, so the server HTML is
|
|
5
|
+
* the hydrated header. The literal is CONTAINER_CLASSES.regular (`breakpoint-literals.test.ts`).
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
.header {
|
|
@@ -16,13 +15,8 @@
|
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
/* A short card
|
|
20
|
-
*
|
|
21
|
-
/* (`data-basalt-chart-short` is written by `ChartBox`, `box.tsx`; the same `:is` is in
|
|
22
|
-
* `dashboard/widget-header.module.css`.) */
|
|
23
|
-
:is([data-basalt-card-short], [data-basalt-chart-card]:has([data-basalt-chart-short])) .header {
|
|
24
|
-
padding-top: 4px;
|
|
25
|
-
}
|
|
18
|
+
/* A short card keeps this inset too, so its title shares a baseline with a tall neighbour in the
|
|
19
|
+
* row; its other short-state rules (the folded subtitle) live in `dashboard/widget-header.module.css`. */
|
|
26
20
|
|
|
27
21
|
/*
|
|
28
22
|
* The facts line (`facts` prop): the headline figure under the title, in place of a subtitle. It wraps
|
|
@@ -72,26 +66,34 @@
|
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
/*
|
|
75
|
-
* A fact's tone is INK only (
|
|
76
|
-
*
|
|
69
|
+
* A fact's tone is INK only (never a fill) and rides the DELTA alone: the comparison, with its direction
|
|
70
|
+
* glyph. The value, unit and period stay ink and muted. A fact with no comparison has no delta, so its
|
|
71
|
+
* tone inks the value (`.factTone` is on whichever element carries it). The status solids are the
|
|
72
|
+
* text-safe ones (`status-text.ts`). `stale` is the strip cell's dimmed value, verbatim
|
|
77
73
|
* (`stat-strip.module.css` `.cell[data-stale]`).
|
|
78
74
|
*/
|
|
79
|
-
.fact[data-tone='good']
|
|
75
|
+
.fact[data-tone='good'] .factTone {
|
|
80
76
|
color: var(--vx-status-good);
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
.fact[data-tone='warn']
|
|
79
|
+
.fact[data-tone='warn'] .factTone {
|
|
84
80
|
color: var(--vx-status-warn);
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
.fact[data-tone='bad']
|
|
83
|
+
.fact[data-tone='bad'] .factTone {
|
|
88
84
|
color: var(--vx-status-bad);
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
.fact[data-tone='muted']
|
|
87
|
+
.fact[data-tone='muted'] .factTone {
|
|
92
88
|
color: var(--vx-muted);
|
|
93
89
|
}
|
|
94
90
|
|
|
91
|
+
/* The direction glyph of a plain-text comparison: DeltaBadge's (`widget-header.module.css` `.deltaGlyph`). */
|
|
92
|
+
.factGlyph {
|
|
93
|
+
margin-inline-end: 3px;
|
|
94
|
+
font-size: var(--vx-text-micro);
|
|
95
|
+
}
|
|
96
|
+
|
|
95
97
|
.factsRow[data-stale] {
|
|
96
98
|
opacity: 0.55;
|
|
97
99
|
}
|
|
@@ -129,3 +131,12 @@
|
|
|
129
131
|
border-radius: 3px;
|
|
130
132
|
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
131
133
|
}
|
|
134
|
+
|
|
135
|
+
/* A pending `BandStrip` card keeps the room of the legend row the loaded strip carries under its box:
|
|
136
|
+
* the chart root's 6px gap plus one legend line (`micro` x 1.35 and the 2px entry border, `legend.tsx`).
|
|
137
|
+
* The legend shows from 240px, the same container class the chart picks it by. */
|
|
138
|
+
@container basalt-card (min-width: 240px) {
|
|
139
|
+
.legendReserve {
|
|
140
|
+
padding-bottom: calc(6px + var(--vx-text-micro) * 1.35 + 2px);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -11,7 +11,10 @@ declare const classes: {
|
|
|
11
11
|
readonly factValue: string
|
|
12
12
|
readonly factUnit: string
|
|
13
13
|
readonly factPeriod: string
|
|
14
|
+
readonly factTone: string
|
|
15
|
+
readonly factGlyph: string
|
|
14
16
|
readonly skeletonFigure: string
|
|
15
17
|
readonly skeletonBasis: string
|
|
18
|
+
readonly legendReserve: string
|
|
16
19
|
}
|
|
17
20
|
export default classes
|