basalt-ui 1.1.1 → 1.3.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 (191) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +64 -8
  4. package/agent/rules/basalt-app.md +126 -0
  5. package/agent/rules/basalt-content.md +3 -1
  6. package/agent/rules/basalt-tokens.md +14 -5
  7. package/agent/skills/basalt-app/SKILL.md +28 -7
  8. package/dist/agent/part-list.d.ts.map +1 -1
  9. package/dist/agent/part-list.js +17 -7
  10. package/dist/agent/stick-to-bottom.js +2 -2
  11. package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
  12. package/dist/agent-chat/thread-detail-panel.js +37 -33
  13. package/dist/agent-chat/thread-message.d.ts.map +1 -1
  14. package/dist/agent-chat/thread-message.js +8 -5
  15. package/dist/agent-chat/thread-outcome-card.js +3 -3
  16. package/dist/agent-chat/thread-workspace.js +1 -1
  17. package/dist/charts/primitives/ChartLegend.js +2 -0
  18. package/dist/charts/primitives/ChartTooltip.js +2 -1
  19. package/dist/cli/index.d.ts +29 -0
  20. package/dist/cli/index.d.ts.map +1 -1
  21. package/dist/cli/index.js +80 -9
  22. package/dist/connectivity/connectivity-indicator.d.ts.map +1 -1
  23. package/dist/connectivity/connectivity-indicator.js +3 -3
  24. package/dist/content/article-card.module.css +7 -5
  25. package/dist/content/article-layout.module.css +16 -12
  26. package/dist/content/callout.module.css +4 -4
  27. package/dist/content/code-block.module.css +8 -7
  28. package/dist/content/guide.module.css +3 -3
  29. package/dist/content/mermaid.module.css +2 -2
  30. package/dist/content/prose.module.css +59 -29
  31. package/dist/content/reading-progress.module.css +2 -0
  32. package/dist/content/toc.module.css +6 -3
  33. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  34. package/dist/dashboard/delta-badge.js +10 -2
  35. package/dist/dashboard/empty-state.d.ts.map +1 -1
  36. package/dist/dashboard/empty-state.js +3 -16
  37. package/dist/dashboard/settings-section.js +2 -2
  38. package/dist/dashboard/settings-section.module.css +2 -2
  39. package/dist/dashboard/stat-card.js +2 -1
  40. package/dist/data/virtual-list.d.ts.map +1 -1
  41. package/dist/data/virtual-list.js +12 -2
  42. package/dist/forms/FormErrorSummary.js +2 -2
  43. package/dist/guard/index.d.ts +20 -4
  44. package/dist/guard/index.d.ts.map +1 -1
  45. package/dist/guard/index.js +266 -38
  46. package/dist/guard/types.d.ts +24 -3
  47. package/dist/guard/types.d.ts.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/provider/index.d.ts +30 -1
  51. package/dist/provider/index.d.ts.map +1 -1
  52. package/dist/provider/index.js +32 -7
  53. package/dist/provider/lab-theme.d.ts +39 -0
  54. package/dist/provider/lab-theme.d.ts.map +1 -0
  55. package/dist/provider/lab-theme.js +52 -0
  56. package/dist/shell/app-header.module.css +2 -2
  57. package/dist/shell/app-mobile-nav.module.css +1 -1
  58. package/dist/shell/app-sidebar-account.d.ts.map +1 -1
  59. package/dist/shell/app-sidebar-account.js +4 -2
  60. package/dist/shell/app-sidebar.d.ts.map +1 -1
  61. package/dist/shell/app-sidebar.js +4 -2
  62. package/dist/shell/app-sidebar.module.css +36 -26
  63. package/dist/shell/index.d.ts.map +1 -1
  64. package/dist/shell/index.js +11 -4
  65. package/dist/shell/sidebar-search.module.css +16 -4
  66. package/dist/styles.css +22 -11
  67. package/dist/surfaces.d.ts +21 -11
  68. package/dist/surfaces.d.ts.map +1 -1
  69. package/dist/surfaces.js +10 -3
  70. package/dist/theme/controls.module.css +1 -1
  71. package/dist/theme/floating.module.css +1 -1
  72. package/dist/theme/index.d.ts +116 -11
  73. package/dist/theme/index.d.ts.map +1 -1
  74. package/dist/theme/index.js +703 -566
  75. package/dist/theme/nav-link.module.css +1 -1
  76. package/dist/theme/use-basalt-spacing.d.ts +3 -0
  77. package/dist/theme/use-basalt-spacing.d.ts.map +1 -0
  78. package/dist/theme/use-basalt-spacing.js +8 -0
  79. package/dist/theme-lab/derive-controls.d.ts +13 -0
  80. package/dist/theme-lab/derive-controls.d.ts.map +1 -0
  81. package/dist/theme-lab/derive-controls.js +137 -0
  82. package/dist/theme-lab/derive-state.d.ts +55 -0
  83. package/dist/theme-lab/derive-state.d.ts.map +1 -0
  84. package/dist/theme-lab/derive-state.js +81 -0
  85. package/dist/theme-lab/index.d.ts +12 -2
  86. package/dist/theme-lab/index.d.ts.map +1 -1
  87. package/dist/theme-lab/index.js +13 -62
  88. package/dist/theme-toggle/index.d.ts.map +1 -1
  89. package/dist/theme-toggle/index.js +3 -2
  90. package/dist/tokens/derive.d.ts +89 -0
  91. package/dist/tokens/derive.d.ts.map +1 -0
  92. package/dist/tokens/derive.js +250 -0
  93. package/dist/tokens/hct.d.ts +34 -0
  94. package/dist/tokens/hct.d.ts.map +1 -0
  95. package/dist/tokens/hct.js +159 -0
  96. package/dist/tokens/index.d.ts +143 -7
  97. package/dist/tokens/index.d.ts.map +1 -1
  98. package/dist/tokens/index.js +322 -48
  99. package/dist/tokens/palette.d.ts +984 -167
  100. package/dist/tokens/palette.d.ts.map +1 -1
  101. package/dist/tokens/palette.js +617 -119
  102. package/dist/tokens.css +248 -0
  103. package/dist/vite-color-mix.d.ts +30 -0
  104. package/dist/vite-color-mix.d.ts.map +1 -0
  105. package/dist/vite-color-mix.js +80 -0
  106. package/dist/vite.d.ts +82 -1
  107. package/dist/vite.d.ts.map +1 -1
  108. package/dist/vite.js +312 -0
  109. package/llms.txt +14 -4
  110. package/package.json +41 -10
  111. package/src/agent/part-list.tsx +13 -7
  112. package/src/agent/stick-to-bottom.tsx +2 -2
  113. package/src/agent-chat/thread-detail-panel.tsx +13 -10
  114. package/src/agent-chat/thread-message.tsx +8 -5
  115. package/src/agent-chat/thread-outcome-card.tsx +2 -2
  116. package/src/agent-chat/thread-workspace.tsx +2 -2
  117. package/src/charts/primitives/ChartLegend.tsx +2 -2
  118. package/src/charts/primitives/ChartTooltip.tsx +2 -2
  119. package/src/cli/check-theme.test.ts +18 -0
  120. package/src/cli/index.ts +129 -6
  121. package/src/cli/tokens-css.test.ts +90 -0
  122. package/src/connectivity/connectivity-indicator.tsx +8 -2
  123. package/src/content/article-card.module.css +7 -5
  124. package/src/content/article-layout.module.css +16 -12
  125. package/src/content/callout.module.css +4 -4
  126. package/src/content/code-block.module.css +8 -7
  127. package/src/content/guide.module.css +3 -3
  128. package/src/content/mermaid.module.css +2 -2
  129. package/src/content/prose.module.css +59 -29
  130. package/src/content/prose.module.css.test.ts +55 -0
  131. package/src/content/reading-progress.module.css +2 -0
  132. package/src/content/toc.module.css +6 -3
  133. package/src/dashboard/delta-badge.tsx +10 -4
  134. package/src/dashboard/empty-state.tsx +3 -16
  135. package/src/dashboard/settings-section.module.css +2 -2
  136. package/src/dashboard/settings-section.tsx +2 -2
  137. package/src/dashboard/stat-card.tsx +2 -2
  138. package/src/data/virtual-list.tsx +12 -2
  139. package/src/forms/FormErrorSummary.tsx +1 -1
  140. package/src/guard/check-source.test.ts +483 -15
  141. package/src/guard/index.ts +426 -47
  142. package/src/guard/types.ts +24 -2
  143. package/src/index.ts +1 -0
  144. package/src/provider/index.test.tsx +100 -0
  145. package/src/provider/index.tsx +79 -7
  146. package/src/provider/lab-theme.test.ts +147 -0
  147. package/src/provider/lab-theme.ts +166 -0
  148. package/src/shell/app-header.module.css +2 -2
  149. package/src/shell/app-mobile-nav.module.css +1 -1
  150. package/src/shell/app-sidebar-account.tsx +9 -2
  151. package/src/shell/app-sidebar.module.css +36 -26
  152. package/src/shell/app-sidebar.tsx +12 -2
  153. package/src/shell/index.tsx +14 -3
  154. package/src/shell/sidebar-search.module.css +16 -4
  155. package/src/styles.css +22 -11
  156. package/src/surfaces.ts +24 -10
  157. package/src/theme/contrast.test.ts +19 -3
  158. package/src/theme/controls.module.css +1 -1
  159. package/src/theme/density-option.test.ts +96 -0
  160. package/src/theme/density-relations.test.ts +428 -0
  161. package/src/theme/derive-theme.test.ts +101 -0
  162. package/src/theme/floating.module.css +1 -1
  163. package/src/theme/fonts-option.test.ts +69 -0
  164. package/src/theme/index.ts +930 -563
  165. package/src/theme/nav-link.module.css +1 -1
  166. package/src/theme/radius-option.test.ts +86 -0
  167. package/src/theme/radius.test.ts +132 -0
  168. package/src/theme/spacing.test.ts +432 -0
  169. package/src/theme/use-basalt-spacing.test.tsx +51 -0
  170. package/src/theme/use-basalt-spacing.ts +38 -0
  171. package/src/theme-lab/derive-controls.test.ts +94 -0
  172. package/src/theme-lab/derive-controls.tsx +227 -0
  173. package/src/theme-lab/derive-state.test.ts +71 -0
  174. package/src/theme-lab/derive-state.ts +163 -0
  175. package/src/theme-lab/index.tsx +29 -68
  176. package/src/theme-lab/theme-lab.test.ts +4 -18
  177. package/src/theme-toggle/index.tsx +9 -4
  178. package/src/tokens/build-fonts-css.test.ts +51 -0
  179. package/src/tokens/build-radius-css.test.ts +25 -0
  180. package/src/tokens/density.test.ts +274 -0
  181. package/src/tokens/derive-radius.test.ts +62 -0
  182. package/src/tokens/derive.test.ts +30 -0
  183. package/src/tokens/derive.ts +481 -0
  184. package/src/tokens/hct.ts +231 -0
  185. package/src/tokens/index.ts +534 -48
  186. package/src/tokens/palette.test.ts +114 -0
  187. package/src/tokens/palette.ts +1118 -180
  188. package/src/vite-color-mix.test.ts +46 -0
  189. package/src/vite-color-mix.ts +137 -0
  190. package/src/vite.test.ts +192 -0
  191. package/src/vite.ts +502 -1
