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.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +46 -0
- package/README.md +64 -8
- package/agent/rules/basalt-app.md +126 -0
- package/agent/rules/basalt-content.md +3 -1
- package/agent/rules/basalt-tokens.md +14 -5
- package/agent/skills/basalt-app/SKILL.md +28 -7
- package/dist/agent/part-list.d.ts.map +1 -1
- package/dist/agent/part-list.js +17 -7
- package/dist/agent/stick-to-bottom.js +2 -2
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
- package/dist/agent-chat/thread-detail-panel.js +37 -33
- package/dist/agent-chat/thread-message.d.ts.map +1 -1
- package/dist/agent-chat/thread-message.js +8 -5
- package/dist/agent-chat/thread-outcome-card.js +3 -3
- package/dist/agent-chat/thread-workspace.js +1 -1
- package/dist/charts/primitives/ChartLegend.js +2 -0
- package/dist/charts/primitives/ChartTooltip.js +2 -1
- package/dist/cli/index.d.ts +29 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +80 -9
- package/dist/connectivity/connectivity-indicator.d.ts.map +1 -1
- package/dist/connectivity/connectivity-indicator.js +3 -3
- package/dist/content/article-card.module.css +7 -5
- package/dist/content/article-layout.module.css +16 -12
- package/dist/content/callout.module.css +4 -4
- package/dist/content/code-block.module.css +8 -7
- package/dist/content/guide.module.css +3 -3
- package/dist/content/mermaid.module.css +2 -2
- package/dist/content/prose.module.css +59 -29
- package/dist/content/reading-progress.module.css +2 -0
- package/dist/content/toc.module.css +6 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +10 -2
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +3 -16
- package/dist/dashboard/settings-section.js +2 -2
- package/dist/dashboard/settings-section.module.css +2 -2
- package/dist/dashboard/stat-card.js +2 -1
- package/dist/data/virtual-list.d.ts.map +1 -1
- package/dist/data/virtual-list.js +12 -2
- package/dist/forms/FormErrorSummary.js +2 -2
- package/dist/guard/index.d.ts +20 -4
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +266 -38
- package/dist/guard/types.d.ts +24 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/provider/index.d.ts +30 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +32 -7
- package/dist/provider/lab-theme.d.ts +39 -0
- package/dist/provider/lab-theme.d.ts.map +1 -0
- package/dist/provider/lab-theme.js +52 -0
- package/dist/shell/app-header.module.css +2 -2
- package/dist/shell/app-mobile-nav.module.css +1 -1
- package/dist/shell/app-sidebar-account.d.ts.map +1 -1
- package/dist/shell/app-sidebar-account.js +4 -2
- package/dist/shell/app-sidebar.d.ts.map +1 -1
- package/dist/shell/app-sidebar.js +4 -2
- package/dist/shell/app-sidebar.module.css +36 -26
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +11 -4
- package/dist/shell/sidebar-search.module.css +16 -4
- package/dist/styles.css +22 -11
- package/dist/surfaces.d.ts +21 -11
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +10 -3
- package/dist/theme/controls.module.css +1 -1
- package/dist/theme/floating.module.css +1 -1
- package/dist/theme/index.d.ts +116 -11
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +703 -566
- package/dist/theme/nav-link.module.css +1 -1
- package/dist/theme/use-basalt-spacing.d.ts +3 -0
- package/dist/theme/use-basalt-spacing.d.ts.map +1 -0
- package/dist/theme/use-basalt-spacing.js +8 -0
- package/dist/theme-lab/derive-controls.d.ts +13 -0
- package/dist/theme-lab/derive-controls.d.ts.map +1 -0
- package/dist/theme-lab/derive-controls.js +137 -0
- package/dist/theme-lab/derive-state.d.ts +55 -0
- package/dist/theme-lab/derive-state.d.ts.map +1 -0
- package/dist/theme-lab/derive-state.js +81 -0
- package/dist/theme-lab/index.d.ts +12 -2
- package/dist/theme-lab/index.d.ts.map +1 -1
- package/dist/theme-lab/index.js +13 -62
- package/dist/theme-toggle/index.d.ts.map +1 -1
- package/dist/theme-toggle/index.js +3 -2
- package/dist/tokens/derive.d.ts +89 -0
- package/dist/tokens/derive.d.ts.map +1 -0
- package/dist/tokens/derive.js +250 -0
- package/dist/tokens/hct.d.ts +34 -0
- package/dist/tokens/hct.d.ts.map +1 -0
- package/dist/tokens/hct.js +159 -0
- package/dist/tokens/index.d.ts +143 -7
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +322 -48
- package/dist/tokens/palette.d.ts +984 -167
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +617 -119
- package/dist/tokens.css +248 -0
- package/dist/vite-color-mix.d.ts +30 -0
- package/dist/vite-color-mix.d.ts.map +1 -0
- package/dist/vite-color-mix.js +80 -0
- package/dist/vite.d.ts +82 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +312 -0
- package/llms.txt +14 -4
- package/package.json +41 -10
- package/src/agent/part-list.tsx +13 -7
- package/src/agent/stick-to-bottom.tsx +2 -2
- package/src/agent-chat/thread-detail-panel.tsx +13 -10
- package/src/agent-chat/thread-message.tsx +8 -5
- package/src/agent-chat/thread-outcome-card.tsx +2 -2
- package/src/agent-chat/thread-workspace.tsx +2 -2
- package/src/charts/primitives/ChartLegend.tsx +2 -2
- package/src/charts/primitives/ChartTooltip.tsx +2 -2
- package/src/cli/check-theme.test.ts +18 -0
- package/src/cli/index.ts +129 -6
- package/src/cli/tokens-css.test.ts +90 -0
- package/src/connectivity/connectivity-indicator.tsx +8 -2
- package/src/content/article-card.module.css +7 -5
- package/src/content/article-layout.module.css +16 -12
- package/src/content/callout.module.css +4 -4
- package/src/content/code-block.module.css +8 -7
- package/src/content/guide.module.css +3 -3
- package/src/content/mermaid.module.css +2 -2
- package/src/content/prose.module.css +59 -29
- package/src/content/prose.module.css.test.ts +55 -0
- package/src/content/reading-progress.module.css +2 -0
- package/src/content/toc.module.css +6 -3
- package/src/dashboard/delta-badge.tsx +10 -4
- package/src/dashboard/empty-state.tsx +3 -16
- package/src/dashboard/settings-section.module.css +2 -2
- package/src/dashboard/settings-section.tsx +2 -2
- package/src/dashboard/stat-card.tsx +2 -2
- package/src/data/virtual-list.tsx +12 -2
- package/src/forms/FormErrorSummary.tsx +1 -1
- package/src/guard/check-source.test.ts +483 -15
- package/src/guard/index.ts +426 -47
- package/src/guard/types.ts +24 -2
- package/src/index.ts +1 -0
- package/src/provider/index.test.tsx +100 -0
- package/src/provider/index.tsx +79 -7
- package/src/provider/lab-theme.test.ts +147 -0
- package/src/provider/lab-theme.ts +166 -0
- package/src/shell/app-header.module.css +2 -2
- package/src/shell/app-mobile-nav.module.css +1 -1
- package/src/shell/app-sidebar-account.tsx +9 -2
- package/src/shell/app-sidebar.module.css +36 -26
- package/src/shell/app-sidebar.tsx +12 -2
- package/src/shell/index.tsx +14 -3
- package/src/shell/sidebar-search.module.css +16 -4
- package/src/styles.css +22 -11
- package/src/surfaces.ts +24 -10
- package/src/theme/contrast.test.ts +19 -3
- package/src/theme/controls.module.css +1 -1
- package/src/theme/density-option.test.ts +96 -0
- package/src/theme/density-relations.test.ts +428 -0
- package/src/theme/derive-theme.test.ts +101 -0
- package/src/theme/floating.module.css +1 -1
- package/src/theme/fonts-option.test.ts +69 -0
- package/src/theme/index.ts +930 -563
- package/src/theme/nav-link.module.css +1 -1
- package/src/theme/radius-option.test.ts +86 -0
- package/src/theme/radius.test.ts +132 -0
- package/src/theme/spacing.test.ts +432 -0
- package/src/theme/use-basalt-spacing.test.tsx +51 -0
- package/src/theme/use-basalt-spacing.ts +38 -0
- package/src/theme-lab/derive-controls.test.ts +94 -0
- package/src/theme-lab/derive-controls.tsx +227 -0
- package/src/theme-lab/derive-state.test.ts +71 -0
- package/src/theme-lab/derive-state.ts +163 -0
- package/src/theme-lab/index.tsx +29 -68
- package/src/theme-lab/theme-lab.test.ts +4 -18
- package/src/theme-toggle/index.tsx +9 -4
- package/src/tokens/build-fonts-css.test.ts +51 -0
- package/src/tokens/build-radius-css.test.ts +25 -0
- package/src/tokens/density.test.ts +274 -0
- package/src/tokens/derive-radius.test.ts +62 -0
- package/src/tokens/derive.test.ts +30 -0
- package/src/tokens/derive.ts +481 -0
- package/src/tokens/hct.ts +231 -0
- package/src/tokens/index.ts +534 -48
- package/src/tokens/palette.test.ts +114 -0
- package/src/tokens/palette.ts +1118 -180
- package/src/vite-color-mix.test.ts +46 -0
- package/src/vite-color-mix.ts +137 -0
- package/src/vite.test.ts +192 -0
- 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}
|
|
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={
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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: -
|
|
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:
|
|
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:
|
|
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:
|
|
159
|
-
padding:
|
|
160
|
-
border-radius:
|
|
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:
|
|
194
|
-
padding:
|
|
195
|
-
|
|
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:
|
|
218
|
-
height:
|
|
219
|
-
border-radius:
|
|
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
|
|
269
|
-
margin-bottom:
|
|
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:
|
|
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:
|
|
304
|
-
|
|
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
|
|
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={
|
|
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
|
|
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}
|
package/src/shell/index.tsx
CHANGED
|
@@ -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={{
|
|
303
|
+
header={{
|
|
304
|
+
height: { base: step.appShellHeaderMobileHeight, sm: step.appShellHeaderHeight },
|
|
305
|
+
}}
|
|
298
306
|
navbar={{
|
|
299
|
-
width: {
|
|
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:
|
|
9
|
+
gap: var(--vx-space-sidebar-search-gap);
|
|
10
10
|
width: 100%;
|
|
11
|
-
height:
|
|
12
|
-
padding: 0
|
|
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:
|
|
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:
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
+
/** 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:
|
|
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:
|
|
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: '
|
|
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.
|
|
163
|
-
//
|
|
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
|
|
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
|
+
})
|