basalt-ui 2.18.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.
Files changed (183) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/MIGRATING.md +238 -12
  3. package/agent/agents/basalt-design-reviewer.md +2 -2
  4. package/agent/rules/basalt-charts.md +1 -1
  5. package/agent/rules/basalt-mantine.md +1 -1
  6. package/agent/skills/basalt-app/SKILL.md +1 -1
  7. package/agent/skills/basalt-design/SKILL.md +1 -1
  8. package/agent/templates/DESIGN.md.tpl +1 -1
  9. package/configs/oxlint-plugin.js +33 -19
  10. package/configs/oxlint-plugin.test.ts +32 -2
  11. package/dist/charts/ChartCard.d.ts +28 -3
  12. package/dist/charts/ChartCard.d.ts.map +1 -1
  13. package/dist/charts/ChartCard.js +33 -11
  14. package/dist/charts/Donut.d.ts.map +1 -1
  15. package/dist/charts/Donut.js +13 -1
  16. package/dist/charts/Heatmap.js +1 -1
  17. package/dist/charts/Sparkline.d.ts +7 -1
  18. package/dist/charts/Sparkline.d.ts.map +1 -1
  19. package/dist/charts/Sparkline.js +137 -18
  20. package/dist/charts/box.d.ts +2 -0
  21. package/dist/charts/box.d.ts.map +1 -1
  22. package/dist/charts/box.js +2 -0
  23. package/dist/charts/chart-box.module.css +30 -0
  24. package/dist/charts/chart-box.module.css.d.ts +1 -0
  25. package/dist/charts/chart-card.module.css +47 -0
  26. package/dist/charts/chart-card.module.css.d.ts +7 -0
  27. package/dist/charts/compile.d.ts.map +1 -1
  28. package/dist/charts/compile.js +35 -8
  29. package/dist/charts/host.d.ts.map +1 -1
  30. package/dist/charts/host.js +2 -1
  31. package/dist/charts/index.d.ts +1 -1
  32. package/dist/charts/index.d.ts.map +1 -1
  33. package/dist/charts/sparkline.module.css +59 -0
  34. package/dist/charts/sparkline.module.css.d.ts +13 -0
  35. package/dist/charts/state.d.ts.map +1 -1
  36. package/dist/charts/state.js +32 -4
  37. package/dist/charts/types.d.ts +6 -0
  38. package/dist/charts/types.d.ts.map +1 -1
  39. package/dist/commands/notifications/center.d.ts.map +1 -1
  40. package/dist/commands/notifications/center.js +18 -26
  41. package/dist/content/callout.d.ts +1 -1
  42. package/dist/content/callout.d.ts.map +1 -1
  43. package/dist/content/callout.js +10 -1
  44. package/dist/content/callout.module.css +15 -3
  45. package/dist/content/callout.module.css.d.ts +1 -0
  46. package/dist/controls/sync-button.d.ts +3 -0
  47. package/dist/controls/sync-button.d.ts.map +1 -1
  48. package/dist/dashboard/bar-list.d.ts +15 -4
  49. package/dist/dashboard/bar-list.d.ts.map +1 -1
  50. package/dist/dashboard/bar-list.js +56 -19
  51. package/dist/dashboard/bar-list.module.css +110 -17
  52. package/dist/dashboard/bar-list.module.css.d.ts +2 -0
  53. package/dist/dashboard/delta-badge.d.ts +8 -3
  54. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  55. package/dist/dashboard/delta-badge.js +9 -2
  56. package/dist/dashboard/index.d.ts +2 -0
  57. package/dist/dashboard/index.d.ts.map +1 -1
  58. package/dist/dashboard/meter-model.d.ts +68 -1
  59. package/dist/dashboard/meter-model.d.ts.map +1 -1
  60. package/dist/dashboard/meter-model.js +65 -4
  61. package/dist/dashboard/meter-parts.d.ts +5 -1
  62. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  63. package/dist/dashboard/meter-parts.js +234 -60
  64. package/dist/dashboard/meter.d.ts +38 -6
  65. package/dist/dashboard/meter.d.ts.map +1 -1
  66. package/dist/dashboard/meter.js +4 -1
  67. package/dist/dashboard/meter.module.css +209 -13
  68. package/dist/dashboard/meter.module.css.d.ts +16 -0
  69. package/dist/dashboard/query-state.d.ts.map +1 -1
  70. package/dist/dashboard/query-state.js +14 -9
  71. package/dist/dashboard/settings-section.d.ts.map +1 -1
  72. package/dist/dashboard/settings-section.js +14 -25
  73. package/dist/dashboard/stat-card-parts.d.ts +3 -1
  74. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  75. package/dist/dashboard/stat-card-parts.js +18 -3
  76. package/dist/dashboard/stat-card.d.ts +7 -6
  77. package/dist/dashboard/stat-card.d.ts.map +1 -1
  78. package/dist/dashboard/stat-card.js +51 -83
  79. package/dist/dashboard/stat-card.module.css +42 -14
  80. package/dist/dashboard/stat-group.d.ts +11 -2
  81. package/dist/dashboard/stat-group.d.ts.map +1 -1
  82. package/dist/dashboard/stat-group.js +9 -7
  83. package/dist/dashboard/stat-strip.d.ts +50 -0
  84. package/dist/dashboard/stat-strip.d.ts.map +1 -0
  85. package/dist/dashboard/stat-strip.js +85 -0
  86. package/dist/dashboard/stat-strip.module.css +208 -0
  87. package/dist/dashboard/stat-strip.module.css.d.ts +28 -0
  88. package/dist/dashboard/widget-header.d.ts +3 -3
  89. package/dist/dashboard/widget-header.d.ts.map +1 -1
  90. package/dist/dashboard/widget-header.js +2 -1
  91. package/dist/dashboard/widget-header.module.css +38 -7
  92. package/dist/format/date.d.ts.map +1 -1
  93. package/dist/format/date.js +4 -3
  94. package/dist/format/shared.d.ts +6 -0
  95. package/dist/format/shared.d.ts.map +1 -1
  96. package/dist/format/shared.js +6 -2
  97. package/dist/guard/index.d.ts +1 -1
  98. package/dist/guard/index.js +1 -1
  99. package/dist/index.d.ts +3 -1
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +4 -0
  102. package/dist/styles.css +6 -0
  103. package/dist/theme/card-inset.module.css +76 -0
  104. package/dist/theme/card-inset.module.css.d.ts +9 -0
  105. package/dist/theme/chrome-vars.d.ts +29 -17
  106. package/dist/theme/chrome-vars.d.ts.map +1 -1
  107. package/dist/theme/chrome-vars.js +18 -8
  108. package/dist/theme/controls.module.css +3 -0
  109. package/dist/theme/index.d.ts.map +1 -1
  110. package/dist/theme/index.js +32 -5
  111. package/dist/theme/nav-link.module.css +8 -10
  112. package/dist/theme/status-dot.d.ts +7 -0
  113. package/dist/theme/status-dot.d.ts.map +1 -0
  114. package/dist/theme/status-dot.js +18 -0
  115. package/dist/theme/status-dot.module.css +9 -0
  116. package/dist/theme/status-dot.module.css.d.ts +8 -0
  117. package/dist/theme/status-verdict.d.ts +10 -0
  118. package/dist/theme/status-verdict.d.ts.map +1 -0
  119. package/dist/theme/status-verdict.js +14 -0
  120. package/dist/theme/status-verdict.module.css +25 -0
  121. package/dist/theme/status-verdict.module.css.d.ts +9 -0
  122. package/llms.txt +30 -6
  123. package/package.json +1 -1
  124. package/src/charts/ChartCard.tsx +70 -4
  125. package/src/charts/Donut.tsx +9 -1
  126. package/src/charts/Heatmap.tsx +1 -1
  127. package/src/charts/Sparkline.tsx +180 -18
  128. package/src/charts/box.tsx +2 -0
  129. package/src/charts/chart-box.module.css +30 -0
  130. package/src/charts/chart-box.module.css.d.ts +1 -0
  131. package/src/charts/chart-card.module.css +47 -0
  132. package/src/charts/chart-card.module.css.d.ts +7 -0
  133. package/src/charts/compile.ts +42 -9
  134. package/src/charts/host.tsx +6 -3
  135. package/src/charts/index.ts +1 -1
  136. package/src/charts/sparkline.module.css +59 -0
  137. package/src/charts/sparkline.module.css.d.ts +13 -0
  138. package/src/charts/state.tsx +44 -4
  139. package/src/charts/types.ts +6 -0
  140. package/src/commands/notifications/center.tsx +29 -32
  141. package/src/content/callout.module.css +15 -3
  142. package/src/content/callout.module.css.d.ts +1 -0
  143. package/src/content/callout.tsx +15 -2
  144. package/src/controls/sync-button.tsx +3 -0
  145. package/src/dashboard/bar-list.module.css +110 -17
  146. package/src/dashboard/bar-list.module.css.d.ts +2 -0
  147. package/src/dashboard/bar-list.tsx +102 -21
  148. package/src/dashboard/delta-badge.tsx +21 -5
  149. package/src/dashboard/index.ts +2 -0
  150. package/src/dashboard/meter-model.ts +132 -4
  151. package/src/dashboard/meter-parts.tsx +305 -25
  152. package/src/dashboard/meter.module.css +209 -13
  153. package/src/dashboard/meter.module.css.d.ts +16 -0
  154. package/src/dashboard/meter.tsx +42 -7
  155. package/src/dashboard/query-state.tsx +28 -19
  156. package/src/dashboard/settings-section.tsx +1 -8
  157. package/src/dashboard/stat-card-parts.tsx +22 -2
  158. package/src/dashboard/stat-card.module.css +42 -14
  159. package/src/dashboard/stat-card.tsx +23 -60
  160. package/src/dashboard/stat-group.tsx +19 -8
  161. package/src/dashboard/stat-strip.module.css +208 -0
  162. package/src/dashboard/stat-strip.module.css.d.ts +28 -0
  163. package/src/dashboard/stat-strip.tsx +183 -0
  164. package/src/dashboard/widget-header.module.css +38 -7
  165. package/src/dashboard/widget-header.tsx +7 -4
  166. package/src/format/date.ts +6 -3
  167. package/src/format/shared.ts +11 -2
  168. package/src/guard/index.ts +1 -1
  169. package/src/index.ts +7 -0
  170. package/src/styles.css +6 -0
  171. package/src/theme/__snapshots__/plain-theme.test.ts.snap +242 -26
  172. package/src/theme/card-inset.module.css +76 -0
  173. package/src/theme/card-inset.module.css.d.ts +9 -0
  174. package/src/theme/chrome-vars.ts +48 -23
  175. package/src/theme/controls.module.css +3 -0
  176. package/src/theme/index.ts +40 -6
  177. package/src/theme/nav-link.module.css +8 -10
  178. package/src/theme/status-dot.module.css +9 -0
  179. package/src/theme/status-dot.module.css.d.ts +8 -0
  180. package/src/theme/status-dot.tsx +31 -0
  181. package/src/theme/status-verdict.module.css +25 -0
  182. package/src/theme/status-verdict.module.css.d.ts +9 -0
  183. package/src/theme/status-verdict.tsx +32 -0
