@unpunnyfuns/swatchbook-blocks 0.2.0 → 0.2.2
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/dist/index.d.mts +1 -1
- package/dist/index.mjs +195 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -241,7 +241,7 @@ interface VirtualAxisShape {
|
|
|
241
241
|
contexts: readonly string[];
|
|
242
242
|
default: string;
|
|
243
243
|
description?: string;
|
|
244
|
-
source: 'resolver' | 'synthetic';
|
|
244
|
+
source: 'resolver' | 'layered' | 'synthetic';
|
|
245
245
|
}
|
|
246
246
|
interface VirtualThemeShape {
|
|
247
247
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -178,6 +178,61 @@ function stringifyFallback(value, fallback) {
|
|
|
178
178
|
return fallback;
|
|
179
179
|
}
|
|
180
180
|
//#endregion
|
|
181
|
+
//#region src/internal/data-attr.ts
|
|
182
|
+
/**
|
|
183
|
+
* Produce a prefixed `data-*` attribute name when `prefix` is set, bare
|
|
184
|
+
* `data-<key>` otherwise. Mirrors `dataAttr` in `@unpunnyfuns/swatchbook-core`
|
|
185
|
+
* so block wrappers and emitted-CSS selectors stay in lockstep without
|
|
186
|
+
* blocks taking a runtime dep on core.
|
|
187
|
+
*/
|
|
188
|
+
function dataAttr(prefix, key) {
|
|
189
|
+
return prefix ? `data-${prefix}-${key}` : `data-${key}`;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Spread helper for the common `<div data-<prefix>-theme="…">` block
|
|
193
|
+
* wrapper. Returns an object keyed on the prefixed attribute name so the
|
|
194
|
+
* call site stays readable: `<div {...themeAttrs(prefix, theme)} />`.
|
|
195
|
+
*/
|
|
196
|
+
function themeAttrs(prefix, themeName) {
|
|
197
|
+
return { [dataAttr(prefix, "theme")]: themeName };
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Vars block chrome reads by literal `var(--sb-*)` regardless of what the
|
|
201
|
+
* project's actual `cssVarPrefix` is. Keeping the literal spelling means we
|
|
202
|
+
* only need to alias these few names on each block wrapper; the bulk of
|
|
203
|
+
* block styling stays untouched.
|
|
204
|
+
*/
|
|
205
|
+
const CHROME_VARS = [
|
|
206
|
+
"color-sys-border-default",
|
|
207
|
+
"color-sys-surface-default",
|
|
208
|
+
"color-sys-surface-muted",
|
|
209
|
+
"color-sys-surface-raised",
|
|
210
|
+
"color-sys-text-default",
|
|
211
|
+
"color-sys-text-muted",
|
|
212
|
+
"color-sys-accent-bg",
|
|
213
|
+
"color-sys-accent-fg",
|
|
214
|
+
"typography-sys-body-font-family",
|
|
215
|
+
"typography-sys-body-font-size"
|
|
216
|
+
];
|
|
217
|
+
/**
|
|
218
|
+
* CSS custom-property aliases that redirect the block chrome's `var(--sb-*)`
|
|
219
|
+
* reads to the project's actual `cssVarPrefix`. Block components spread the
|
|
220
|
+
* return into their wrapper's inline `style`, so the aliases cascade down
|
|
221
|
+
* into every nested block / sample / token-detail piece without each one
|
|
222
|
+
* re-reading the prefix.
|
|
223
|
+
*
|
|
224
|
+
* When `prefix === 'sb'` the aliases are self-references — we skip emission
|
|
225
|
+
* to keep the inline style shorter. When `prefix === ''` (opt-out) the
|
|
226
|
+
* aliases point at the bare `var(--color-sys-…)` names core emitted.
|
|
227
|
+
*/
|
|
228
|
+
function chromeAliases(prefix) {
|
|
229
|
+
if (prefix === "sb") return {};
|
|
230
|
+
const out = {};
|
|
231
|
+
const head = prefix ? `${prefix}-` : "";
|
|
232
|
+
for (const name of CHROME_VARS) out[`--sb-${name}`] = `var(--${head}${name})`;
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
181
236
|
//#region src/internal/channel-globals.ts
|
|
182
237
|
const AXES_GLOBAL_KEY = "swatchbookAxes";
|
|
183
238
|
const THEME_GLOBAL_KEY = "swatchbookTheme";
|
|
@@ -389,6 +444,24 @@ function makeCssVar(path, prefix) {
|
|
|
389
444
|
const tail = path.replaceAll(".", "-");
|
|
390
445
|
return prefix ? `var(--${prefix}-${tail})` : `var(--${tail})`;
|
|
391
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Match a dot-separated DTCG token path against a block `filter` prop.
|
|
449
|
+
*
|
|
450
|
+
* **Supported shapes** (the narrow subset we need — DTCG paths don't have
|
|
451
|
+
* directories, brace expansion, or regex, so we skip a full glob engine):
|
|
452
|
+
*
|
|
453
|
+
* | Pattern | Matches |
|
|
454
|
+
* | ------------------ | --------------------------------------------------- |
|
|
455
|
+
* | `undefined` / `''` | everything |
|
|
456
|
+
* | `*` or `**` | everything |
|
|
457
|
+
* | `color` | exact path `color`, or any descendant `color.*` |
|
|
458
|
+
* | `color.sys.*` | any path whose fixed prefix is `color.sys.` |
|
|
459
|
+
* | `color**` | any path starting with `color` |
|
|
460
|
+
*
|
|
461
|
+
* Not supported (all pass through as literal segment matchers): brace
|
|
462
|
+
* expansion (`{a,b}`), mid-path globs (`color.*.bg`), negation (`!foo`),
|
|
463
|
+
* character classes (`[sys]`). If you hit those, pre-filter by hand.
|
|
464
|
+
*/
|
|
392
465
|
function globMatch(path, glob) {
|
|
393
466
|
if (!glob) return true;
|
|
394
467
|
if (glob === "*" || glob === "**") return true;
|
|
@@ -420,6 +493,7 @@ function BorderSample({ path }) {
|
|
|
420
493
|
const cssVar = makeCssVar(path, cssVarPrefix);
|
|
421
494
|
return /* @__PURE__ */ jsx("div", {
|
|
422
495
|
style: {
|
|
496
|
+
...chromeAliases(cssVarPrefix),
|
|
423
497
|
...sampleStyle$1,
|
|
424
498
|
border: cssVar
|
|
425
499
|
},
|
|
@@ -450,25 +524,6 @@ const emptyStyle = {
|
|
|
450
524
|
opacity: .6
|
|
451
525
|
};
|
|
452
526
|
//#endregion
|
|
453
|
-
//#region src/internal/data-attr.ts
|
|
454
|
-
/**
|
|
455
|
-
* Produce a prefixed `data-*` attribute name when `prefix` is set, bare
|
|
456
|
-
* `data-<key>` otherwise. Mirrors `dataAttr` in `@unpunnyfuns/swatchbook-core`
|
|
457
|
-
* so block wrappers and emitted-CSS selectors stay in lockstep without
|
|
458
|
-
* blocks taking a runtime dep on core.
|
|
459
|
-
*/
|
|
460
|
-
function dataAttr(prefix, key) {
|
|
461
|
-
return prefix ? `data-${prefix}-${key}` : `data-${key}`;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Spread helper for the common `<div data-<prefix>-theme="…">` block
|
|
465
|
-
* wrapper. Returns an object keyed on the prefixed attribute name so the
|
|
466
|
-
* call site stays readable: `<div {...themeAttrs(prefix, theme)} />`.
|
|
467
|
-
*/
|
|
468
|
-
function themeAttrs(prefix, themeName) {
|
|
469
|
-
return { [dataAttr(prefix, "theme")]: themeName };
|
|
470
|
-
}
|
|
471
|
-
//#endregion
|
|
472
527
|
//#region src/BorderPreview.tsx
|
|
473
528
|
const styles$14 = {
|
|
474
529
|
wrapper: surfaceStyle,
|
|
@@ -561,7 +616,10 @@ function BorderPreview({ filter = "border", caption }) {
|
|
|
561
616
|
const captionText = caption ?? `${rows.length} border${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
562
617
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
563
618
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
564
|
-
style:
|
|
619
|
+
style: {
|
|
620
|
+
...chromeAliases(cssVarPrefix),
|
|
621
|
+
...styles$14.wrapper
|
|
622
|
+
},
|
|
565
623
|
children: /* @__PURE__ */ jsx("div", {
|
|
566
624
|
style: styles$14.empty,
|
|
567
625
|
children: "No border tokens match this filter."
|
|
@@ -569,7 +627,10 @@ function BorderPreview({ filter = "border", caption }) {
|
|
|
569
627
|
});
|
|
570
628
|
return /* @__PURE__ */ jsxs("div", {
|
|
571
629
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
572
|
-
style:
|
|
630
|
+
style: {
|
|
631
|
+
...chromeAliases(cssVarPrefix),
|
|
632
|
+
...styles$14.wrapper
|
|
633
|
+
},
|
|
573
634
|
children: [/* @__PURE__ */ jsx("div", {
|
|
574
635
|
style: styles$14.caption,
|
|
575
636
|
children: captionText
|
|
@@ -665,6 +726,8 @@ const styles$13 = {
|
|
|
665
726
|
/**
|
|
666
727
|
* Count segments in the filter before the first glob (`*` / `**`).
|
|
667
728
|
* `color.ref.*` → 2; `color.sys.surface.*` → 3; `color` → 1; undefined → 0.
|
|
729
|
+
*
|
|
730
|
+
* @internal Exported for tests; not part of the public API.
|
|
668
731
|
*/
|
|
669
732
|
function fixedPrefixLength(filter) {
|
|
670
733
|
if (!filter) return 0;
|
|
@@ -721,7 +784,10 @@ function ColorPalette({ filter = "color", groupBy, caption }) {
|
|
|
721
784
|
const captionText = caption ?? `${totalCount} color${totalCount === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
722
785
|
if (totalCount === 0) return /* @__PURE__ */ jsx("div", {
|
|
723
786
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
724
|
-
style:
|
|
787
|
+
style: {
|
|
788
|
+
...chromeAliases(cssVarPrefix),
|
|
789
|
+
...styles$13.wrapper
|
|
790
|
+
},
|
|
725
791
|
children: /* @__PURE__ */ jsx("div", {
|
|
726
792
|
style: styles$13.empty,
|
|
727
793
|
children: "No color tokens match this filter."
|
|
@@ -729,7 +795,10 @@ function ColorPalette({ filter = "color", groupBy, caption }) {
|
|
|
729
795
|
});
|
|
730
796
|
return /* @__PURE__ */ jsxs("div", {
|
|
731
797
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
732
|
-
style:
|
|
798
|
+
style: {
|
|
799
|
+
...chromeAliases(cssVarPrefix),
|
|
800
|
+
...styles$13.wrapper
|
|
801
|
+
},
|
|
733
802
|
children: [/* @__PURE__ */ jsx("div", {
|
|
734
803
|
style: styles$13.caption,
|
|
735
804
|
children: captionText
|
|
@@ -814,9 +883,11 @@ function DimensionBar({ path, kind = "length" }) {
|
|
|
814
883
|
const token = resolved[path];
|
|
815
884
|
const pxValue = toPixels$1(token?.$value);
|
|
816
885
|
const cappedValue = Number.isFinite(pxValue) && pxValue > MAX_RENDER_PX$1 ? `${MAX_RENDER_PX$1}px` : cssVar;
|
|
886
|
+
const aliases = chromeAliases(cssVarPrefix);
|
|
817
887
|
switch (kind) {
|
|
818
888
|
case "radius": return /* @__PURE__ */ jsx("div", {
|
|
819
889
|
style: {
|
|
890
|
+
...aliases,
|
|
820
891
|
...styles$12.radiusSample,
|
|
821
892
|
borderRadius: cssVar
|
|
822
893
|
},
|
|
@@ -824,6 +895,7 @@ function DimensionBar({ path, kind = "length" }) {
|
|
|
824
895
|
});
|
|
825
896
|
case "size": return /* @__PURE__ */ jsx("div", {
|
|
826
897
|
style: {
|
|
898
|
+
...aliases,
|
|
827
899
|
...styles$12.sizeSample,
|
|
828
900
|
width: cappedValue,
|
|
829
901
|
height: cappedValue
|
|
@@ -832,6 +904,7 @@ function DimensionBar({ path, kind = "length" }) {
|
|
|
832
904
|
});
|
|
833
905
|
default: return /* @__PURE__ */ jsx("div", {
|
|
834
906
|
style: {
|
|
907
|
+
...aliases,
|
|
835
908
|
...styles$12.bar,
|
|
836
909
|
width: cappedValue
|
|
837
910
|
},
|
|
@@ -934,7 +1007,10 @@ function DimensionScale({ filter = "dimension", kind = "length", caption }) {
|
|
|
934
1007
|
const captionText = caption ?? `${rows.length} dimension${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
935
1008
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
936
1009
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
937
|
-
style:
|
|
1010
|
+
style: {
|
|
1011
|
+
...chromeAliases(cssVarPrefix),
|
|
1012
|
+
...styles$11.wrapper
|
|
1013
|
+
},
|
|
938
1014
|
children: /* @__PURE__ */ jsx("div", {
|
|
939
1015
|
style: styles$11.empty,
|
|
940
1016
|
children: "No dimension tokens match this filter."
|
|
@@ -942,7 +1018,10 @@ function DimensionScale({ filter = "dimension", kind = "length", caption }) {
|
|
|
942
1018
|
});
|
|
943
1019
|
return /* @__PURE__ */ jsxs("div", {
|
|
944
1020
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
945
|
-
style:
|
|
1021
|
+
style: {
|
|
1022
|
+
...chromeAliases(cssVarPrefix),
|
|
1023
|
+
...styles$11.wrapper
|
|
1024
|
+
},
|
|
946
1025
|
children: [/* @__PURE__ */ jsx("div", {
|
|
947
1026
|
style: styles$11.caption,
|
|
948
1027
|
children: captionText
|
|
@@ -1047,7 +1126,10 @@ function FontFamilySample({ filter = "fontFamily", sample = "The quick brown fox
|
|
|
1047
1126
|
const captionText = caption ?? `${rows.length} fontFamily token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontFamily" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
1048
1127
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1049
1128
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1050
|
-
style:
|
|
1129
|
+
style: {
|
|
1130
|
+
...chromeAliases(cssVarPrefix),
|
|
1131
|
+
...styles$10.wrapper
|
|
1132
|
+
},
|
|
1051
1133
|
children: /* @__PURE__ */ jsx("div", {
|
|
1052
1134
|
style: styles$10.empty,
|
|
1053
1135
|
children: "No fontFamily tokens match this filter."
|
|
@@ -1055,7 +1137,10 @@ function FontFamilySample({ filter = "fontFamily", sample = "The quick brown fox
|
|
|
1055
1137
|
});
|
|
1056
1138
|
return /* @__PURE__ */ jsxs("div", {
|
|
1057
1139
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1058
|
-
style:
|
|
1140
|
+
style: {
|
|
1141
|
+
...chromeAliases(cssVarPrefix),
|
|
1142
|
+
...styles$10.wrapper
|
|
1143
|
+
},
|
|
1059
1144
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1060
1145
|
style: styles$10.caption,
|
|
1061
1146
|
children: captionText
|
|
@@ -1164,7 +1249,10 @@ function FontWeightScale({ filter = "fontWeight", sample = "Aa", caption }) {
|
|
|
1164
1249
|
const captionText = caption ?? `${rows.length} fontWeight token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontWeight" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
1165
1250
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1166
1251
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1167
|
-
style:
|
|
1252
|
+
style: {
|
|
1253
|
+
...chromeAliases(cssVarPrefix),
|
|
1254
|
+
...styles$9.wrapper
|
|
1255
|
+
},
|
|
1168
1256
|
children: /* @__PURE__ */ jsx("div", {
|
|
1169
1257
|
style: styles$9.empty,
|
|
1170
1258
|
children: "No fontWeight tokens match this filter."
|
|
@@ -1172,7 +1260,10 @@ function FontWeightScale({ filter = "fontWeight", sample = "Aa", caption }) {
|
|
|
1172
1260
|
});
|
|
1173
1261
|
return /* @__PURE__ */ jsxs("div", {
|
|
1174
1262
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1175
|
-
style:
|
|
1263
|
+
style: {
|
|
1264
|
+
...chromeAliases(cssVarPrefix),
|
|
1265
|
+
...styles$9.wrapper
|
|
1266
|
+
},
|
|
1176
1267
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1177
1268
|
style: styles$9.caption,
|
|
1178
1269
|
children: captionText
|
|
@@ -1301,7 +1392,10 @@ function GradientPalette({ filter = "gradient", caption }) {
|
|
|
1301
1392
|
const captionText = caption ?? `${rows.length} gradient${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
1302
1393
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1303
1394
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1304
|
-
style:
|
|
1395
|
+
style: {
|
|
1396
|
+
...chromeAliases(cssVarPrefix),
|
|
1397
|
+
...styles$8.wrapper
|
|
1398
|
+
},
|
|
1305
1399
|
children: /* @__PURE__ */ jsx("div", {
|
|
1306
1400
|
style: styles$8.empty,
|
|
1307
1401
|
children: "No gradient tokens match this filter."
|
|
@@ -1309,7 +1403,10 @@ function GradientPalette({ filter = "gradient", caption }) {
|
|
|
1309
1403
|
});
|
|
1310
1404
|
return /* @__PURE__ */ jsxs("div", {
|
|
1311
1405
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1312
|
-
style:
|
|
1406
|
+
style: {
|
|
1407
|
+
...chromeAliases(cssVarPrefix),
|
|
1408
|
+
...styles$8.wrapper
|
|
1409
|
+
},
|
|
1313
1410
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1314
1411
|
style: styles$8.caption,
|
|
1315
1412
|
children: captionText
|
|
@@ -1476,7 +1573,7 @@ function resolveMotionSpec(token, themeTokens) {
|
|
|
1476
1573
|
return null;
|
|
1477
1574
|
}
|
|
1478
1575
|
function MotionSample({ path, speed = 1, runKey = 0 }) {
|
|
1479
|
-
const { resolved } = useProject();
|
|
1576
|
+
const { resolved, cssVarPrefix } = useProject();
|
|
1480
1577
|
const reducedMotion = usePrefersReducedMotion();
|
|
1481
1578
|
const spec = useMemo(() => resolveMotionSpec(resolved[path], resolved), [resolved, path]);
|
|
1482
1579
|
const durationMs = spec?.durationMs ?? DEFAULT_DURATION_MS;
|
|
@@ -1500,11 +1597,17 @@ function MotionSample({ path, speed = 1, runKey = 0 }) {
|
|
|
1500
1597
|
reducedMotion
|
|
1501
1598
|
]);
|
|
1502
1599
|
if (reducedMotion) return /* @__PURE__ */ jsx("div", {
|
|
1503
|
-
style:
|
|
1600
|
+
style: {
|
|
1601
|
+
...chromeAliases(cssVarPrefix),
|
|
1602
|
+
...styles$7.reducedMotion
|
|
1603
|
+
},
|
|
1504
1604
|
children: "Animation suppressed by `prefers-reduced-motion: reduce`."
|
|
1505
1605
|
});
|
|
1506
1606
|
return /* @__PURE__ */ jsx("div", {
|
|
1507
|
-
style:
|
|
1607
|
+
style: {
|
|
1608
|
+
...chromeAliases(cssVarPrefix),
|
|
1609
|
+
...styles$7.track
|
|
1610
|
+
},
|
|
1508
1611
|
children: /* @__PURE__ */ jsx("div", {
|
|
1509
1612
|
style: {
|
|
1510
1613
|
...styles$7.ball,
|
|
@@ -1651,7 +1754,10 @@ function MotionPreview({ filter, caption }) {
|
|
|
1651
1754
|
const captionText = caption ?? `${rows.length} motion token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
1652
1755
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1653
1756
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1654
|
-
style:
|
|
1757
|
+
style: {
|
|
1758
|
+
...chromeAliases(cssVarPrefix),
|
|
1759
|
+
...styles$6.wrapper
|
|
1760
|
+
},
|
|
1655
1761
|
children: /* @__PURE__ */ jsx("div", {
|
|
1656
1762
|
style: styles$6.empty,
|
|
1657
1763
|
children: "No motion tokens match this filter."
|
|
@@ -1659,7 +1765,10 @@ function MotionPreview({ filter, caption }) {
|
|
|
1659
1765
|
});
|
|
1660
1766
|
return /* @__PURE__ */ jsxs("div", {
|
|
1661
1767
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1662
|
-
style:
|
|
1768
|
+
style: {
|
|
1769
|
+
...chromeAliases(cssVarPrefix),
|
|
1770
|
+
...styles$6.wrapper
|
|
1771
|
+
},
|
|
1663
1772
|
children: [
|
|
1664
1773
|
/* @__PURE__ */ jsx("div", {
|
|
1665
1774
|
style: styles$6.caption,
|
|
@@ -1759,6 +1868,7 @@ function ShadowSample({ path }) {
|
|
|
1759
1868
|
const cssVar = makeCssVar(path, cssVarPrefix);
|
|
1760
1869
|
return /* @__PURE__ */ jsx("div", {
|
|
1761
1870
|
style: {
|
|
1871
|
+
...chromeAliases(cssVarPrefix),
|
|
1762
1872
|
...sampleStyle,
|
|
1763
1873
|
boxShadow: cssVar
|
|
1764
1874
|
},
|
|
@@ -1874,7 +1984,10 @@ function ShadowPreview({ filter = "shadow", caption }) {
|
|
|
1874
1984
|
const captionText = caption ?? `${rows.length} shadow${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
1875
1985
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
1876
1986
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1877
|
-
style:
|
|
1987
|
+
style: {
|
|
1988
|
+
...chromeAliases(cssVarPrefix),
|
|
1989
|
+
...styles$5.wrapper
|
|
1990
|
+
},
|
|
1878
1991
|
children: /* @__PURE__ */ jsx("div", {
|
|
1879
1992
|
style: styles$5.empty,
|
|
1880
1993
|
children: "No shadow tokens match this filter."
|
|
@@ -1882,7 +1995,10 @@ function ShadowPreview({ filter = "shadow", caption }) {
|
|
|
1882
1995
|
});
|
|
1883
1996
|
return /* @__PURE__ */ jsxs("div", {
|
|
1884
1997
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
1885
|
-
style:
|
|
1998
|
+
style: {
|
|
1999
|
+
...chromeAliases(cssVarPrefix),
|
|
2000
|
+
...styles$5.wrapper
|
|
2001
|
+
},
|
|
1886
2002
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1887
2003
|
style: styles$5.caption,
|
|
1888
2004
|
children: captionText
|
|
@@ -2032,7 +2148,10 @@ function StrokeStyleSample({ filter = "strokeStyle", caption }) {
|
|
|
2032
2148
|
const captionText = caption ?? `${rows.length} strokeStyle token${rows.length === 1 ? "" : "s"}${filter && filter !== "strokeStyle" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
2033
2149
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
2034
2150
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
2035
|
-
style:
|
|
2151
|
+
style: {
|
|
2152
|
+
...chromeAliases(cssVarPrefix),
|
|
2153
|
+
...styles$4.wrapper
|
|
2154
|
+
},
|
|
2036
2155
|
children: /* @__PURE__ */ jsx("div", {
|
|
2037
2156
|
style: styles$4.empty,
|
|
2038
2157
|
children: "No strokeStyle tokens match this filter."
|
|
@@ -2040,7 +2159,10 @@ function StrokeStyleSample({ filter = "strokeStyle", caption }) {
|
|
|
2040
2159
|
});
|
|
2041
2160
|
return /* @__PURE__ */ jsxs("div", {
|
|
2042
2161
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
2043
|
-
style:
|
|
2162
|
+
style: {
|
|
2163
|
+
...chromeAliases(cssVarPrefix),
|
|
2164
|
+
...styles$4.wrapper
|
|
2165
|
+
},
|
|
2044
2166
|
children: [/* @__PURE__ */ jsx("div", {
|
|
2045
2167
|
style: styles$4.caption,
|
|
2046
2168
|
children: captionText
|
|
@@ -3167,7 +3289,10 @@ function TokenDetail({ path, heading }) {
|
|
|
3167
3289
|
const colorFormat = useColorFormat();
|
|
3168
3290
|
if (!token) return /* @__PURE__ */ jsx("div", {
|
|
3169
3291
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3170
|
-
style:
|
|
3292
|
+
style: {
|
|
3293
|
+
...chromeAliases(cssVarPrefix),
|
|
3294
|
+
...styles$3.wrapper
|
|
3295
|
+
},
|
|
3171
3296
|
children: /* @__PURE__ */ jsxs("div", {
|
|
3172
3297
|
style: styles$3.missing,
|
|
3173
3298
|
children: [
|
|
@@ -3185,7 +3310,10 @@ function TokenDetail({ path, heading }) {
|
|
|
3185
3310
|
const outOfGamut = formatted?.outOfGamut ?? false;
|
|
3186
3311
|
return /* @__PURE__ */ jsxs("div", {
|
|
3187
3312
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3188
|
-
style:
|
|
3313
|
+
style: {
|
|
3314
|
+
...chromeAliases(cssVarPrefix),
|
|
3315
|
+
...styles$3.wrapper
|
|
3316
|
+
},
|
|
3189
3317
|
children: [
|
|
3190
3318
|
/* @__PURE__ */ jsx(TokenHeader, {
|
|
3191
3319
|
path,
|
|
@@ -3349,6 +3477,7 @@ const styles$2 = {
|
|
|
3349
3477
|
lineHeight: 1
|
|
3350
3478
|
}
|
|
3351
3479
|
};
|
|
3480
|
+
/** @internal Exported for tests; not part of the public API. */
|
|
3352
3481
|
function buildTree(resolved, root) {
|
|
3353
3482
|
const rootPrefix = root && root.length > 0 ? `${root}.` : "";
|
|
3354
3483
|
const rootSegments = root ? root.split(".") : [];
|
|
@@ -3446,7 +3575,10 @@ function TokenNavigator({ root, initiallyExpanded = 1, onSelect }) {
|
|
|
3446
3575
|
}, [onSelect]);
|
|
3447
3576
|
if (tree.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
3448
3577
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3449
|
-
style:
|
|
3578
|
+
style: {
|
|
3579
|
+
...chromeAliases(cssVarPrefix),
|
|
3580
|
+
...styles$2.wrapper
|
|
3581
|
+
},
|
|
3450
3582
|
children: /* @__PURE__ */ jsx("div", {
|
|
3451
3583
|
style: styles$2.empty,
|
|
3452
3584
|
children: root ? `No tokens under "${root}".` : "No tokens in the active theme."
|
|
@@ -3454,7 +3586,10 @@ function TokenNavigator({ root, initiallyExpanded = 1, onSelect }) {
|
|
|
3454
3586
|
});
|
|
3455
3587
|
return /* @__PURE__ */ jsxs("div", {
|
|
3456
3588
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3457
|
-
style:
|
|
3589
|
+
style: {
|
|
3590
|
+
...chromeAliases(cssVarPrefix),
|
|
3591
|
+
...styles$2.wrapper
|
|
3592
|
+
},
|
|
3458
3593
|
children: [
|
|
3459
3594
|
/* @__PURE__ */ jsxs("div", {
|
|
3460
3595
|
style: styles$2.caption,
|
|
@@ -3772,7 +3907,10 @@ function TokenTable({ filter, type, showVar = true, caption }) {
|
|
|
3772
3907
|
const captionText = caption ?? `${rows.length} token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""}${type ? ` · $type=${type}` : ""} · ${activeTheme}`;
|
|
3773
3908
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
3774
3909
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3775
|
-
style:
|
|
3910
|
+
style: {
|
|
3911
|
+
...chromeAliases(cssVarPrefix),
|
|
3912
|
+
...styles$1.wrapper
|
|
3913
|
+
},
|
|
3776
3914
|
children: /* @__PURE__ */ jsx("div", {
|
|
3777
3915
|
style: styles$1.empty,
|
|
3778
3916
|
children: "No tokens match this filter."
|
|
@@ -3780,7 +3918,10 @@ function TokenTable({ filter, type, showVar = true, caption }) {
|
|
|
3780
3918
|
});
|
|
3781
3919
|
return /* @__PURE__ */ jsx("div", {
|
|
3782
3920
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3783
|
-
style:
|
|
3921
|
+
style: {
|
|
3922
|
+
...chromeAliases(cssVarPrefix),
|
|
3923
|
+
...styles$1.wrapper
|
|
3924
|
+
},
|
|
3784
3925
|
children: /* @__PURE__ */ jsxs("table", {
|
|
3785
3926
|
style: styles$1.table,
|
|
3786
3927
|
children: [
|
|
@@ -3952,7 +4093,10 @@ function TypographyScale({ filter = "typography", sample = "The quick brown fox
|
|
|
3952
4093
|
const captionText = caption ?? `${rows.length} typography token${rows.length === 1 ? "" : "s"}${filter && filter !== "typography" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
|
|
3953
4094
|
if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
3954
4095
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3955
|
-
style:
|
|
4096
|
+
style: {
|
|
4097
|
+
...chromeAliases(cssVarPrefix),
|
|
4098
|
+
...styles.wrapper
|
|
4099
|
+
},
|
|
3956
4100
|
children: /* @__PURE__ */ jsx("div", {
|
|
3957
4101
|
style: styles.empty,
|
|
3958
4102
|
children: "No typography tokens match this filter."
|
|
@@ -3960,7 +4104,10 @@ function TypographyScale({ filter = "typography", sample = "The quick brown fox
|
|
|
3960
4104
|
});
|
|
3961
4105
|
return /* @__PURE__ */ jsxs("div", {
|
|
3962
4106
|
...themeAttrs(cssVarPrefix, activeTheme),
|
|
3963
|
-
style:
|
|
4107
|
+
style: {
|
|
4108
|
+
...chromeAliases(cssVarPrefix),
|
|
4109
|
+
...styles.wrapper
|
|
4110
|
+
},
|
|
3964
4111
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3965
4112
|
style: styles.caption,
|
|
3966
4113
|
children: captionText
|