basalt-ui 1.2.0 → 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/CHANGELOG.md +16 -0
- package/README.md +17 -3
- package/agent/rules/basalt-tokens.md +14 -5
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +51 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +17 -2
- package/dist/styles.css +21 -10
- package/dist/surfaces.d.ts +6 -0
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +6 -0
- package/dist/tokens/index.d.ts +72 -0
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +41 -5
- package/dist/tokens.css +248 -0
- package/llms.txt +11 -2
- package/package.json +18 -2
- package/src/cli/index.ts +74 -1
- package/src/cli/tokens-css.test.ts +90 -0
- package/src/guard/check-source.test.ts +68 -11
- package/src/guard/index.ts +60 -3
- package/src/styles.css +21 -10
- package/src/surfaces.ts +7 -0
- package/src/tokens/index.ts +142 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [1.3.0](https://github.com/jkrumm/basalt-ui/compare/v1.2.0...v1.3.0) (2026-07-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* realign the spacing guard with the retuned scale and CSS reality ([dc6918a](https://github.com/jkrumm/basalt-ui/commit/dc6918a8e5753ce6b5ebb187ccc97421293a0014))
|
|
7
|
+
* stop styles.css reaching past the framework's own chrome ([24f66dc](https://github.com/jkrumm/basalt-ui/commit/24f66dc0e0bb9bd8386235ee3a9e2974eb6b452c))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add a core-only spacing emission mode to buildPaletteCss ([1a3d59b](https://github.com/jkrumm/basalt-ui/commit/1a3d59bb1558bb66771d3a51295993ab18084015))
|
|
13
|
+
* let buildPaletteCss target a custom color-scheme selector ([944a674](https://github.com/jkrumm/basalt-ui/commit/944a674c02a47b32c6badf7a2e000e4b0ccb26b3))
|
|
14
|
+
* make the react and mantine peers optional ([841f88f](https://github.com/jkrumm/basalt-ui/commit/841f88fdfed2ba946a72921b231bcdc427af173c))
|
|
15
|
+
* ship a prebuilt tokens.css and a tokens:css subcommand ([b23aca3](https://github.com/jkrumm/basalt-ui/commit/b23aca32b81cf4c9d580562cfc46b89a9c5a38da))
|
|
16
|
+
|
|
1
17
|
# [1.2.0](https://github.com/jkrumm/basalt-ui/compare/v1.1.1...v1.2.0) (2026-07-27)
|
|
2
18
|
|
|
3
19
|
|
package/README.md
CHANGED
|
@@ -22,13 +22,26 @@ bun add basalt-ui
|
|
|
22
22
|
bun add react react-dom @mantine/core @mantine/hooks @tanstack/react-query
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
`@tanstack/react-query` (`BasaltProvider` hard-requires it at build
|
|
27
|
-
|
|
25
|
+
The root `.` entry needs all five: `react` / `react-dom` `^19`, `@mantine/core` +
|
|
26
|
+
`@mantine/hooks` `^9.3`, and `@tanstack/react-query` (`BasaltProvider` hard-requires it at build
|
|
27
|
+
time). **Install them yourself — every peer is declared `optional`**, so no package manager adds
|
|
28
|
+
them for you and a missing one surfaces as an unresolved import when you build, not as a warning
|
|
29
|
+
when you install. That optionality is what lets the Mantine-free subpaths cost nothing (below);
|
|
30
|
+
version mismatches on an installed peer still warn.
|
|
28
31
|
|
|
29
32
|
A real app also needs `@types/react @types/react-dom` (dev) and a standard Vite `vite-env.d.ts`
|
|
30
33
|
for `tsc --noEmit` to pass.
|
|
31
34
|
|
|
35
|
+
**No React?** `./tokens`, `./charts`, `./state` and `./guard` resolve with none of the five
|
|
36
|
+
installed, and the token system is consumable with no package at all:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bunx basalt-ui tokens:css --selector-attribute data-theme --only core --out src/tokens.css
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
See [`docs/FRAMEWORK-FREE.md`](https://github.com/jkrumm/basalt-ui/blob/master/docs/FRAMEWORK-FREE.md)
|
|
43
|
+
for the selector-specificity trap, the `color-mix` opacity law, and the surface-token roles.
|
|
44
|
+
|
|
32
45
|
### 2. Scaffold the repo doctrine (`basalt-ui init`)
|
|
33
46
|
|
|
34
47
|
```bash
|
|
@@ -199,6 +212,7 @@ scanned files. Other `"basalt"` config keys (`exempt`,
|
|
|
199
212
|
| `./connectivity` | coupled | `ConnectivityProvider` (aggregates browser/React-Query/SSE/health-check status), `useConnectivity`, `ConnectivityIndicator` — auto-mounted by `BasaltProvider` |
|
|
200
213
|
| `./content` | coupled | `Prose`, `CodeBlock`, `Callout`, `TableOfContents`, `ReadingProgress`, `Markdown`, `MermaidDiagram`, `ArticleLayout`, `ArticleCard` / `ArticleGrid`, `GuideLink` / `GuideDrawer`, `mdxComponents` |
|
|
201
214
|
| `./styles.css` | — | `@layer basalt` base styles, iOS input safety net, font stack |
|
|
215
|
+
| `./tokens.css` | **free** | Prebuilt `--vx-*` stylesheet — the default `buildPaletteCss()` output as a plain file, for a consumer with no bundler, React or Mantine; `basalt-ui tokens:css` re-emits it with a custom scheme selector |
|
|
202
216
|
| `./configs/*` | — | Raw toolchain presets — oxlint, oxfmt, tsconfig (base/react-app/node), lefthook |
|
|
203
217
|
| `./llms.txt` | — | Machine-readable surface map — one entry per published subpath with import specifier, description, layer, and optional peers |
|
|
204
218
|
|
|
@@ -93,10 +93,12 @@ Popover, Accordion, cards) renders one border shade, one card background, and on
|
|
|
93
93
|
|
|
94
94
|
## Spacing & radius — prefer the scale token
|
|
95
95
|
|
|
96
|
-
- `baseTheme` owns the scales: `spacing`
|
|
97
|
-
|
|
98
|
-
`
|
|
99
|
-
|
|
96
|
+
- `baseTheme` owns the scales: `spacing` 11/13/18/20/26 → `xs…xl`, `radius` 2/4/6/16/32 → `xs…xl`.
|
|
97
|
+
Both are DERIVED — `deriveSpacing(level)` / `deriveRadius(level)` in `tokens/palette.ts` move them
|
|
98
|
+
with `createBasaltTheme`'s `density` / `radius` knobs, so read the numbers as level-0 values, not
|
|
99
|
+
as constants. **Use the token**, not the raw number, when a value equals a step: `p="md"` not
|
|
100
|
+
`p={18}`, `gap="sm"` not `gap={13}`, `radius="sm"` not `radius={4}`. The guard flags exact
|
|
101
|
+
token-equals (`p={18}`, any numeric `radius`).
|
|
100
102
|
- **Card radius has one source: `--vx-radius-card` (7px) = `VX.radiusCard`.** Every
|
|
101
103
|
card corner — the Mantine chrome (`Card`/`Paper`, `radius="md"`) and the Mantine-free `ChartCard`
|
|
102
104
|
(`var(--vx-radius-card)`) — resolves to this single token; cards must never diverge. Don't inline
|
|
@@ -105,8 +107,15 @@ Popover, Accordion, cards) renders one border shade, one card background, and on
|
|
|
105
107
|
spacing step (`sm`/`xs`) for shell, nav, and card padding rather than `md`/`lg` air (see
|
|
106
108
|
basalt-mantine.md for the shipped dense defaults).
|
|
107
109
|
- **Sub-scale micro-spacing is legitimate and allowed raw** — `gap={2}`, `pl={4}`, `mt={6}` have no
|
|
108
|
-
token equivalent (the scale starts at
|
|
110
|
+
token equivalent (the scale starts at 11). Use them freely for tight clusters; don't invent
|
|
109
111
|
micro-tokens or pepper `theme-allow`. One-off layout dims (`h={36}`, `w={64}`) are also fine raw.
|
|
112
|
+
**The same permission holds in CSS modules**, where it has to be enforced differently: there is no
|
|
113
|
+
prop form to prefer, so `inline-spacing` simply does not fire on a declaration whose every literal
|
|
114
|
+
is ≤ 10px (`gap: 2px`, `padding: 4px 8px`). A `var()` component is dropped before that judgement;
|
|
115
|
+
one non-micro value makes the whole declaration a finding (`padding: 4px 16px` flags). Other units
|
|
116
|
+
are out — the doctrine is px, so `padding: 1.5rem` still flags. An inline style OBJECT in TSX
|
|
117
|
+
(`style={{ padding: 4 }}`) also still flags: there the Mantine prop exists and should have been
|
|
118
|
+
used.
|
|
110
119
|
- **Icons** size via the icon's own `size` prop (`size={16}`), not spacing tokens — that's not spacing.
|
|
111
120
|
|
|
112
121
|
## Type
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -314,6 +314,20 @@ export type InfoOutput = {
|
|
|
314
314
|
* `basalt info --json` → stable JSON (InfoOutput shape)
|
|
315
315
|
*/
|
|
316
316
|
export declare function info(flags: string[]): number;
|
|
317
|
+
/**
|
|
318
|
+
* tokens:css — emit the `--vx-*` stylesheet, optionally retargeted.
|
|
319
|
+
*
|
|
320
|
+
* The escape hatch from installing anything: a static site runs this once (`bunx basalt-ui
|
|
321
|
+
* tokens:css --selector-attribute data-theme --out src/tokens.css`) and consumes basalt's token
|
|
322
|
+
* system as plain CSS, with no package in its dependency tree at all. `basalt-ui/tokens.css` is the
|
|
323
|
+
* same artifact for a consumer that does install; this command exists for the ones that shouldn't
|
|
324
|
+
* have to just to change a selector.
|
|
325
|
+
*
|
|
326
|
+
* It parses flags and calls `buildPaletteCss` — nothing else. No emission logic, no post-processing
|
|
327
|
+
* of the returned string: the CLI and the API must not be able to disagree about what basalt's
|
|
328
|
+
* tokens are.
|
|
329
|
+
*/
|
|
330
|
+
export declare function tokensCss(flags: string[], cwd?: string): number;
|
|
317
331
|
/**
|
|
318
332
|
* guard-hook — PreToolUse stdin adapter.
|
|
319
333
|
*
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAA;AAE/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAA2C,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAA;AAE/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAA2C,MAAM,aA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AA;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CA8F5C;AAUD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CA4C9E;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqF5E;AAWD;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCzF;AAKD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA;AACnF,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/cli/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { fileURLToPath } from "node:url";
|
|
|
13
13
|
import { checkSource, DEFAULT_GUARD_CONFIG, GUARD_RULES } from "../guard/index.js";
|
|
14
14
|
import { evaluateGuardHook } from "../guard/guard-hook.js";
|
|
15
15
|
import { RULE_NAMES, SKILL_NAMES, SURFACES, TOKEN_LAYER_BOUNDARY_SURFACES } from "../surfaces.js";
|
|
16
|
+
import { buildPaletteCss } from "../tokens/index.js";
|
|
16
17
|
const DEFAULT_ROOT = "src";
|
|
17
18
|
const DEFAULT_ROOTS = [DEFAULT_ROOT];
|
|
18
19
|
function resolveRoots(cfg) {
|
|
@@ -814,6 +815,51 @@ basalt-ui v${pkgVersion} \u2014 published surface
|
|
|
814
815
|
console.log("");
|
|
815
816
|
return 0;
|
|
816
817
|
}
|
|
818
|
+
function flagValue(flags, name) {
|
|
819
|
+
const i = flags.indexOf(name);
|
|
820
|
+
if (i === -1) return void 0;
|
|
821
|
+
const value = flags[i + 1];
|
|
822
|
+
return value === void 0 || value.startsWith("--") ? void 0 : value;
|
|
823
|
+
}
|
|
824
|
+
function tokensCss(flags, cwd = process.cwd()) {
|
|
825
|
+
const attribute = flagValue(flags, "--selector-attribute");
|
|
826
|
+
const darkValue = flagValue(flags, "--dark-value");
|
|
827
|
+
const lightValue = flagValue(flags, "--light-value");
|
|
828
|
+
const defaultScheme = flagValue(flags, "--default-scheme");
|
|
829
|
+
const only = flagValue(flags, "--only");
|
|
830
|
+
if (defaultScheme !== void 0 && !["dark", "light", "none"].includes(defaultScheme)) {
|
|
831
|
+
console.error(
|
|
832
|
+
`tokens:css: --default-scheme must be dark, light or none (got '${defaultScheme}')`
|
|
833
|
+
);
|
|
834
|
+
return 1;
|
|
835
|
+
}
|
|
836
|
+
if (only !== void 0 && !["core", "all"].includes(only)) {
|
|
837
|
+
console.error(`tokens:css: --only must be core or all (got '${only}')`);
|
|
838
|
+
return 1;
|
|
839
|
+
}
|
|
840
|
+
const scheme = {
|
|
841
|
+
...attribute === void 0 ? {} : { attribute },
|
|
842
|
+
...darkValue === void 0 ? {} : { darkValue },
|
|
843
|
+
...lightValue === void 0 ? {} : { lightValue }
|
|
844
|
+
};
|
|
845
|
+
const css = buildPaletteCss({
|
|
846
|
+
...Object.keys(scheme).length === 0 ? {} : { scheme },
|
|
847
|
+
...defaultScheme === void 0 ? {} : { defaultScheme },
|
|
848
|
+
...flags.includes("--media-fallback") ? { mediaFallback: true } : {},
|
|
849
|
+
...only === void 0 ? {} : { only }
|
|
850
|
+
});
|
|
851
|
+
const out = flagValue(flags, "--out");
|
|
852
|
+
if (out === void 0) {
|
|
853
|
+
process.stdout.write(`${css}
|
|
854
|
+
`);
|
|
855
|
+
return 0;
|
|
856
|
+
}
|
|
857
|
+
const target = isAbsolute(out) ? out : resolve(cwd, out);
|
|
858
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
859
|
+
writeFileSync(target, css);
|
|
860
|
+
console.log(`wrote ${css.split("\n").length} lines \u2192 ${relative(cwd, target) || target}`);
|
|
861
|
+
return 0;
|
|
862
|
+
}
|
|
817
863
|
async function guardHook(cwd = process.cwd()) {
|
|
818
864
|
let raw;
|
|
819
865
|
try {
|
|
@@ -889,7 +935,7 @@ async function guardHook(cwd = process.cwd()) {
|
|
|
889
935
|
}
|
|
890
936
|
return 0;
|
|
891
937
|
}
|
|
892
|
-
const USAGE = "Usage: basalt-ui <init [--with-router] [--with-query] | sync [--force] [--check] | check-theme | check-coverage | info [--json] | doctor | guard-hook | help>\n\nEvery subcommand accepts --help / -h to print this message and exit without running.";
|
|
938
|
+
const USAGE = "Usage: basalt-ui <init [--with-router] [--with-query] | sync [--force] [--check] | check-theme | check-coverage | info [--json] | doctor | guard-hook | tokens:css | help>\n\ntokens:css [--out <path>] [--selector-attribute <attr>] [--dark-value <v>] [--light-value <v>]\n [--default-scheme <dark|light|none>] [--media-fallback] [--only <core|all>]\n Emit the --vx-* stylesheet (stdout unless --out). Defaults reproduce basalt-ui/tokens.css.\n\nEvery subcommand accepts --help / -h to print this message and exit without running.";
|
|
893
939
|
function run(argv, cwd = process.cwd()) {
|
|
894
940
|
const [cmd, ...flags] = argv;
|
|
895
941
|
if (cmd === "help" || cmd === "--help" || cmd === "-h" || flags.includes("--help") || flags.includes("-h")) {
|
|
@@ -914,6 +960,8 @@ function run(argv, cwd = process.cwd()) {
|
|
|
914
960
|
return doctor(cwd);
|
|
915
961
|
case "guard-hook":
|
|
916
962
|
return guardHook(cwd);
|
|
963
|
+
case "tokens:css":
|
|
964
|
+
return tokensCss(flags, cwd);
|
|
917
965
|
default:
|
|
918
966
|
console.error(USAGE);
|
|
919
967
|
return 1;
|
|
@@ -932,5 +980,6 @@ export {
|
|
|
932
980
|
managedFiles,
|
|
933
981
|
normalizeForLedger,
|
|
934
982
|
run,
|
|
935
|
-
sync
|
|
983
|
+
sync,
|
|
984
|
+
tokensCss
|
|
936
985
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE9D,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE9D,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;AAuL/C,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,WAkBlC,CAAA;AA0QD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;gCA0BL,WAAW;;;;;;gCAaX,WAAW;;;;;;;gCAaX,WAAW;;;;;;;gCAQX,WAAW;;;;;;gCAOX,WAAW;;;;;;;gCASX,WAAW;;;;;;gCAOX,WAAW;;;;;;;gCASX,WAAW;;;;;;gCAMX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCAUX,WAAW;;;;;;;gCAUX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCAUX,WAAW;;;;CAOmB,CAAA;AAUjD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,EAAE,CAuNtF"}
|
package/dist/guard/index.js
CHANGED
|
@@ -17,6 +17,19 @@ const RAW_HTML_TAG = /<(?:div|span|section|header|nav|footer|aside|main|article|
|
|
|
17
17
|
const INLINE_STYLE = /style=\{\{/;
|
|
18
18
|
const LAYOUT_SURFACE_PROP = /\b(?:display|padding|margin|gap|flex|grid|border|background|width|height)\b/;
|
|
19
19
|
const INLINE_SPACING = /\b(?:padding(?:Top|Bottom|Left|Right)?|margin(?:Top|Bottom|Left|Right)?|gap|rowGap|columnGap)\s*:\s*(?!var\()['"]?-?(?!0\b)\d/g;
|
|
20
|
+
const MICRO_SPACING_CEILING_PX = 10;
|
|
21
|
+
function isSubScaleCssSpacing(line, matchIndex) {
|
|
22
|
+
const colon = line.indexOf(":", matchIndex);
|
|
23
|
+
if (colon === -1) return false;
|
|
24
|
+
const rest = line.slice(colon + 1);
|
|
25
|
+
const end = rest.search(/[;}]/);
|
|
26
|
+
const value = (end === -1 ? rest : rest.slice(0, end)).replace(/var\([^)]*\)/g, " ").trim();
|
|
27
|
+
if (value === "") return true;
|
|
28
|
+
return value.split(/\s+/).every((part) => {
|
|
29
|
+
const literal = /^-?(\d+(?:\.\d+)?)(?:px)?$/.exec(part);
|
|
30
|
+
return literal !== null && Number(literal[1]) <= MICRO_SPACING_CEILING_PX;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
20
33
|
const INLINE_DISPLAY = /\bdisplay\s*:\s*['"](?:inline-)?(?:flex|grid)['"]/g;
|
|
21
34
|
const RAW_VISX_AXIS = /<Axis(?:Left|Bottom|Right)\b/g;
|
|
22
35
|
const AXIS_WRAPPER_FILE = /(?:^|\/)Axes\.tsx$/;
|
|
@@ -30,7 +43,7 @@ const RAW_FORM_CONTROL = /<(?:input|select|textarea)\b/g;
|
|
|
30
43
|
const RAW_FORM_CONTROL_TAG = /<(?:input|select|textarea)\b(?:=>|[^>])*?>/g;
|
|
31
44
|
const STYLES_INPUT_PART = /\bstyles\s*=\s*\{\{\s*input\s*:\s*\{([^}]*)\}/g;
|
|
32
45
|
const SUB_16_FONT_SIZE = /font-?[Ss]ize\s*:\s*['"]?(-?\d+(?:\.\d+)?)(?:px)?['"]?(?=[,\s}]|$)/g;
|
|
33
|
-
const DEFAULT_SPACING_STEPS = [
|
|
46
|
+
const DEFAULT_SPACING_STEPS = [11, 13, 18, 20, 26];
|
|
34
47
|
const DEFAULT_FORBIDDEN_ACCENTS = ["teal", "violet", "grape", "indigo", "pink"];
|
|
35
48
|
const DEFAULT_GUARD_CONFIG = {
|
|
36
49
|
spacingSteps: DEFAULT_SPACING_STEPS,
|
|
@@ -384,7 +397,8 @@ function checkSource(text, relPath, cfg) {
|
|
|
384
397
|
GUARD_RULES["raw-radius"].pattern.flags
|
|
385
398
|
);
|
|
386
399
|
const lines = text.split("\n");
|
|
387
|
-
const
|
|
400
|
+
const syntax = guardSyntaxFor(relPath);
|
|
401
|
+
const codeText = stripComments(text, syntax);
|
|
388
402
|
const codeLines = codeText.split("\n");
|
|
389
403
|
for (let i = 0; i < lines.length; i++) {
|
|
390
404
|
const line = codeLines[i] ?? "";
|
|
@@ -439,6 +453,7 @@ function checkSource(text, relPath, cfg) {
|
|
|
439
453
|
}
|
|
440
454
|
if (GUARD_RULES["inline-spacing"].enabled(cfg)) {
|
|
441
455
|
for (const m of line.matchAll(GUARD_RULES["inline-spacing"].pattern)) {
|
|
456
|
+
if (syntax === "css" && isSubScaleCssSpacing(line, m.index)) continue;
|
|
442
457
|
findings.push({ relPath, line: i + 1, token: m[0], kind: "inline-spacing" });
|
|
443
458
|
}
|
|
444
459
|
}
|
package/dist/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,
|
|
@@ -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/dist/surfaces.d.ts
CHANGED
|
@@ -331,6 +331,12 @@ export declare const SURFACES: {
|
|
|
331
331
|
readonly description: "Mandatory CSS import (after the Mantine styles.layer.css bundles) — @layer basalt base styles, iOS input safety net, font stack";
|
|
332
332
|
readonly forbiddenImports: readonly [];
|
|
333
333
|
};
|
|
334
|
+
readonly './tokens.css': {
|
|
335
|
+
readonly kind: "tooling";
|
|
336
|
+
readonly layer: "non-js-asset";
|
|
337
|
+
readonly description: "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`";
|
|
338
|
+
readonly forbiddenImports: readonly [];
|
|
339
|
+
};
|
|
334
340
|
readonly './configs/*': {
|
|
335
341
|
readonly kind: "tooling";
|
|
336
342
|
readonly layer: "non-js-asset";
|
package/dist/surfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.d.ts","sourceRoot":"","sources":["../src/surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,eAAe,GACf,UAAU,GACV,MAAM,GACN,OAAO,GACP,SAAS,GACT,KAAK,CAAA;AAET;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,eAAe,GAAG,eAAe,CAAA;AAExE;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,iBAAiB,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,CAAA;AAElF;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;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;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAC5B,CAAA;AAED,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,WAAW,CAAA;AA8BpD;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2S2B,CAAA;AAIhD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,qBAMiB,CAAA;AAIxC;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,sBAMiB,CAAA;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAAqC,CAAA;AAEnG;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACzC,OAAO,CAET"}
|
package/dist/surfaces.js
CHANGED
|
@@ -244,6 +244,12 @@ const SURFACES = {
|
|
|
244
244
|
description: "Mandatory CSS import (after the Mantine styles.layer.css bundles) \u2014 @layer basalt base styles, iOS input safety net, font stack",
|
|
245
245
|
forbiddenImports: []
|
|
246
246
|
},
|
|
247
|
+
"./tokens.css": {
|
|
248
|
+
kind: "tooling",
|
|
249
|
+
layer: "non-js-asset",
|
|
250
|
+
description: "Prebuilt --vx-* token stylesheet \u2014 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`",
|
|
251
|
+
forbiddenImports: []
|
|
252
|
+
},
|
|
247
253
|
"./configs/*": {
|
|
248
254
|
kind: "tooling",
|
|
249
255
|
layer: "non-js-asset",
|
package/dist/tokens/index.d.ts
CHANGED
|
@@ -148,12 +148,76 @@ export declare function defineSeries<const T extends SeriesMap>(map: T): T;
|
|
|
148
148
|
export declare function groupTokens<const T extends SeriesMap>(name: string, map: T): {
|
|
149
149
|
[K in keyof T]: string;
|
|
150
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* The attribute + values the per-scheme blocks key off. Defaults reproduce Mantine's own toggle
|
|
153
|
+
* (`data-mantine-color-scheme` = `dark` / `light`), so a consumer only names the axis it differs
|
|
154
|
+
* on. Supplying this object at all switches the emitter onto the framework-neutral selector shape
|
|
155
|
+
* — see {@link BuildPaletteOpts.scheme}.
|
|
156
|
+
*/
|
|
157
|
+
export type ColorSchemeSelector = {
|
|
158
|
+
attribute?: string;
|
|
159
|
+
darkValue?: string;
|
|
160
|
+
lightValue?: string;
|
|
161
|
+
};
|
|
151
162
|
/** Options for {@link buildPaletteCss}. */
|
|
152
163
|
export type BuildPaletteOpts = {
|
|
153
164
|
/** Extra named series maps to emit under the given prefixes (e.g. `{ '': SERIES, 'activity-': ACTIVITY }`). */
|
|
154
165
|
groups?: Record<string, SeriesMap>;
|
|
155
166
|
/** Theme-independent derived declarations (gradients, semantic fills) emitted once on `:root`. */
|
|
156
167
|
derived?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* Attribute + values the per-scheme blocks key off — for a consumer whose scheme toggle is not
|
|
170
|
+
* Mantine's (a static site on `data-theme`, say). Default: Mantine's own
|
|
171
|
+
* `data-mantine-color-scheme` = `dark` / `light`.
|
|
172
|
+
*
|
|
173
|
+
* Setting ANY of `scheme` / `defaultScheme` / `mediaFallback` moves the emitter off the legacy
|
|
174
|
+
* `html[…]` selector onto `:root[…]`. That is deliberate and load-bearing, NOT cosmetic:
|
|
175
|
+
*
|
|
176
|
+
* `:root[data-theme='dark']` 0-2-0 ← what this path emits
|
|
177
|
+
* `html[data-theme='dark']` 0-1-1
|
|
178
|
+
* `[data-theme='dark']` 0-1-0 ← same as a bare `:root`, so source order decides
|
|
179
|
+
*
|
|
180
|
+
* A light-default site whose own `:root` block happens to come last would beat the third form
|
|
181
|
+
* outright — dark mode silently does nothing. `:root[…]` sits above both a bare `:root` and
|
|
182
|
+
* `html[…]`, and carries no assumption about the element the attribute lands on.
|
|
183
|
+
*
|
|
184
|
+
* The no-options path keeps emitting `html[data-mantine-color-scheme='…']` verbatim, because a
|
|
185
|
+
* basalt consumer may already override `--vx-*` under that exact selector — raising basalt's own
|
|
186
|
+
* specificity would silently win over their override.
|
|
187
|
+
*/
|
|
188
|
+
scheme?: ColorSchemeSelector;
|
|
189
|
+
/**
|
|
190
|
+
* Which scheme rides along on the bare `:root` block — the one that applies when the attribute
|
|
191
|
+
* is absent. Default: `'dark'` (the framework's own default scheme).
|
|
192
|
+
*
|
|
193
|
+
* `'none'` emits no bare-`:root` primitives at all: each scheme gets only its attribute block,
|
|
194
|
+
* and an unattributed document falls back to the theme-independent scalars alone. Pair it with
|
|
195
|
+
* `mediaFallback` unless the consumer always sets the attribute.
|
|
196
|
+
*/
|
|
197
|
+
defaultScheme?: 'dark' | 'light' | 'none';
|
|
198
|
+
/**
|
|
199
|
+
* Also emit an `@media (prefers-color-scheme: …)` block for every scheme that is not the bare
|
|
200
|
+
* `:root` default, so a document with no attribute set follows the OS. Default: `false`.
|
|
201
|
+
*
|
|
202
|
+
* The block is a bare `:root` (0-1-0), so an explicit attribute block (0-2-0) always wins over
|
|
203
|
+
* it regardless of source order — the OS preference is a fallback, never an override.
|
|
204
|
+
*/
|
|
205
|
+
mediaFallback?: boolean;
|
|
206
|
+
/**
|
|
207
|
+
* How much of the SPACING set to emit. Default: `'all'` (every one of the 104 `--vx-space-*`
|
|
208
|
+
* declarations the framework's own components read).
|
|
209
|
+
*
|
|
210
|
+
* `'core'` keeps the 9 generic anchors — the stack rhythm, the two control heights, the row
|
|
211
|
+
* insets — and drops the 95 named for a specific basalt component
|
|
212
|
+
* (`--vx-space-agent-transcript-inset`, `--vx-space-toc-sub-indent`, …), taking the emitted set
|
|
213
|
+
* from 197 variables to 102. Nothing outside basalt's own React components reads those, so a
|
|
214
|
+
* framework-free consumer is carrying them for nothing.
|
|
215
|
+
*
|
|
216
|
+
* This is a SPACING filter only: color, radius, shadow, type and status variables are identical
|
|
217
|
+
* in both modes. The partition is derived from the `SPACE` key set rather than a maintained list
|
|
218
|
+
* — see {@link CORE_SPACE_VARS}.
|
|
219
|
+
*/
|
|
220
|
+
only?: 'core' | 'all';
|
|
157
221
|
};
|
|
158
222
|
/**
|
|
159
223
|
* Emit the `--vx-*` stylesheet: a `:root` block of theme-independent scalars, then the
|
|
@@ -170,6 +234,14 @@ export type BuildPaletteOpts = {
|
|
|
170
234
|
*
|
|
171
235
|
* Dark is the default (`:root`) since the framework defaults to dark; the
|
|
172
236
|
* `[data-mantine-color-scheme]` selectors track Mantine's toggle on `<html>`.
|
|
237
|
+
*
|
|
238
|
+
* A non-Mantine consumer retargets all three of those choices — the attribute, which scheme rides
|
|
239
|
+
* the bare `:root`, and whether the OS preference is honoured — via `opts.scheme` /
|
|
240
|
+
* `opts.defaultScheme` / `opts.mediaFallback`. Setting any of them also moves the per-scheme
|
|
241
|
+
* selector from `html[…]` to the framework-neutral, higher-specificity `:root[…]`; see
|
|
242
|
+
* `BuildPaletteOpts.scheme` for why that is not cosmetic. With none of them set the output is
|
|
243
|
+
* byte-identical to what the framework has always emitted (pinned by
|
|
244
|
+
* `tests/palette-css.test.ts`).
|
|
173
245
|
*/
|
|
174
246
|
export declare function buildPaletteCss(opts?: BuildPaletteOpts, data?: PaletteData): string;
|
|
175
247
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAMvE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AAOjC,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAM5D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAO7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,wFAAwF;AACxF,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvD,8FAA8F;AAC9F,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEjD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,GAAG,MAAM,KAAG,MACoB,CAAA;AAsCrE,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIL,CAAA;AAOV;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAExC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;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AE,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAkB1E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CASvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAGtE"}
|
package/dist/tokens/index.js
CHANGED
|
@@ -347,13 +347,21 @@ function spaceDecls(space) {
|
|
|
347
347
|
// as JS numbers via `useBasaltSpacing()` (Mantine's `<Menu width={…}>` also takes a number).
|
|
348
348
|
];
|
|
349
349
|
}
|
|
350
|
+
const CORE_SPACE_VARS = new Set(
|
|
351
|
+
Object.keys(SPACE).map((key) => `space-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`)
|
|
352
|
+
);
|
|
353
|
+
function isCoreSpaceDecl(line) {
|
|
354
|
+
const name = /^ {2}--vx-([\w-]+):/.exec(line)?.[1];
|
|
355
|
+
return name !== void 0 && CORE_SPACE_VARS.has(name);
|
|
356
|
+
}
|
|
350
357
|
const DEFAULT_SPACE_VALUES = {
|
|
351
358
|
anchors: SPACE,
|
|
352
359
|
scale: SPACE_SCALE,
|
|
353
360
|
step: SPACE_STEP,
|
|
354
361
|
rowLineHeight: ROW_LINE_HEIGHT
|
|
355
362
|
};
|
|
356
|
-
function frameworkDerived(data) {
|
|
363
|
+
function frameworkDerived(data, only) {
|
|
364
|
+
const space = spaceDecls(DEFAULT_SPACE_VALUES);
|
|
357
365
|
return [
|
|
358
366
|
decl("radius-card", `${RADIUS.card}px`),
|
|
359
367
|
decl("radius-ctrl", `${RADIUS.ctrl}px`),
|
|
@@ -368,7 +376,7 @@ function frameworkDerived(data) {
|
|
|
368
376
|
// only in this static block, never in `buildRadiusCss`'s dynamic override (see
|
|
369
377
|
// `RADIUS_STEP.pill`'s doc).
|
|
370
378
|
decl("radius-pill", `${RADIUS_STEP.pill}px`),
|
|
371
|
-
...
|
|
379
|
+
...only === "core" ? space.filter(isCoreSpaceDecl) : space,
|
|
372
380
|
// Article-density Prose measure (docs/CONTENT-SPEC.md §5) — theme-independent, like the radii.
|
|
373
381
|
decl("prose-measure", "72ch"),
|
|
374
382
|
// The fill band (see FILL in palette.ts). Emitted on `:root`, NOT per scheme — a filled surface
|
|
@@ -406,10 +414,12 @@ function defineSeries(map) {
|
|
|
406
414
|
function groupTokens(name, map) {
|
|
407
415
|
return seriesTokens(map, `${name}-`);
|
|
408
416
|
}
|
|
417
|
+
const MANTINE_SCHEME_ATTRIBUTE = "data-mantine-color-scheme";
|
|
418
|
+
const indent = (block) => block.split("\n").map((line) => line === "" ? line : ` ${line}`).join("\n");
|
|
409
419
|
function buildPaletteCss(opts = {}, data = buildPaletteData()) {
|
|
410
420
|
const groups = opts.groups ?? {};
|
|
411
421
|
const extraDerived = (opts.derived ?? []).map((d) => ` ${d}`).join("\n");
|
|
412
|
-
const derivedBlock = frameworkDerived(data);
|
|
422
|
+
const derivedBlock = frameworkDerived(data, opts.only ?? "all");
|
|
413
423
|
const derived = extraDerived ? `${derivedBlock}
|
|
414
424
|
${extraDerived}` : derivedBlock;
|
|
415
425
|
const side = (s) => {
|
|
@@ -418,9 +428,11 @@ ${extraDerived}` : derivedBlock;
|
|
|
418
428
|
return extra ? `${framework}
|
|
419
429
|
${extra}` : framework;
|
|
420
430
|
};
|
|
421
|
-
|
|
431
|
+
const rootBlock = `:root {
|
|
422
432
|
${derived}
|
|
423
|
-
}
|
|
433
|
+
}`;
|
|
434
|
+
if (opts.scheme === void 0 && opts.defaultScheme === void 0 && !opts.mediaFallback) {
|
|
435
|
+
return `${rootBlock}
|
|
424
436
|
:root,
|
|
425
437
|
html[data-mantine-color-scheme='dark'] {
|
|
426
438
|
${side("dark")}
|
|
@@ -428,6 +440,30 @@ ${side("dark")}
|
|
|
428
440
|
html[data-mantine-color-scheme='light'] {
|
|
429
441
|
${side("light")}
|
|
430
442
|
}`;
|
|
443
|
+
}
|
|
444
|
+
const attribute = opts.scheme?.attribute ?? MANTINE_SCHEME_ATTRIBUTE;
|
|
445
|
+
const value = {
|
|
446
|
+
dark: opts.scheme?.darkValue ?? "dark",
|
|
447
|
+
light: opts.scheme?.lightValue ?? "light"
|
|
448
|
+
};
|
|
449
|
+
const defaultScheme = opts.defaultScheme ?? "dark";
|
|
450
|
+
const order = defaultScheme === "light" ? ["light", "dark"] : ["dark", "light"];
|
|
451
|
+
const blocks = [rootBlock];
|
|
452
|
+
for (const s of order) {
|
|
453
|
+
const selector = s === defaultScheme ? `:root,
|
|
454
|
+
:root[${attribute}='${value[s]}']` : `:root[${attribute}='${value[s]}']`;
|
|
455
|
+
if (opts.mediaFallback === true && s !== defaultScheme) {
|
|
456
|
+
blocks.push(`@media (prefers-color-scheme: ${s}) {
|
|
457
|
+
:root {
|
|
458
|
+
${indent(side(s))}
|
|
459
|
+
}
|
|
460
|
+
}`);
|
|
461
|
+
}
|
|
462
|
+
blocks.push(`${selector} {
|
|
463
|
+
${side(s)}
|
|
464
|
+
}`);
|
|
465
|
+
}
|
|
466
|
+
return blocks.join("\n");
|
|
431
467
|
}
|
|
432
468
|
const FONT_VAR_NAMES = {
|
|
433
469
|
sans: "--basalt-font-sans",
|