@@ -5,7 +5,7 @@
5
5
  import type { CSSProperties, ReactElement, ReactNode } from 'react'
6
6
  import { toErrorMessage } from '../common/errors'
7
7
  import { VX } from '../tokens'
8
- import { ChartBox, stateClass } from './box'
8
+ import { ChartBox, growClass, stateClass } from './box'
9
9
  import type { ChartBoxHeight } from './box'
10
10
  import type { ChartState } from './types'
11
11
 
@@ -36,6 +36,36 @@ const pendingStyle: CSSProperties = {
36
36
  background: `linear-gradient(90deg, transparent, ${VX.surface.subtle}, transparent)`,
37
37
  }
38
38
 
39
+ // The error idiom (D28, SPEC § 6.12): a status dot + a word + the message + the action, on the
40
+ // neutral surface. The dot is drawn from `--vx-*` tokens here — `src/charts/**` stays Mantine-free and `theme/status-dot` sits in the
41
+ // Mantine-coupled theme layer.
42
+ const dotStyle: CSSProperties = {
43
+ display: 'inline-block',
44
+ flex: 'none',
45
+ width: 6,
46
+ height: 6,
47
+ // theme-allow raw-surface — a 6px status dot, not a surface
48
+ borderRadius: '50%',
49
+ background: VX.status.bad,
50
+ }
51
+ // StatCard's error anatomy (`ErrorState` at the section tier): a left-aligned stack, never centred.
52
+ const errorStyle: CSSProperties = {
53
+ ...boxStyle,
54
+ alignItems: 'flex-start',
55
+ textAlign: 'start',
56
+ fontSize: VX.text.sm,
57
+ gap: VX.space.controlGap,
58
+ }
59
+ const errorHeadStyle: CSSProperties = {
60
+ display: 'inline-flex',
61
+ alignItems: 'center',
62
+ gap: VX.space.controlGap,
63
+ color: VX.ink,
64
+ fontWeight: 500,
65
+ }
66
+
67
+ const errorMessageStyle: CSSProperties = { color: VX.muted }
68
+
39
69
  const emptyLabel = (state: ChartState | undefined): string =>