@@ -17,6 +17,7 @@
17
17
  * generic person glyph below.
18
18
  */
19
19
  import { Group, Menu, Skeleton, Stack, Text, UnstyledButton } from '@mantine/core'
20
+ import { useBasaltSpacing } from '../theme'
20
21
  import type { BasaltAccountProps } from './account-types'
21
22
  import classes from './app-sidebar.module.css'
22
23
 
@@ -61,7 +62,7 @@ function IconUser() {
61
62
  function AccountSkeleton() {
62
63
  return (
63
64
  <Group className={classes.accountRow} gap="sm" wrap="nowrap">
64
- <Skeleton height={28} width={28} radius={7} />
65
+ <Skeleton height={28} width={28} style={{ borderRadius: 'var(--vx-radius-card)' }} />
65
66
  <Stack gap={4} className={classes.accountText}>
66
67
  <Skeleton height={10} width="70%" radius="sm" />
67
68
  <Skeleton height={9} width="50%" radius="sm" />
@@ -71,6 +72,12 @@ function AccountSkeleton() {
71
72
  }
72
73
 
73
74
  export function SidebarAccount({ state, actions, showEmail }: BasaltAccountProps) {
75
+ // Density-tracking Menu dropdown width (`SPACE_STEP.sidebarAccountMenuWidth`) — read the ACTIVE
76
+ // resolved level, not the frozen level-0 constant, so the dropdown widens with its rows as density
77
+ // rises (see that constant's own doc in `tokens/palette.ts`). Called unconditionally, ahead of the
78
+ // early returns below (rules-of-hooks).
79
+ const { step } = useBasaltSpacing()
80
+
74
81
  if (state.status === 'loading') {
75
82
  return <AccountSkeleton />
76
83
  }
@@ -90,7 +97,7 @@ export function SidebarAccount({ state, actions, showEmail }: BasaltAccountProps
90
97
  const canUpgrade = Boolean(plan?.isFree && actions?.onUpgrade)
91
98
 
92
99
  return (
93
- <Menu position="right-end" withArrow width={220} zIndex={500}>
100
+ <Menu position="right-end" withArrow width={step.sidebarAccountMenuWidth} zIndex={500}>
94
101
  <Menu.Target>
95
102
  <UnstyledButton className={classes.accountRow} aria-label="Account menu">
96
103
  <InitialsBlock name={identity.name} />
@@ -17,14 +17,16 @@
17
17
  * a consuming app's bundler — `!important` makes the override deterministic.
18
18
  */
19
19
 
20
- /* Sidebar frame — the ~10px inner horizontal padding every region (brand/nav/footer) sits in. */
20
+ /* Sidebar frame — the ~10px inner horizontal padding every region (brand/nav/footer) sits in.
21
+ * Reuses `SPACE.rowInsetX` (the same horizontal inset a nav/menu row carries) since this IS the
22
+ * master column every region aligns to — see the several `--vx-space-row-inset-x` reuses below. */
21
23
  .root {
22
- padding: 0 10px;
24
+ padding: 0 var(--vx-space-row-inset-x);
23
25
  }
24
26
 
25
27
  .link {
26
28
  font-size: var(--vx-text-md);
27
- border-radius: 6px !important;
29
+ border-radius: var(--vx-radius-ctrl) !important;
28
30
  }
29
31
 
30
32
  .link :global(.mantine-NavLink-label) {
@@ -32,7 +34,7 @@
32
34
  }
33
35
 
34
36
  .link :global(.mantine-NavLink-section[data-position='left']) {
35
- margin-inline-end: 10px;
37
+ margin-inline-end: var(--vx-space-nav-icon-gap);
36
38
  }
37
39
 
38
40
  /* Inactive rows: muted text + faint icon. Active rows keep the theme's ink text (via `--nl-color`)
@@ -68,7 +70,7 @@
68
70
  */
69
71
  .ghostIcon {
70
72
  color: var(--vx-faint) !important;
71
- border-radius: 6px !important;
73
+ border-radius: var(--vx-radius-ctrl) !important;
72
74
  }
73
75
 
74
76
  .ghostIcon:hover {
@@ -82,7 +84,8 @@
82
84
  */
83
85
  .brand {
84
86
  justify-content: space-between;
85
- padding: 3px 8px 12px;
87
+ padding: var(--vx-space-sidebar-brand-inset-top) var(--vx-space-sidebar-brand-inset-x)
88
+ var(--vx-space-sidebar-region-gap);
86
89
  flex-shrink: 0;
87
90
  }
88
91
 
@@ -98,7 +101,7 @@
98
101
  /* No horizontal padding — the field spans the same width as the nav rows below it (both sit at the
99
102
  * `.root` 10px inset), so the search box edge-aligns with the nav column. */
100
103
  .searchSlot {
101
- padding: 0 0 12px;
104
+ padding: 0 0 var(--vx-space-sidebar-region-gap);
102
105
  flex-shrink: 0;
103
106
  }
104
107
 
@@ -122,20 +125,20 @@
122
125
  /* Bleed the scroll root across `.root`'s right inset so the overlay bar draws in that 10px
123
126
  * gutter instead of on top of the rows (it anchors to the root's right edge, which otherwise
124
127
  * lands exactly on the row's own right padding — the bar then crowds the badge column). */
125
- margin-right: -10px;
128
+ margin-right: calc(-1 * var(--vx-space-row-inset-x));
126
129
  }
127
130
 
128
131
  /* Re-apply the bled inset INSIDE the viewport, so rows keep their exact 10px/10px column while the
129
132
  * bar floats clear of them in the gutter. Static padding, not Mantine's `offsetScrollbars`: the
130
133
  * latter pads only while overflowing, which reflows the rows the moment a section expands. */
131
134
  .navViewport {
132
- padding-inline-end: 10px;
135
+ padding-inline-end: var(--vx-space-row-inset-x);
133
136
  }
134
137
 
135
138
  /* Sections separate by SPACING only — 15px between sections, nothing above the first (the brand
136
139
  * row's own bottom padding already opens the region). */
137
140
  .nav > div + div {
138
- margin-top: 15px;
141
+ margin-top: var(--vx-space-sidebar-section-gap);
139
142
  }
140
143
 
141
144
  /*
@@ -155,9 +158,9 @@
155
158
  min-width: 0;
156
159
  display: flex;
157
160
  align-items: center;
158
- gap: 10px;
159
- padding: 6px 10px;
160
- border-radius: 6px;
161
+ gap: var(--vx-space-nav-icon-gap);
162
+ padding: var(--vx-space-row-inset-y) var(--vx-space-row-inset-x);
163
+ border-radius: var(--vx-radius-ctrl);
161
164
  font-size: var(--vx-text-md);
162
165
  color: var(--vx-muted);
163
166
  }
@@ -190,9 +193,10 @@
190
193
  min-width: 0;
191
194
  display: flex;
192
195
  align-items: center;
193
- gap: 10px;
194
- padding: 11px 8px 3px;
195
- border-radius: 6px;
196
+ gap: var(--vx-space-nav-icon-gap);
197
+ padding: var(--vx-space-sidebar-account-inset-top) var(--vx-space-sidebar-account-inset-x)
198
+ var(--vx-space-sidebar-account-inset-bottom);
199
+ border-radius: var(--vx-radius-ctrl);
196
200
  }
197
201
 
198
202
  .accountRow:hover {
@@ -214,9 +218,9 @@
214
218
  display: flex;
215
219
  align-items: center;
216
220
  justify-content: center;
217
- width: 28px;
218
- height: 28px;
219
- border-radius: 7px;
221
+ width: var(--vx-space-sidebar-avatar-size);
222
+ height: var(--vx-space-sidebar-avatar-size);
223
+ border-radius: var(--vx-radius-card);
220
224
  background-color: color-mix(in srgb, var(--vx-ink) 10%, transparent);
221
225
  color: var(--vx-muted);
222
226
  font-family: var(--basalt-font-mono);
@@ -265,8 +269,8 @@
265
269
  align-items: center;
266
270
  justify-content: space-between;
267
271
  width: 100%;
268
- padding: 0 10px;
269
- margin-bottom: 3px;
272
+ padding: 0 var(--vx-space-row-inset-x);
273
+ margin-bottom: var(--vx-space-sidebar-section-label-gap);
270
274
  }
271
275
 
272
276
  .sectionBand > svg {
@@ -293,15 +297,17 @@
293
297
  * `--vx-divider` left guide on the WRAPPER (not per row, so hover tints don't break the line).
294
298
  */
295
299
  .childList {
296
- margin: 2px 0 4px 17px;
300
+ margin: var(--vx-space-sidebar-child-list-gap-top) 0 var(--vx-space-sidebar-child-list-gap-bottom)
301
+ var(--vx-space-sidebar-child-list-indent);
297
302
  border-left: 1px solid var(--vx-divider);
298
303
  }
299
304
 
300
305
  /* Child row geometry — one size smaller than a parent row. The theme sets padding inline
301
306
  * (6px 10px), so the child value needs `!important`. */
302
307
  .childList :global(.mantine-NavLink-root) {
303
- padding: 5px 10px 5px 14px !important;
304
- border-radius: 6px !important;
308
+ padding: var(--vx-space-sidebar-child-row-inset-y) var(--vx-space-row-inset-x)
309
+ var(--vx-space-sidebar-child-row-inset-y) var(--vx-space-sidebar-child-row-indent) !important;
310
+ border-radius: var(--vx-radius-ctrl) !important;
305
311
  }
306
312
 
307
313
  .childList :global(.mantine-NavLink-label) {
@@ -331,7 +337,11 @@
331
337
  }
332
338
  }
333
339
 
334
- /* Subnav popover dropdown — match sidebar density. */
340
+ /* Subnav popover dropdown — match sidebar density. A `min-width`, not a `width`: it only floors the
341
+ * box and grows with content, so — unlike a fixed `width` (see the account/settings `<Menu
342
+ * width={…}>` props in app-sidebar.tsx/app-sidebar-account.tsx, tokenized onto
343
+ * `SPACE_STEP.sidebarAccountMenuWidth`/`.sidebarSettingsMenuWidth`) — a rising density can never
344
+ * squeeze it, so it stays a raw literal on purpose. */
335
345
  .subnavDropdown {
336
346
  min-width: 180px;
337
347
  }
@@ -355,7 +365,7 @@
355
365
  }
356
366
 
357
367
  .root[data-collapsed] .searchSlot {
358
- padding: 0 0 12px;
368
+ padding: 0 0 var(--vx-space-sidebar-region-gap);
359
369
  display: flex;
360
370
  justify-content: center;
361
371
  }
@@ -36,6 +36,7 @@ import type { BasaltAccountProps } from './account-types'
36
36
  import { SidebarSearch } from './sidebar-search'
37
37
  import type { SidebarSearchConfig } from './sidebar-search'
38
38
  import { VX } from '../tokens'
39
+ import { useBasaltSpacing } from '../theme'
39
40
  import classes from './app-sidebar.module.css'
40
41
 
41
42
  /**
@@ -457,6 +458,11 @@ export function AppSidebar({
457
458
  account,
458
459
  search,
459
460
  }: AppSidebarProps) {
461
+ // Density-tracking Menu dropdown width (`SPACE_STEP.sidebarSettingsMenuWidth`) — read the ACTIVE
462
+ // resolved level, not the frozen level-0 constant (see that constant's own doc in
463
+ // `tokens/palette.ts`).
464
+ const { step } = useBasaltSpacing()
465
+
460
466
  // Desktop collapsible-section state, keyed by section label. Seeded once from each section's
461
467
  // `defaultCollapsed`; non-collapsible sections are simply never read here.
462
468
  const [collapsedSections, setCollapsedSections] = useState<Record<string, boolean>>(() =>
@@ -497,7 +503,7 @@ export function AppSidebar({
497
503
  const hasSettingsMenu = (settingsMenuItems?.length ?? 0) > 0
498
504
  const settingsRow = hasSettingsMenu ? (
499
505
  <Group {...(account ? {} : { className: classes.footer })} gap="xs" wrap="nowrap">
500
- <Menu position="right-start" withArrow width={200} zIndex={500}>
506
+ <Menu position="right-start" withArrow width={step.sidebarSettingsMenuWidth} zIndex={500}>
501
507
  <Menu.Target>
502
508
  <UnstyledButton className={classes.footerBtn} aria-label="Settings">
503
509
  <IconGear />
@@ -554,7 +560,11 @@ export function AppSidebar({
554
560
  </Group>
555
561
  <ActionIcon
556
562
  variant="subtle"
557
- size="md"
563
+ // A numeric size, not the named `"md"` — same opt-out as `connectivity-indicator.tsx`'s
564
+ // toolbar icon (see that comment): this is a plain collapse-toggle icon, not a control meant
565
+ // to match a `size="md"` Input/Button, so it must not pick up the theme's `ActionIcon.extend`
566
+ // control-height override. Reproduces Mantine's own static `--ai-size-md` (28px).
567
+ size={28}
558
568
  visibleFrom="sm"
559
569
  className={`${classes.collapseBtn} ${classes.ghostIcon}`}
560
570
  onClick={onToggleCollapse}
@@ -23,6 +23,7 @@ import { PageActionsOutlet, PageHeaderProvider } from './page-header'
23
23
  import type { BasaltAccountProps } from './account-types'
24
24
  import type { SidebarSearchConfig } from './sidebar-search'
25
25
  import { VX } from '../tokens'
26
+ import { useBasaltSpacing } from '../theme'
26
27
  import headerClasses from './app-header.module.css'
27
28
 
28
29
  export { AppSidebar, type AppSidebarProps, type NavLinkRenderer } from './app-sidebar'
@@ -163,7 +164,6 @@ export function NavCountBadge({ count }: { count: number }) {
163
164
  return (
164
165
  <Badge
165
166
  size="sm"
166
- radius={5}
167
167
  styles={{
168
168
  root: {
169
169
  backgroundColor: 'color-mix(in srgb, var(--vx-ink) 8%, transparent)',
@@ -174,6 +174,7 @@ export function NavCountBadge({ count }: { count: number }) {
174
174
  height: 16,
175
175
  padding: '0 5px',
176
176
  marginLeft: 'auto',
177
+ borderRadius: 'var(--vx-radius-tight)',
177
178
  },
178
179
  }}
179
180
  >
@@ -270,6 +271,11 @@ export function BasaltShell({
270
271
  search,
271
272
  children,
272
273
  }: BasaltShellProps) {
274
+ // The active density level's resolved spacing — the AppShell dimensions below must track it
275
+ // (see `SPACE_STEP_BASE`'s "shell/index.tsx" group doc in `tokens/palette.ts`): their contents
276
+ // (controls, the search trigger/avatar, nav labels) already track density, so a fixed literal
277
+ // container squeezes progressively worse as density rises.
278
+ const { step } = useBasaltSpacing()
273
279
  const [mobileOpened, { toggle: toggleMobile, close: closeMobile }] = useDisclosure()
274
280
  const [storedCollapsed, setStoredCollapsed] = useLocalStorage({
275
281
  key: storageKey,
@@ -294,9 +300,14 @@ export function BasaltShell({
294
300
  <AppShell
295
301
  h="100dvh"
296
302
  layout="alt"
297
- header={{ height: { base: 96, sm: 48 } }}
303
+ header={{
304
+ height: { base: step.appShellHeaderMobileHeight, sm: step.appShellHeaderHeight },
305
+ }}
298
306
  navbar={{
299
- width: { base: 216, sm: collapsed ? 48 : 216 },
307
+ width: {
308
+ base: step.appShellNavbarWidth,
309
+ sm: collapsed ? step.appShellNavbarRailWidth : step.appShellNavbarWidth,
310
+ },
300
311
  breakpoint: 'sm',
301
312
  collapsed: { mobile: !mobileOpened },
302
313
  }}
@@ -6,10 +6,10 @@
6
6
  .trigger {
7
7
  display: flex;
8
8
  align-items: center;
9
- gap: 8px;
9
+ gap: var(--vx-space-sidebar-search-gap);
10
10
  width: 100%;
11
- height: 32px;
12
- padding: 0 10px;
11
+ height: var(--vx-space-sidebar-search-trigger-height);
12
+ padding: 0 var(--vx-space-row-inset-x);
13
13
  border-radius: var(--vx-radius-ctrl);
14
14
  background-color: var(--vx-surface-panel);
15
15
  box-shadow: var(--vx-shadow-card);
@@ -50,10 +50,22 @@
50
50
  * Collapsed rail button — mirrors app-sidebar.module.css's `.ghostIcon`: faint icon, radius 6,
51
51
  * hover ink-6% + ink. `!important` for the same reason as that rule: it competes with Mantine's
52
52
  * own compiled ActionIcon variant CSS.
53
+ *
54
+ * `--ai-size` is re-pointed at the SAME resolved `sidebarSearchTriggerHeight` the expanded trigger
55
+ * reads (`.trigger`'s `height` below), not the generic control-height anchor the theme's
56
+ * `ActionIcon.extend` `vars` sets for every OTHER `size="md"` ActionIcon (`theme/index.ts`) — that
57
+ * anchor is tuned to match a `size="md"` Input/Button (42px at level 0), a different, larger control
58
+ * than this compact icon-only rail toggle. Without this override the two states of one logical
59
+ * control (expanded trigger vs. collapsed rail icon) would render at different heights AND, at a
60
+ * negative density level, the rail icon would stop tracking the trigger's own WCAG 24px floor
61
+ * (`deriveSpacing`'s doc in `tokens/palette.ts`). `!important` wins over the theme's own inline
62
+ * `--ai-size` (a non-`!important` `vars` declaration, i.e. an inline style) for the same
63
+ * cascade reason the other declarations here need it.
53
64
  */
54
65
  .railBtn {
66
+ --ai-size: var(--vx-space-sidebar-search-trigger-height) !important;
55
67
  color: var(--vx-faint) !important;
56
- border-radius: 6px !important;
68
+ border-radius: var(--vx-radius-ctrl) !important;
57
69
  }
58
70
 
59
71
  .railBtn:hover {
package/src/styles.css CHANGED
@@ -24,6 +24,11 @@
24
24
  /* Font stack — overridable via the --basalt-font-* custom properties. */
25
25
  @layer base {
26
26
  :root {
27
+ /* Hubot Sans is a condensed display face; the spec pins it at 88% wherever it lands. A knob
28
+ rather than a literal at the rule below, because that rule reaches BARE h1–h6: a consumer
29
+ that layers its own base type would otherwise have no way to keep its own heading width
30
+ short of out-specifying the framework. `normal` opts out entirely. */
31
+ --basalt-font-head-stretch: 88%;
27
32
  --basalt-font-sans:
28
33
  'Nunito Sans Variable', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto,
29
34
  Helvetica, Arial, sans-serif;
@@ -75,7 +80,9 @@
75
80
  }
76
81
 
77
82
  /* Hubot Sans is a condensed display face — the spec pins it at 88% font-stretch everywhere it
78
- lands (headings + the Mantine Title component). */
83
+ lands (headings + the Mantine Title component). Read from the knob declared above rather than
84
+ hardcoded here, so a consumer retunes it in one declaration instead of fighting these bare
85
+ element selectors with a more specific rule of their own. */
79
86
  h1,
80
87
  h2,
81
88
  h3,
@@ -83,7 +90,7 @@
83
90
  h5,
84
91
  h6,
85
92
  .mantine-Title-root {
86
- font-stretch: 88%;
93
+ font-stretch: var(--basalt-font-head-stretch, 88%);
87
94
  }
88
95
 
89
96
  /* Scrollbars (docs/DESIGN-SPEC.md §5): 9px, ink-mix thumb (stronger on hover), radius 6,
@@ -116,7 +123,7 @@
116
123
 
117
124
  *::-webkit-scrollbar-thumb {
118
125
  background-color: var(--basalt-scrollbar-thumb);
119
- border-radius: 6px;
126
+ border-radius: var(--vx-radius-ctrl);
120
127
  }
121
128
 
122
129
  *::-webkit-scrollbar-thumb:hover {
@@ -153,14 +160,18 @@
153
160
  .mantine-ScrollArea-scrollbar:active .mantine-ScrollArea-thumb {
154
161
  background-color: var(--basalt-scrollbar-thumb-hover);
155
162
  }
156
- }
157
163
 
158
- /* Print: hide the BasaltShell chrome so only page content prints.
159
- * AppShell.Navbar → <nav>, AppShell.Header → <header>, AppShell.Footer → <footer>. */
160
- @media print {
161
- nav,
162
- header,
163
- footer {
164
- display: none !important;
164
+ /* Print: hide the BasaltShell chrome so only page content prints.
165
+ Scoped to AppShell's own class hooks, NOT to bare nav/header/footer. The element form matched
166
+ any landmark on the page — a consumer with a real <nav> and no BasaltShell silently printed a
167
+ blank one, and being unlayered with `!important` there was nothing they could do about it
168
+ either. `@layer basalt` already outranks `@layer mantine`, so no `!important` is needed to win
169
+ against the AppShell's own display rules. */
170
+ @media print {
171
+ .mantine-AppShell-navbar,
172
+ .mantine-AppShell-header,
173
+ .mantine-AppShell-footer {
174
+ display: none;
175
+ }
165
176
  }
166
177
  }
package/src/surfaces.ts CHANGED
@@ -9,7 +9,7 @@ import type { GuardKind } from './guard/types'
9
9
 
10
10
  // ── Scalar types ──────────────────────────────────────────────────────────────────────────────────
11
11
 
12
- /** The 12 on-disk rule names (agent/rules/basalt-{name}.md — the set-equality target).
12
+ /** The 13 on-disk rule names (agent/rules/basalt-{name}.md — the set-equality target).
13
13
  *
14
14
  * @example
15
15
  * const r: RuleName = 'tokens' // ok
@@ -28,6 +28,7 @@ export type RuleName =
28
28
  | 'data'
29
29
  | 'agent'
30
30
  | 'content'
31
+ | 'app'
31
32
 
32
33
  /** The 3 shipped skill names (agent/skills/basalt-{name}/SKILL.md, placed into a consumer's
33
34
  * .claude/skills/ by `basalt-ui init`/`sync` — the same managed path the rules take).
@@ -95,6 +96,14 @@ type BaseSurface = {
95
96
  readonly shipped: readonly string[]
96
97
  readonly repo: readonly string[]
97
98
  }
99
+ /**
100
+ * Optional peer package names this surface depends on (e.g. '@tanstack/react-query').
101
+ * Single source of truth — read by gen-llms.ts and cli/index.ts; versions resolved from package.json.
102
+ *
103
+ * Lives on the base, not the doctrine triad: an optional peer is a PACKAGING fact, so a tooling
104
+ * surface can carry one too (`./vite` → `vite-plugin-pwa`).
105
+ */
106
+ readonly optionalPeers?: readonly string[]
98
107
  }
99
108
 
100
109
  /**
@@ -112,11 +121,6 @@ export type DoctrineSpec = BaseSurface & {
112
121
  readonly skill: readonly SkillName[]
113
122
  /** Required, but [] is legal for advisory surfaces (router/query: rule only, no guard). */
114
123
  readonly guardKinds: readonly GuardKind[]
115
- /**
116
- * Optional peer package names this surface depends on (e.g. '@tanstack/react-query').
117
- * Single source of truth — read by gen-llms.ts and cli/index.ts; versions resolved from package.json.
118
- */
119
- readonly optionalPeers?: readonly string[]
120
124
  }
121
125
 
122
126
  /**
@@ -225,13 +229,16 @@ export const SURFACES = {
225
229
  './theme-lab': {
226
230
  kind: 'tooling',
227
231
  layer: 'mantine-coupled',
228
- description: 'ThemeLabControls, applyOverrides, COLOR_GROUPS for live theme inspection',
232
+ description:
233
+ 'ThemeLabControls, applyOverrides, COLOR_GROUPS — a low-level inspector for the non-derived structural tokens; identity/color tuning lives in DeriveControls',
229
234
  forbiddenImports: [],
230
235
  },
231
236
  './vite': {
232
237
  kind: 'tooling',
233
238
  layer: 'mantine-coupled',
234
- description: 'basaltViteConfig(opts) — Vite preset for basalt-ui consumer apps',
239
+ description:
240
+ 'basaltViteConfig(opts) — Vite preset for basalt-ui consumer apps; basaltAppPlugin(opts) — PWA head, manifest, and icon metadata derived from the token palette',
241
+ optionalPeers: ['vite-plugin-pwa'],
235
242
  forbiddenImports: [],
236
243
  },
237
244
  './guard': {
@@ -417,6 +424,13 @@ export const SURFACES = {
417
424
  'Mandatory CSS import (after the Mantine styles.layer.css bundles) — @layer basalt base styles, iOS input safety net, font stack',
418
425
  forbiddenImports: [],
419
426
  },
427
+ './tokens.css': {
428
+ kind: 'tooling',
429
+ layer: 'non-js-asset',
430
+ description:
431
+ 'Prebuilt --vx-* token stylesheet — the default buildPaletteCss() output as a plain file, for a consumer with no bundler, no React and no Mantine; retune the selector or trim the spacing set with `basalt-ui tokens:css`',
432
+ forbiddenImports: [],
433
+ },
420
434
  './configs/*': {
421
435
  kind: 'tooling',
422
436
  layer: 'non-js-asset',
@@ -437,7 +451,7 @@ export const SURFACES = {
437
451
  // synthetic global app-wide ban layer — the src/**+app/** glob
438
452
  kind: 'doctrine',
439
453
  layer: 'app-global',
440
- rule: 'mantine',
454
+ rule: 'app',
441
455
  skill: ['basalt-app'],
442
456
  guardKinds: [],
443
457
  globs: {
@@ -470,7 +484,7 @@ export const SURFACES = {
470
484
 
471
485
  /**
472
486
  * Derived, deduped set of doctrine rule names. Projection 1 of SURFACES.
473
- * → ['mantine', 'charts', 'tokens', 'query', 'router', 'forms', 'notifications', 'commands', 'data', 'agent', 'content', 'state'] (order is insertion order of Set)
487
+ * → ['mantine', 'charts', 'tokens', 'query', 'router', 'forms', 'notifications', 'commands', 'data', 'agent', 'content', 'state', 'app'] (order is insertion order of Set)
474
488
  *
475
489
  * @example
476
490
  * RULE_NAMES.includes('tokens') // true
@@ -24,7 +24,7 @@
24
24
  import { DEFAULT_THEME, getPrimaryShade, mergeMantineTheme } from '@mantine/core'
25
25
  import type { MantineTheme } from '@mantine/core'
26
26
  import { describe, expect, test } from 'bun:test'
27
- import { ACCENT, FILL } from '../tokens/palette'
27
+ import { ACCENT, FILL, SURFACE } from '../tokens/palette'
28
28
  import { baseTheme, cssVariablesResolver } from './index'
29
29
 
30
30
  const theme: MantineTheme = mergeMantineTheme(DEFAULT_THEME, baseTheme)
@@ -159,8 +159,9 @@ describe('the accent is split by role: ink inverts, surface does not', () => {
159
159
  for (const scheme of SCHEMES) {
160
160
  test(`the accent surface stays visible AGAINST the ${scheme} page`, () => {
161
161
  // The reason the fill is not simply darkened until white text is comfortable: at 3:1 (WCAG
162
- // non-text) the control must be distinguishable from the page. `#0069a8` would score 2.68:1
163
- // on dark — a button fading into the background.
162
+ // non-text) the control must be distinguishable from the page. Darkening the fill further
163
+ // buys white-text contrast but can drop this ratio below 3 — a button fading into the
164
+ // background.
164
165
  const ratio = contrastRatio(filledBackground(theme.primaryColor, scheme), PAGE[scheme])
165
166
  expect(ratio).toBeGreaterThanOrEqual(3)
166
167
  })
@@ -304,3 +305,18 @@ describe('doctrine inversion #1 reaches every default-variant CONTROL, not just
304
305
  expect(border).not.toContain('surface-border')
305
306
  })
306
307
  })
308
+
309
+ describe('the shipped palette is the generator output at DEFAULT_DERIVE_CONFIG', () => {
310
+ // A handful of exact hexes from `deriveTokens(DEFAULT_DERIVE_CONFIG)` (`tokens/derive.ts`) — the
311
+ // shipped default identity (seed #0077bd, zinc, all four knobs at level 0). Drift here means
312
+ // either the derive constants moved or `palette.ts` stopped reading the generator's output.
313
+ test('accentFill (light + dark, same hex)', () => {
314
+ expect(ACCENT.accentFill.light).toBe('#4374a6')
315
+ expect(ACCENT.accentFill.dark).toBe('#4374a6')
316
+ })
317
+
318
+ test('surface-bg', () => {
319
+ expect(SURFACE.bg.light).toBe('#f2f2f5')
320
+ expect(SURFACE.bg.dark).toBe('#27272a')
321
+ })
322
+ })
@@ -45,7 +45,7 @@ html[data-mantine-color-scheme] .inputWrapper[data-variant='default']:not([data-
45
45
  * which keep their Mantine semantics and take the focus ring alone.
46
46
  */
47
47
  .input {
48
- --field-depth: 0 0 #0000;
48
+ --field-depth: 0 0 transparent;
49
49
 
50
50
  box-shadow: var(--field-depth);
51
51
  }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * `createBasaltTheme`'s `{ density }` option — the graduation of `deriveSpacing` into a first-class
3
+ * consumer API. Mirrors `radius-option.test.ts`'s two invariants:
4
+ *
5
+ * 1. The DEFAULT path (no `options`, or `density: 0`) stays byte-identical to the pre-baked static
6
+ * `baseTheme` — `theme.other.basaltDensity` stays unset, and `theme/spacing.test.ts` (untouched)
7
+ * stays green.
8
+ * 2. A NON-default level rebuilds every density-anchored `defaultProps`/`styles` number AND the
9
+ * `spacing` size-scale from `deriveSpacing(level)`'s output, and lands it on
10
+ * `theme.other.basaltDensity`.
11
+ */
12
+ import { describe, expect, test } from 'bun:test'
13
+ import { deriveSpacing } from '../tokens/palette'
14
+ import { createBasaltTheme } from './index'
15
+
16
+ describe('the default level stays on the static path', () => {
17
+ test('createBasaltTheme() carries no theme.other.basaltDensity', () => {
18
+ expect(createBasaltTheme().other?.['basaltDensity']).toBeUndefined()
19
+ })
20
+
21
+ test('createBasaltTheme(undefined, {}) resolves to the same default', () => {
22
+ expect(createBasaltTheme(undefined, {}).other?.['basaltDensity']).toBeUndefined()
23
+ })
24
+
25
+ test('an explicit density: 0 also carries no basaltDensity', () => {
26
+ expect(createBasaltTheme(undefined, { density: 0 }).other?.['basaltDensity']).toBeUndefined()
27
+ })
28
+ })
29
+
30
+ describe('a non-default density level graduates onto the theme', () => {
31
+ const theme = createBasaltTheme(undefined, { density: -2 })
32
+ const expected = deriveSpacing(-2)
33
+
34
+ test('the resolved values land on theme.other.basaltDensity', () => {
35
+ expect(theme.other?.['basaltDensity']).toEqual(expected)
36
+ })
37
+
38
+ test('Timeline bulletSize follows the resolved step (18)', () => {
39
+ expect(theme.components?.['Timeline']?.defaultProps?.['bulletSize']).toBe(18)
40
+ })
41
+
42
+ test('Progress size follows the resolved step (5)', () => {
43
+ expect(theme.components?.['Progress']?.defaultProps?.['size']).toBe(5)
44
+ })
45
+
46
+ // Read off `expected.scale` rather than hardcoded literals: what this asserts is the WIRING (the
47
+ // resolved scale group reaches `theme.spacing` as rem strings), and the law's own level-0 bases plus
48
+ // its per-level output are locked by `spacing.test.ts` + `density-relations.test.ts`. At the time of
49
+ // writing, `density: -2` resolves to 9/10/14/16/21.
50
+ test('the spacing size-scale reflects the resolved scale group', () => {
51
+ expect(theme.spacing?.xs).toBe(`${expected.scale.xs / 16}rem`)
52
+ expect(theme.spacing?.sm).toBe(`${expected.scale.sm / 16}rem`)
53
+ expect(theme.spacing?.md).toBe(`${expected.scale.md / 16}rem`)
54
+ expect(theme.spacing?.lg).toBe(`${expected.scale.lg / 16}rem`)
55
+ expect(theme.spacing?.xl).toBe(`${expected.scale.xl / 16}rem`)
56
+ })
57
+ })
58
+
59
+ describe('the default theme is unchanged by the density option existing', () => {
60
+ test('createBasaltTheme() still matches the shipped level-0 numbers', () => {
61
+ const theme = createBasaltTheme()
62
+ expect(theme.components?.['Timeline']?.defaultProps?.['bulletSize']).toBe(22)
63
+ expect(theme.components?.['Progress']?.defaultProps?.['size']).toBe(6)
64
+ })
65
+ })
66
+
67
+ describe('a malformed density level throws through createBasaltTheme', () => {
68
+ test('rejects a non-integer', () => {
69
+ expect(() => createBasaltTheme(undefined, { density: 1.5 })).toThrow()
70
+ })
71
+
72
+ test('rejects an out-of-range level', () => {
73
+ expect(() => createBasaltTheme(undefined, { density: 10 })).toThrow()
74
+ })
75
+ })
76
+
77
+ describe('consumer overrides still win on top of a density option', () => {
78
+ test('an explicit override merges onto the density-rebuilt theme', () => {
79
+ const theme = createBasaltTheme({ primaryColor: 'green' }, { density: -2 })
80
+ expect(theme.primaryColor).toBe('green')
81
+ expect(theme.other?.['basaltDensity']).toEqual(deriveSpacing(-2))
82
+ })
83
+ })
84
+
85
+ describe('density combines with radius and derive without dropping any', () => {
86
+ test('all three land on theme.other', () => {
87
+ const theme = createBasaltTheme(undefined, {
88
+ derive: { accent: '#16a34a' },
89
+ radius: 2,
90
+ density: -2,
91
+ })
92
+ expect(theme.other?.['basaltDerive']).toBeDefined()
93
+ expect(theme.other?.['basaltRadius']).toBeDefined()
94
+ expect(theme.other?.['basaltDensity']).toEqual(deriveSpacing(-2))
95
+ })
96
+ })