40
70
  typeof state?.empty === 'string' ? state.empty : 'No data'
41
71
 
@@ -51,9 +81,13 @@ export function ChartPlaceholder(props: {
51
81
  }): ReactElement | null {
52
82
  const kind = resolveChartState(props.state)
53
83
  if (kind === null) return null
54
- const style = kind === 'pending' ? pendingStyle : boxStyle
84
+ const style = kind === 'pending' ? pendingStyle : kind === 'error' ? errorStyle : boxStyle
85
+ // An error GROWS past the final chart's height rather than clip its action: the box's height is
86
+ // the floor, not the size.
55
87
  const fit = (node: ReactElement): ReactElement => (
56
- <ChartBox height={props.height}>{node}</ChartBox>
88
+ <ChartBox height={props.height} {...(kind === 'error' && { className: growClass })}>
89
+ {node}
90
+ </ChartBox>
57
91
  )
58
92
  if (kind === 'pending')
59
93
  return fit(
@@ -67,7 +101,13 @@ export function ChartPlaceholder(props: {
67
101
  <span aria-hidden="true">—</span>
68
102
  ) : (
69
103
  <>
70
- <span>{label}</span>
104
+ {kind === 'error' && (
105
+ <span style={errorHeadStyle}>
106
+ <span aria-hidden="true" data-basalt-status-dot="" style={dotStyle} />
107
+ Could not load this chart
108
+ </span>
109
+ )}
110
+ <span style={errorMessageStyle}>{label}</span>
71
111
  {props.action}
72
112
  </>
73
113
  )
@@ -154,6 +154,12 @@ export type RefLine = {
154
154
  color: string
155
155
  dashed?: boolean | undefined
156
156
  axis?: 'left' | 'right' | undefined
157
+ /**
158
+ * Names the line on the plot: a small muted caption at the plot's right end (left end for a
159
+ * right-axis line, clear of its tick labels), above the line, below it near the plot's top. It
160
+ * follows the legend toggle. The ink is `--vx-ink2`, never the line colour.
161
+ */
162
+ label?: string | undefined
157
163
  /**
158
164
  * Names the line in the legend (its color, dashed as `dashed`; a toggle hides the line), so a
159
165
  * threshold needs no always-`null` series. `mark` is the swatch shape. Default `'line'`. The
@@ -30,28 +30,20 @@ import {
30
30
  import type { BasaltProps } from '../../common/props'
31
31
  import { cx } from '../../common/props'
32
32
  import { relativeTime } from '../../format'
33
+ import { StatusVerdict } from '../../theme/status-verdict'
33
34
  import { VX } from '../../tokens'
34
35
  import { resolveAction } from './define-notifications'
35
36
  import { useNotificationHistory } from './store'
36
37
  import type { NotificationHistoryItem, NotificationIntent } from './store'
37
38
 
38
- // ── Intent → Mantine color (drives the action Button's own `light`-variant tint) ──────────────
39
-
40
- const INTENT_COLOR: Record<NotificationIntent, string> = {
41
- success: 'green',
42
- error: 'red',
43
- warning: 'yellow',
44
- info: 'blue',
45
- }
46
-
47
- // ── Intent → status token (docs/DESIGN-SPEC.md §5: "severity accents via status tokens") — the
48
- // exact spec success/warning/danger hex, used for the item's left-border accent. `info` has no
49
- // status tone, so it reads the neutral accent instead.
50
- const INTENT_STATUS: Record<NotificationIntent, string> = {
51
- success: VX.status.good,
52
- error: VX.status.bad,
53
- warning: VX.status.warn,
54
- info: VX.accent,
39
+ // ── Intent → the action Button's Mantine tint, the status dot colour and the visible word beside
40
+ // it (docs/DESIGN-SPEC.md §5: severity via status tokens). `info` has no status tone, so its dot is
41
+ // the neutral muted ink, not the accent.
42
+ const INTENT_META: Record<NotificationIntent, { color: string; dot: string; word: string }> = {
43
+ success: { color: 'green', dot: VX.status.good, word: 'Success' },
44
+ error: { color: 'red', dot: VX.status.bad, word: 'Error' },
45
+ warning: { color: 'yellow', dot: VX.status.warn, word: 'Warning' },
46
+ info: { color: 'blue', dot: VX.muted, word: 'Info' },
55
47
  }
56
48
 
57
49
  type CenterView = 'inbox' | 'all'
@@ -78,8 +70,7 @@ function NotificationItem({
78
70
  }) {
79
71
  const isUnread = item.readAt === undefined
80
72
  const isDismissed = item.dismissedAt !== undefined
81
- const color = INTENT_COLOR[item.intent]
82
- const statusAccent = INTENT_STATUS[item.intent]
73
+ const { color, dot, word } = INTENT_META[item.intent]
83
74
  const resolved = item.action !== undefined ? resolveAction(item.action) : undefined
84
75
 
85
76
  function handleAction(e: MouseEvent): void {
@@ -101,7 +92,6 @@ function NotificationItem({
101
92
  onClick={isUnread ? () => onMarkRead(item.id) : undefined}
102
93
  style={{
103
94
  cursor: isUnread ? 'pointer' : 'default',
104
- borderInlineStart: `3px solid ${statusAccent}`,
105
95
  borderRadius: 'var(--mantine-radius-sm)',
106
96
  background: isUnread ? 'var(--mantine-color-default-hover)' : 'transparent',
107
97
  opacity: isDismissed ? 0.55 : 1,
@@ -109,19 +99,26 @@ function NotificationItem({
109
99
  >
110
100
  <Group gap="xs" align="flex-start" wrap="nowrap">
111
101
  <Stack gap={2} style={{ minWidth: 0, flex: 1 }}>
112
- {item.title !== undefined && (
113
- <Text size="sm" fw={isUnread ? 600 : 500} lh={1.2} truncate="end">
114
- {item.title}
115
- </Text>
102
+ {item.title !== undefined ? (
103
+ <>
104
+ <Group gap="xs" align="center" wrap="nowrap">
105
+ <StatusVerdict color={dot} word={word} />
106
+ <Text size="sm" fw={isUnread ? 600 : 500} lh={1.2} miw={0} truncate="end">
107
+ {item.title}
108
+ </Text>
109
+ </Group>
110
+ <Text size="sm" lh={1.3} c="dimmed" style={{ wordBreak: 'break-word' }}>
111
+ {item.message}
112
+ </Text>
113
+ </>
114
+ ) : (
115
+ <Group gap="xs" align="flex-start" wrap="nowrap">
116
+ <StatusVerdict color={dot} word={word} />
117
+ <Text size="sm" lh={1.3} miw={0} style={{ wordBreak: 'break-word' }}>
118
+ {item.message}
119
+ </Text>
120
+ </Group>
116
121
  )}
117
- <Text
118
- size="sm"
119
- lh={1.3}
120
- {...(item.title !== undefined && { c: 'dimmed' })}
121
- style={{ wordBreak: 'break-word' }}
122
- >
123
- {item.message}
124
- </Text>
125
122
  <Group gap="xs" align="center" mt={2} wrap="nowrap">
126
123
  <Text ff="monospace" c="var(--vx-faint)" style={{ fontSize: VX.text.micro }}>
127
124
  {relativeTime(item.createdAt, { style: 'short' })}
@@ -1,13 +1,12 @@
1
1
  /*
2
- * Callout — a soft tinted panel with a left rail, keyed to one of the four semantic tokens.
3
- * `--callout-ink` is set per kind below and consumed by both the rail/bg tint and the title/icon
2
+ * Callout — a soft tinted panel, keyed to one of the four semantic tokens.
3
+ * `--callout-ink` is set per kind below and consumed by both the bg tint and the title/icon
4
4
  * color — one custom property, no per-kind duplication.
5
5
  */
6
6
 
7
7
  .root {
8
8
  border-radius: var(--vx-radius-card);
9
9
  padding: var(--vx-space-callout-inset-y) var(--vx-space-callout-inset-x);
10
- border-left: 2px solid var(--callout-ink);
11
10
  background: color-mix(in srgb, var(--callout-ink) 8%, transparent);
12
11
  }
13
12
 
@@ -56,6 +55,7 @@
56
55
  }
57
56
 
58
57
  .body {
58
+ position: relative;
59
59
  font-size: var(--vx-text-md);
60
60
  color: var(--vx-ink2);
61
61
  }
@@ -75,3 +75,15 @@
75
75
  .body p {
76
76
  margin: 0 0 var(--vx-space-stack-sm);
77
77
  }
78
+
79
+ /* The kind as a word for assistive tech; visually hidden. */
80
+ .kindWord {
81
+ position: absolute;
82
+ width: 1px;
83
+ height: 1px;
84
+ margin: -1px;
85
+ padding: 0;
86
+ overflow: hidden;
87
+ clip-path: inset(50%);
88
+ white-space: nowrap;
89
+ }
@@ -12,5 +12,6 @@ declare const classes: {
12
12
  readonly icon: string
13
13
  readonly title: string
14
14
  readonly body: string
15
+ readonly kindWord: string
15
16
  }
16
17
  export default classes
@@ -21,7 +21,7 @@ import classes from './callout.module.css'
21
21
  export type CalloutKind = 'info' | 'good' | 'warn' | 'bad'
22
22
 
23
23
  export type CalloutProps = BasaltProps & {
24
- /** Semantic kind — drives the rail/tint color and the default icon. Default `'info'`. */
24
+ /** Semantic kind — drives the tint color and the default icon. Default `'info'`. */
25
25
  readonly kind?: CalloutKind
26
26
  readonly title?: string
27
27
  /** Overrides the default per-kind icon. Only rendered alongside a `title`. */
@@ -77,6 +77,14 @@ function BadGlyph() {
77
77
  )
78
78
  }
79
79
 
80
+ // The kind as a word for assistive tech, so a title-less callout is never tint-only.
81
+ const KIND_WORD: Record<CalloutKind, string> = {
82
+ info: 'Info',
83
+ good: 'Success',
84
+ warn: 'Warning',
85
+ bad: 'Error',
86
+ }
87
+
80
88
  const DEFAULT_ICON: Record<CalloutKind, ReactNode> = {
81
89
  info: <InfoGlyph />,
82
90
  good: <GoodGlyph />,
@@ -96,7 +104,12 @@ export function Callout({ kind = 'info', title, icon, children, className, style
96
104
  <span className={classes.title}>{title}</span>
97
105
  </div>
98
106
  )}
99
- <div className={classes.body}>{children}</div>
107
+ <div className={classes.body}>
108
+ <span className={classes.kindWord} data-callout-kind-word="">
109
+ {KIND_WORD[kind]}
110
+ </span>
111
+ {children}
112
+ </div>
100
113
  </div>
101
114
  )
102
115
  }
@@ -86,6 +86,9 @@ function subscribeAgeTick(onTick: () => void): () => void {
86
86
  }
87
87
 
88
88
  /**
89
+ * The age label follows the `BasaltProvider` / `defineFormat` locale. It is read when the label is
90
+ * formatted, so a locale switch shows on the next age tick or re-render (no new subscription).
91
+ *
89
92
  * @example
90
93
  * // page scope — the page's own data
91
94
  * <PageBar sync={{ syncing, lastCompletedAt, onSync: refetch }} />
@@ -1,30 +1,46 @@
1
1
  /*
2
- * BarList — ranked rows on one shared scale (docs/waves/design-parity/SPEC.md § 6.4). The bar sits
3
- * BEHIND the label and value; the row never wraps: the label truncates, the value is nowrap.
2
+ * BarList — ranked rows on one shared scale (docs/waves/design-parity/SPEC.md § 6.4). The bar track
3
+ * is the LABEL column only; the value (and secondary) columns sit outside it, so a full-scale bar ends
4
+ * before the value. The columns are shared by every row (subgrid), which is what keeps one scale. The
5
+ * row never wraps: the label truncates, the value is nowrap.
4
6
  */
5
7
 
6
8
  .root {
7
- display: flex;
8
- flex-direction: column;
9
- gap: var(--vx-space-stack-xs, 0.25rem);
9
+ display: grid;
10
+ grid-template-columns: minmax(0, 1fr) auto;
11
+ column-gap: var(--vx-space-control-gap, 0.375rem);
12
+ row-gap: var(--vx-space-stack-xs, 0.25rem);
10
13
  margin: 0;
11
14
  padding: 0;
12
15
  list-style: none;
13
16
  min-width: 0;
14
17
  }
15
18
 
19
+ .root[data-secondary] {
20
+ grid-template-columns: minmax(0, 1fr) auto auto;
21
+ }
22
+
16
23
  .row {
17
- position: relative;
18
- display: flex;
24
+ display: grid;
25
+ grid-column: 1 / -1;
26
+ grid-template-columns: subgrid;
19
27
  align-items: center;
20
- gap: var(--vx-space-control-gap, 0.375rem);
21
28
  min-width: 0;
22
29
  min-height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
23
- padding-inline: var(--vx-space-stack-sm);
24
30
  font-size: var(--vx-text-sm);
25
31
  color: var(--vx-ink);
26
32
  }
27
33
 
34
+ /* The bar's scale: `.bar` is a percentage of THIS box, never of the row. */
35
+ .track {
36
+ position: relative;
37
+ display: flex;
38
+ align-items: center;
39
+ align-self: stretch;
40
+ min-width: 0;
41
+ padding-inline: var(--vx-space-stack-sm);
42
+ }
43
+
28
44
  .bar {
29
45
  position: absolute;
30
46
  inset-block: 0;
@@ -39,7 +55,6 @@
39
55
 
40
56
  .label {
41
57
  position: relative;
42
- flex: 1 1 0;
43
58
  min-width: 0;
44
59
  overflow: hidden;
45
60
  text-overflow: ellipsis;
@@ -47,27 +62,105 @@
47
62
  }
48
63
 
49
64
  .value {
50
- position: relative;
51
- flex: none;
52
- font-family: var(--basalt-font-mono);
65
+ font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
66
+ font-variant-numeric: lining-nums;
53
67
  text-align: end;
54
68
  white-space: nowrap;
55
69
  }
56
70
 
71
+ .value:last-child,
72
+ .secondary:last-child {
73
+ padding-inline-end: var(--vx-space-stack-sm);
74
+ }
75
+
57
76
  .secondary {
58
- position: relative;
59
- flex: none;
60
- font-family: var(--basalt-font-mono);
61
- font-size: var(--vx-text-xs);
77
+ font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
78
+ font-variant-numeric: lining-nums;
79
+ font-size: var(--vx-text-sm);
62
80
  color: var(--vx-muted);
63
81
  white-space: nowrap;
64
82
  }
65
83
 
66
84
  .empty {
85
+ grid-column: 1 / -1;
67
86
  font-size: var(--vx-text-sm);
68
87
  color: var(--vx-muted);
69
88
  }
70
89
 
71
90
  .skeletonRow {
91
+ grid-column: 1 / -1;
72
92
  height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
73
93
  }
94
+
95
+ /* A row's threshold: a hairline across the bar at a position on the row's own scale. */
96
+ .tick {
97
+ position: absolute;
98
+ inset-block: 0;
99
+ inline-size: 0;
100
+ border-inline-start: 1px solid var(--vx-ink);
101
+ }
102
+
103
+ /*
104
+ * Thin: label and value share the first line, the bar is a thin rail on the second spanning every
105
+ * column. The label column is still shared (subgrid), so the value columns stay aligned.
106
+ */
107
+ .root[data-variant='thin'] .row {
108
+ grid-template-rows: auto auto;
109
+ row-gap: var(--vx-space-stack-xs, 0.25rem);
110
+ align-items: baseline;
111
+ padding-block: var(--vx-space-stack-xs, 0.25rem);
112
+ }
113
+
114
+ .root[data-variant='thin'] .track {
115
+ grid-column: 1 / -1;
116
+ align-self: auto;
117
+ block-size: 0.25rem;
118
+ padding-inline: 0;
119
+ border-radius: var(--vx-radius-fine);
120
+ background: color-mix(in srgb, var(--vx-line) 20%, transparent);
121
+ }
122
+
123
+ .root[data-variant='thin'] .bar {
124
+ background: color-mix(in srgb, var(--vx-line) 80%, transparent);
125
+ }
126
+
127
+ .root[data-variant='thin'] .bar.leader {
128
+ background: var(--vx-accent);
129
+ }
130
+
131
+ /* The mark outgrows the rail so a 1px line stays visible against a 4px bar. */
132
+ .root[data-variant='thin'] .tick {
133
+ inset-block: calc(var(--vx-space-stack-xs, 0.25rem) * -1);
134
+ }
135
+
136
+ /*
137
+ * Thin rows get a phone's width: the label wraps up to two lines, then truncates (its `title` carries
138
+ * the whole text), and the secondary column takes at most 40% of the list, clipped, so a long status
139
+ * never squeezes the title down to a few characters.
140
+ */
141
+ .root[data-variant='thin'][data-secondary] {
142
+ grid-template-columns: minmax(0, 1fr) auto fit-content(40%);
143
+ }
144
+
145
+ .root[data-variant='thin'] .label {
146
+ display: -webkit-box;
147
+ overflow: hidden;
148
+ white-space: normal;
149
+ overflow-wrap: anywhere;
150
+ -webkit-box-orient: vertical;
151
+ -webkit-line-clamp: 2;
152
+ line-clamp: 2;
153
+ }
154
+
155
+ .root[data-variant='thin'] .secondary {
156
+ min-width: 0;
157
+ overflow: hidden;
158
+ text-overflow: ellipsis;
159
+ }
160
+
161
+ .root[data-variant='thin'] .secondary [data-verdict-word] {
162
+ min-width: 0;
163
+ overflow: hidden;
164
+ text-overflow: ellipsis;
165
+ white-space: nowrap;
166
+ }
@@ -5,8 +5,10 @@
5
5
  declare const classes: {
6
6
  readonly root: string
7
7
  readonly row: string
8
+ readonly track: string
8
9
  readonly bar: string
9
10
  readonly leader: string
11
+ readonly tick: string
10
12
  readonly label: string
11
13
  readonly value: string
12
14
  readonly secondary: string
@@ -1,8 +1,17 @@
1
1
  /**
2
- * BarList — a ranked list: label, an inline bar on ONE shared scale, a mono right-aligned value and
2
+ * BarList — a ranked list: label, an inline bar on ONE shared scale, a right-aligned sans value and
3
3
  * an optional muted secondary value. Choose it for "top N" (the bar ranks by length before anything
4
- * is read). Intended for 5–10 rows; past 10 use a table with an inline `Meter` cell. An HTML/CSS
5
- * primitive, not a chart kind.
4
+ * is read). The bar spans the label column only — values sit outside it, so a full-scale bar ends
5
+ * before its value. Intended for 5–10 rows; past 10 use a table with an inline `Meter` cell. An
6
+ * HTML/CSS primitive, not a chart kind.
7
+ *
8
+ * A row may carry its own `max` (points of 40 / 35 / 25): its bar fills value / row.max and the value
9
+ * column reads "32 / 40". The shared scale — `max` prop, else the largest value — is computed over the
10
+ * rows WITHOUT their own `max` only. A row's `tick` (on that row's scale) draws a hairline across the
11
+ * bar, named for assistive tech. `variant="thin"` puts the label on its own line above a thin bar with
12
+ * the value right-aligned on the label line.
13
+ *
14
+ * Thin rows sit flush: no inline inset on the label or the rail.
6
15
  *
7
16
  * Colour law: bars are neutral. `accentLeader` (opt-in) lets the top row take the accent — the
8
17
  * leader bar, and nothing else. Each value is rendered as text, never only a bar length.
@@ -13,6 +22,14 @@
13
22
  * // Recovery contributors on a fixed 0–100 scale, the qualitative level as the secondary value:
14
23
  * <BarList label="Recovery contributors" max={100} items={[{ label: 'Sleep', value: 82, secondary: 'Good' }]} />
15
24
  *
25
+ * // Points of different maxima, thin rows, a threshold tick ("32 / 40 pts"; the tick is named for AT):
26
+ * <BarList
27
+ * label="Recovery contributors"
28
+ * variant="thin"
29
+ * format={(n, part) => (part === 'max' ? `${n} pts` : String(n))}
30
+ * items={[{ label: 'Sleep', value: 32, max: 40, tick: 30, tickLabel: 'Target' }, { label: 'HRV', value: 14, max: 35 }]}
31
+ * />
32
+ *
16
33
  * <BarList
17
34
  * label="Top projects by tokens"
18
35
  * items={[{ label: 'argo', value: 1840, secondary: '41%' }, { label: 'rb', value: 920 }]}
@@ -27,17 +44,33 @@ import type { BasaltProps } from '../common/props'
27
44
  import classes from './bar-list.module.css'
28
45
  import { asText, barPercent } from './scale'
29
46
 
30
- type BarListItem = { label: string; value: number; secondary?: ReactNode; key?: string }
47
+ type BarListItem = {
48
+ label: string
49
+ value: number
50
+ secondary?: ReactNode
51
+ key?: string
52
+ /** This row's own scale end: the bar fills value / max and the value reads "value / max". */
53
+ max?: number
54
+ /** A hairline mark at this position on the row's scale (a threshold). */
55
+ tick?: number
56
+ /** Names the tick for assistive tech (visually hidden text in the track). Default "Threshold". */
57
+ tickLabel?: string
58
+ }
31
59
 
32
60
  export type BarListProps = BasaltProps & {
33
61
  /** Accessible name of the list. Required. */
34
62
  label: string
35
63
  /** Rows in display order (sort them yourself; the list does not reorder). */
36
64
  items: readonly BarListItem[]
37
- /** Formats each value. Default: the number as written. */
38
- format?: (value: number) => string
39
- /** Scale end shared by every bar. Default: the largest value. */
65
+ /**
66
+ * Formats each number. `part` is `'max'` for a row's denominator, `'value'` otherwise (the value and
67
+ * the tick), so a unit can sit on one side only: `'32 / 40 pts'`. Default: the number as written.
68
+ */
69
+ format?: (value: number, part: 'value' | 'max') => string
70
+ /** Scale end shared by rows without their own `max`. Default: the largest of those rows' values. */
40
71
  max?: number
72
+ /** `thin`: label on its own line above a thin bar, value right-aligned on that line. */
73
+ variant?: 'default' | 'thin'
41
74
  /** The first row's bar takes the accent. Off by default. */
42
75
  accentLeader?: boolean
43
76
  /** Renders row-shaped skeletons. */
@@ -48,11 +81,16 @@ export type BarListProps = BasaltProps & {
48
81
  emptyText?: string
49
82
  }
50
83
 
84
+ /** `null`, `undefined`, `false` and `true` render nothing, so they are not a secondary value. */
85
+ const hasContent = (node: ReactNode): boolean =>
86
+ node !== undefined && node !== null && typeof node !== 'boolean'
87
+
51
88
  export function BarList({
52
89
  label,
53
90
  items,
54
91
  format = asText,
55
92
  max,
93
+ variant = 'default',
56
94
  accentLeader = false,
57
95
  loading = false,
58
96
  loadingRows = 5,
@@ -79,31 +117,74 @@ export function BarList({
79
117
  }
80
118
 
81
119
  const scale =
82
- max ?? items.reduce((top, i) => (Number.isFinite(i.value) ? Math.max(top, i.value) : top), 0)
120
+ max ??
121
+ items.reduce(
122
+ (top, i) => (i.max === undefined && Number.isFinite(i.value) ? Math.max(top, i.value) : top),
123
+ 0,
124
+ )
125
+ const thin = variant === 'thin'
126
+ const hasSecondary = items.some((i) => hasContent(i.secondary))
83
127
  return (
84
128
  // The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
85
- // oxlint-disable-next-line jsx-a11y/no-redundant-roles
86
- <ul className={cx(classes.root, className)} style={style} role="list" aria-label={label}>
129
+ <ul
130
+ className={cx(classes.root, className)}
131
+ style={style}
132
+ // oxlint-disable-next-line jsx-a11y/no-redundant-roles
133
+ role="list"
134
+ aria-label={label}
135
+ data-secondary={hasSecondary ? '' : undefined}
136
+ data-variant={thin ? 'thin' : undefined}
137
+ >
87
138
  {items.map((item, i) => {
88
139
  const isLeader = accentLeader && i === 0
89
- return (
90
- <li key={item.key ?? `${item.label}-${i}`} className={classes.row}>
91
- {/* theme-allow hidden-inline-style — the width is the row's data (a % of the shared scale), not styling */}
140
+ const rowScale = item.max ?? scale
141
+ const labelNode = (
142
+ <span className={classes.label} title={item.label}>
143
+ {item.label}
144
+ </span>
145
+ )
146
+ const tickName =
147
+ item.tick === undefined
148
+ ? ''
149
+ : `${item.tickLabel ?? 'Threshold'} ${format(item.tick, 'value')}`
150
+ const track = (
151
+ <span className={classes.track} data-bar-track>
152
+ {/* theme-allow hidden-inline-style — the width is the row's data (a % of its scale), not styling */}
92
153
  <span
93
154
  className={cx(classes.bar, isLeader && classes.leader)}
94
- style={{ width: `${barPercent(item.value, scale)}%` }}
155
+ style={{ width: `${barPercent(item.value, rowScale)}%` }}
156
+ data-bar-fill=""
95
157
  data-bar-leader={isLeader ? '' : undefined}
96
158
  aria-hidden
97
159
  />
98
- <span className={classes.label} title={item.label}>
99
- {item.label}
100
- </span>
160
+ {item.tick !== undefined && (
161
+ // theme-allow hidden-inline-style — the position is the row's data (a % of its scale)
162
+ <span
163
+ className={classes.tick}
164
+ style={{ insetInlineStart: `${barPercent(item.tick, rowScale)}%` }}
165
+ data-bar-tick=""
166
+ aria-hidden
167
+ />
168
+ )}
169
+ {!thin && labelNode}
170
+ {/* Inside the track so it is never the row's last child (the value/secondary inset). */}
171
+ {item.tick !== undefined && <VisuallyHidden>{tickName}</VisuallyHidden>}
172
+ </span>
173
+ )
174
+ return (
175
+ <li key={item.key ?? `${item.label}-${i}`} className={classes.row}>
176
+ {thin && labelNode}
177
+ {!thin && track}
101
178
  <span className={classes.value}>
102
- {Number.isFinite(item.value) ? format(item.value) : '—'}
179
+ {Number.isFinite(item.value)
180
+ ? item.max === undefined
181
+ ? format(item.value, 'value')
182
+ : `${format(item.value, 'value')} / ${format(item.max, 'max')}`
183
+ : '—'}
103
184
  </span>
104
- {item.secondary !== undefined && (
105
- <span className={classes.secondary}>{item.secondary}</span>
106
- )}
185
+ {/* Kept empty on a row without one: the secondary column is shared, so every row has the cell. */}
186
+ {hasSecondary && <span className={classes.secondary}>{item.secondary}</span>}
187
+ {thin && track}
107
188
  </li>
108
189
  )
109
190
  })}