@unpunnyfuns/swatchbook-blocks 0.1.5 → 0.2.1

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Published as `@unpunnyfuns/swatchbook-blocks`. Storybook MDX doc blocks for DTCG design tokens. React components for rendering token documentation inside `.mdx` pages or regular stories. Self-mount the addon's CSS and react to axis changes from the toolbar; work inside the docs container even though story decorators don't.
4
4
 
5
- > **Documentation:** [unpunnyfuns.github.io/swatchbook](https://unpunnyfuns.github.io/swatchbook/). Token parsing powered by [Terrazzo](https://terrazzo.app/) by [Drew Powers](https://github.com/drwpow) via `@unpunnyfuns/swatchbook-core`.
5
+ > **Documentation:** [unpunnyfuns.github.io/swatchbook](https://unpunnyfuns.github.io/swatchbook/). Token parsing powered by [Terrazzo](https://terrazzo.app/) by the [Terrazzo team](https://github.com/terrazzoapp) via `@unpunnyfuns/swatchbook-core`.
6
6
 
7
7
  ## Install
8
8
 
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";
@@ -420,6 +475,7 @@ function BorderSample({ path }) {
420
475
  const cssVar = makeCssVar(path, cssVarPrefix);
421
476
  return /* @__PURE__ */ jsx("div", {
422
477
  style: {
478
+ ...chromeAliases(cssVarPrefix),
423
479
  ...sampleStyle$1,
424
480
  border: cssVar
425
481
  },
@@ -541,16 +597,22 @@ function BorderPreview({ filter = "border", caption }) {
541
597
  ]);
542
598
  const captionText = caption ?? `${rows.length} border${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
543
599
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
544
- "data-theme": activeTheme,
545
- style: styles$14.wrapper,
600
+ ...themeAttrs(cssVarPrefix, activeTheme),
601
+ style: {
602
+ ...chromeAliases(cssVarPrefix),
603
+ ...styles$14.wrapper
604
+ },
546
605
  children: /* @__PURE__ */ jsx("div", {
547
606
  style: styles$14.empty,
548
607
  children: "No border tokens match this filter."
549
608
  })
550
609
  });
551
610
  return /* @__PURE__ */ jsxs("div", {
552
- "data-theme": activeTheme,
553
- style: styles$14.wrapper,
611
+ ...themeAttrs(cssVarPrefix, activeTheme),
612
+ style: {
613
+ ...chromeAliases(cssVarPrefix),
614
+ ...styles$14.wrapper
615
+ },
554
616
  children: [/* @__PURE__ */ jsx("div", {
555
617
  style: styles$14.caption,
556
618
  children: captionText
@@ -701,15 +763,18 @@ function ColorPalette({ filter = "color", groupBy, caption }) {
701
763
  const totalCount = groups.reduce((acc, [, swatches]) => acc + swatches.length, 0);
702
764
  const captionText = caption ?? `${totalCount} color${totalCount === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
703
765
  if (totalCount === 0) return /* @__PURE__ */ jsx("div", {
704
- "data-theme": activeTheme,
705
- style: styles$13.wrapper,
766
+ ...themeAttrs(cssVarPrefix, activeTheme),
767
+ style: {
768
+ ...chromeAliases(cssVarPrefix),
769
+ ...styles$13.wrapper
770
+ },
706
771
  children: /* @__PURE__ */ jsx("div", {
707
772
  style: styles$13.empty,
708
773
  children: "No color tokens match this filter."
709
774
  })
710
775
  });
711
776
  return /* @__PURE__ */ jsxs("div", {
712
- "data-theme": activeTheme,
777
+ ...themeAttrs(cssVarPrefix, activeTheme),
713
778
  style: styles$13.wrapper,
714
779
  children: [/* @__PURE__ */ jsx("div", {
715
780
  style: styles$13.caption,
@@ -795,9 +860,11 @@ function DimensionBar({ path, kind = "length" }) {
795
860
  const token = resolved[path];
796
861
  const pxValue = toPixels$1(token?.$value);
797
862
  const cappedValue = Number.isFinite(pxValue) && pxValue > MAX_RENDER_PX$1 ? `${MAX_RENDER_PX$1}px` : cssVar;
863
+ const aliases = chromeAliases(cssVarPrefix);
798
864
  switch (kind) {
799
865
  case "radius": return /* @__PURE__ */ jsx("div", {
800
866
  style: {
867
+ ...aliases,
801
868
  ...styles$12.radiusSample,
802
869
  borderRadius: cssVar
803
870
  },
@@ -805,6 +872,7 @@ function DimensionBar({ path, kind = "length" }) {
805
872
  });
806
873
  case "size": return /* @__PURE__ */ jsx("div", {
807
874
  style: {
875
+ ...aliases,
808
876
  ...styles$12.sizeSample,
809
877
  width: cappedValue,
810
878
  height: cappedValue
@@ -813,6 +881,7 @@ function DimensionBar({ path, kind = "length" }) {
813
881
  });
814
882
  default: return /* @__PURE__ */ jsx("div", {
815
883
  style: {
884
+ ...aliases,
816
885
  ...styles$12.bar,
817
886
  width: cappedValue
818
887
  },
@@ -914,16 +983,22 @@ function DimensionScale({ filter = "dimension", kind = "length", caption }) {
914
983
  ]);
915
984
  const captionText = caption ?? `${rows.length} dimension${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
916
985
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
917
- "data-theme": activeTheme,
918
- style: styles$11.wrapper,
986
+ ...themeAttrs(cssVarPrefix, activeTheme),
987
+ style: {
988
+ ...chromeAliases(cssVarPrefix),
989
+ ...styles$11.wrapper
990
+ },
919
991
  children: /* @__PURE__ */ jsx("div", {
920
992
  style: styles$11.empty,
921
993
  children: "No dimension tokens match this filter."
922
994
  })
923
995
  });
924
996
  return /* @__PURE__ */ jsxs("div", {
925
- "data-theme": activeTheme,
926
- style: styles$11.wrapper,
997
+ ...themeAttrs(cssVarPrefix, activeTheme),
998
+ style: {
999
+ ...chromeAliases(cssVarPrefix),
1000
+ ...styles$11.wrapper
1001
+ },
927
1002
  children: [/* @__PURE__ */ jsx("div", {
928
1003
  style: styles$11.caption,
929
1004
  children: captionText
@@ -1027,16 +1102,22 @@ function FontFamilySample({ filter = "fontFamily", sample = "The quick brown fox
1027
1102
  ]);
1028
1103
  const captionText = caption ?? `${rows.length} fontFamily token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontFamily" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
1029
1104
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
1030
- "data-theme": activeTheme,
1031
- style: styles$10.wrapper,
1105
+ ...themeAttrs(cssVarPrefix, activeTheme),
1106
+ style: {
1107
+ ...chromeAliases(cssVarPrefix),
1108
+ ...styles$10.wrapper
1109
+ },
1032
1110
  children: /* @__PURE__ */ jsx("div", {
1033
1111
  style: styles$10.empty,
1034
1112
  children: "No fontFamily tokens match this filter."
1035
1113
  })
1036
1114
  });
1037
1115
  return /* @__PURE__ */ jsxs("div", {
1038
- "data-theme": activeTheme,
1039
- style: styles$10.wrapper,
1116
+ ...themeAttrs(cssVarPrefix, activeTheme),
1117
+ style: {
1118
+ ...chromeAliases(cssVarPrefix),
1119
+ ...styles$10.wrapper
1120
+ },
1040
1121
  children: [/* @__PURE__ */ jsx("div", {
1041
1122
  style: styles$10.caption,
1042
1123
  children: captionText
@@ -1144,16 +1225,22 @@ function FontWeightScale({ filter = "fontWeight", sample = "Aa", caption }) {
1144
1225
  ]);
1145
1226
  const captionText = caption ?? `${rows.length} fontWeight token${rows.length === 1 ? "" : "s"}${filter && filter !== "fontWeight" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
1146
1227
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
1147
- "data-theme": activeTheme,
1148
- style: styles$9.wrapper,
1228
+ ...themeAttrs(cssVarPrefix, activeTheme),
1229
+ style: {
1230
+ ...chromeAliases(cssVarPrefix),
1231
+ ...styles$9.wrapper
1232
+ },
1149
1233
  children: /* @__PURE__ */ jsx("div", {
1150
1234
  style: styles$9.empty,
1151
1235
  children: "No fontWeight tokens match this filter."
1152
1236
  })
1153
1237
  });
1154
1238
  return /* @__PURE__ */ jsxs("div", {
1155
- "data-theme": activeTheme,
1156
- style: styles$9.wrapper,
1239
+ ...themeAttrs(cssVarPrefix, activeTheme),
1240
+ style: {
1241
+ ...chromeAliases(cssVarPrefix),
1242
+ ...styles$9.wrapper
1243
+ },
1157
1244
  children: [/* @__PURE__ */ jsx("div", {
1158
1245
  style: styles$9.caption,
1159
1246
  children: captionText
@@ -1281,16 +1368,22 @@ function GradientPalette({ filter = "gradient", caption }) {
1281
1368
  ]);
1282
1369
  const captionText = caption ?? `${rows.length} gradient${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
1283
1370
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
1284
- "data-theme": activeTheme,
1285
- style: styles$8.wrapper,
1371
+ ...themeAttrs(cssVarPrefix, activeTheme),
1372
+ style: {
1373
+ ...chromeAliases(cssVarPrefix),
1374
+ ...styles$8.wrapper
1375
+ },
1286
1376
  children: /* @__PURE__ */ jsx("div", {
1287
1377
  style: styles$8.empty,
1288
1378
  children: "No gradient tokens match this filter."
1289
1379
  })
1290
1380
  });
1291
1381
  return /* @__PURE__ */ jsxs("div", {
1292
- "data-theme": activeTheme,
1293
- style: styles$8.wrapper,
1382
+ ...themeAttrs(cssVarPrefix, activeTheme),
1383
+ style: {
1384
+ ...chromeAliases(cssVarPrefix),
1385
+ ...styles$8.wrapper
1386
+ },
1294
1387
  children: [/* @__PURE__ */ jsx("div", {
1295
1388
  style: styles$8.caption,
1296
1389
  children: captionText
@@ -1457,7 +1550,7 @@ function resolveMotionSpec(token, themeTokens) {
1457
1550
  return null;
1458
1551
  }
1459
1552
  function MotionSample({ path, speed = 1, runKey = 0 }) {
1460
- const { resolved } = useProject();
1553
+ const { resolved, cssVarPrefix } = useProject();
1461
1554
  const reducedMotion = usePrefersReducedMotion();
1462
1555
  const spec = useMemo(() => resolveMotionSpec(resolved[path], resolved), [resolved, path]);
1463
1556
  const durationMs = spec?.durationMs ?? DEFAULT_DURATION_MS;
@@ -1481,11 +1574,17 @@ function MotionSample({ path, speed = 1, runKey = 0 }) {
1481
1574
  reducedMotion
1482
1575
  ]);
1483
1576
  if (reducedMotion) return /* @__PURE__ */ jsx("div", {
1484
- style: styles$7.reducedMotion,
1577
+ style: {
1578
+ ...chromeAliases(cssVarPrefix),
1579
+ ...styles$7.reducedMotion
1580
+ },
1485
1581
  children: "Animation suppressed by `prefers-reduced-motion: reduce`."
1486
1582
  });
1487
1583
  return /* @__PURE__ */ jsx("div", {
1488
- style: styles$7.track,
1584
+ style: {
1585
+ ...chromeAliases(cssVarPrefix),
1586
+ ...styles$7.track
1587
+ },
1489
1588
  children: /* @__PURE__ */ jsx("div", {
1490
1589
  style: {
1491
1590
  ...styles$7.ball,
@@ -1631,16 +1730,22 @@ function MotionPreview({ filter, caption }) {
1631
1730
  ]);
1632
1731
  const captionText = caption ?? `${rows.length} motion token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
1633
1732
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
1634
- "data-theme": activeTheme,
1635
- style: styles$6.wrapper,
1733
+ ...themeAttrs(cssVarPrefix, activeTheme),
1734
+ style: {
1735
+ ...chromeAliases(cssVarPrefix),
1736
+ ...styles$6.wrapper
1737
+ },
1636
1738
  children: /* @__PURE__ */ jsx("div", {
1637
1739
  style: styles$6.empty,
1638
1740
  children: "No motion tokens match this filter."
1639
1741
  })
1640
1742
  });
1641
1743
  return /* @__PURE__ */ jsxs("div", {
1642
- "data-theme": activeTheme,
1643
- style: styles$6.wrapper,
1744
+ ...themeAttrs(cssVarPrefix, activeTheme),
1745
+ style: {
1746
+ ...chromeAliases(cssVarPrefix),
1747
+ ...styles$6.wrapper
1748
+ },
1644
1749
  children: [
1645
1750
  /* @__PURE__ */ jsx("div", {
1646
1751
  style: styles$6.caption,
@@ -1740,6 +1845,7 @@ function ShadowSample({ path }) {
1740
1845
  const cssVar = makeCssVar(path, cssVarPrefix);
1741
1846
  return /* @__PURE__ */ jsx("div", {
1742
1847
  style: {
1848
+ ...chromeAliases(cssVarPrefix),
1743
1849
  ...sampleStyle,
1744
1850
  boxShadow: cssVar
1745
1851
  },
@@ -1854,16 +1960,22 @@ function ShadowPreview({ filter = "shadow", caption }) {
1854
1960
  ]);
1855
1961
  const captionText = caption ?? `${rows.length} shadow${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
1856
1962
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
1857
- "data-theme": activeTheme,
1858
- style: styles$5.wrapper,
1963
+ ...themeAttrs(cssVarPrefix, activeTheme),
1964
+ style: {
1965
+ ...chromeAliases(cssVarPrefix),
1966
+ ...styles$5.wrapper
1967
+ },
1859
1968
  children: /* @__PURE__ */ jsx("div", {
1860
1969
  style: styles$5.empty,
1861
1970
  children: "No shadow tokens match this filter."
1862
1971
  })
1863
1972
  });
1864
1973
  return /* @__PURE__ */ jsxs("div", {
1865
- "data-theme": activeTheme,
1866
- style: styles$5.wrapper,
1974
+ ...themeAttrs(cssVarPrefix, activeTheme),
1975
+ style: {
1976
+ ...chromeAliases(cssVarPrefix),
1977
+ ...styles$5.wrapper
1978
+ },
1867
1979
  children: [/* @__PURE__ */ jsx("div", {
1868
1980
  style: styles$5.caption,
1869
1981
  children: captionText
@@ -2012,16 +2124,22 @@ function StrokeStyleSample({ filter = "strokeStyle", caption }) {
2012
2124
  ]);
2013
2125
  const captionText = caption ?? `${rows.length} strokeStyle token${rows.length === 1 ? "" : "s"}${filter && filter !== "strokeStyle" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
2014
2126
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
2015
- "data-theme": activeTheme,
2016
- style: styles$4.wrapper,
2127
+ ...themeAttrs(cssVarPrefix, activeTheme),
2128
+ style: {
2129
+ ...chromeAliases(cssVarPrefix),
2130
+ ...styles$4.wrapper
2131
+ },
2017
2132
  children: /* @__PURE__ */ jsx("div", {
2018
2133
  style: styles$4.empty,
2019
2134
  children: "No strokeStyle tokens match this filter."
2020
2135
  })
2021
2136
  });
2022
2137
  return /* @__PURE__ */ jsxs("div", {
2023
- "data-theme": activeTheme,
2024
- style: styles$4.wrapper,
2138
+ ...themeAttrs(cssVarPrefix, activeTheme),
2139
+ style: {
2140
+ ...chromeAliases(cssVarPrefix),
2141
+ ...styles$4.wrapper
2142
+ },
2025
2143
  children: [/* @__PURE__ */ jsx("div", {
2026
2144
  style: styles$4.caption,
2027
2145
  children: captionText
@@ -2466,7 +2584,7 @@ function treeHasTruncation(nodes) {
2466
2584
  //#endregion
2467
2585
  //#region src/token-detail/AxisVariance.tsx
2468
2586
  function AxisVariance({ path }) {
2469
- const { token, cssVar, axes, themes, themesResolved, activeAxes } = useTokenDetailData(path);
2587
+ const { token, cssVar, axes, themes, themesResolved, activeAxes, cssVarPrefix } = useTokenDetailData(path);
2470
2588
  const colorFormat = useColorFormat();
2471
2589
  const isColor = token?.$type === "color";
2472
2590
  const formatFn = (t) => valueFor(t, isColor, colorFormat);
@@ -2559,7 +2677,7 @@ function AxisVariance({ path }) {
2559
2677
  ...styles$3.swatch,
2560
2678
  background: cssVar
2561
2679
  },
2562
- "data-theme": row.themeName,
2680
+ [dataAttr(cssVarPrefix, "theme")]: row.themeName,
2563
2681
  "aria-hidden": true
2564
2682
  }), row.value]
2565
2683
  })]
@@ -2618,7 +2736,7 @@ function AxisVariance({ path }) {
2618
2736
  ...styles$3.swatch,
2619
2737
  background: cssVar
2620
2738
  },
2621
- "data-theme": name,
2739
+ [dataAttr(cssVarPrefix, "theme")]: name,
2622
2740
  "aria-hidden": true
2623
2741
  }), value]
2624
2742
  }, col);
@@ -3144,11 +3262,14 @@ function TokenUsageSnippet({ path }) {
3144
3262
  //#endregion
3145
3263
  //#region src/TokenDetail.tsx
3146
3264
  function TokenDetail({ path, heading }) {
3147
- const { token, cssVar, activeTheme } = useTokenDetailData(path);
3265
+ const { token, cssVar, activeTheme, cssVarPrefix } = useTokenDetailData(path);
3148
3266
  const colorFormat = useColorFormat();
3149
3267
  if (!token) return /* @__PURE__ */ jsx("div", {
3150
- "data-theme": activeTheme,
3151
- style: styles$3.wrapper,
3268
+ ...themeAttrs(cssVarPrefix, activeTheme),
3269
+ style: {
3270
+ ...chromeAliases(cssVarPrefix),
3271
+ ...styles$3.wrapper
3272
+ },
3152
3273
  children: /* @__PURE__ */ jsxs("div", {
3153
3274
  style: styles$3.missing,
3154
3275
  children: [
@@ -3165,8 +3286,11 @@ function TokenDetail({ path, heading }) {
3165
3286
  const value = formatted ? formatted.value : formatValue(token.$value);
3166
3287
  const outOfGamut = formatted?.outOfGamut ?? false;
3167
3288
  return /* @__PURE__ */ jsxs("div", {
3168
- "data-theme": activeTheme,
3169
- style: styles$3.wrapper,
3289
+ ...themeAttrs(cssVarPrefix, activeTheme),
3290
+ style: {
3291
+ ...chromeAliases(cssVarPrefix),
3292
+ ...styles$3.wrapper
3293
+ },
3170
3294
  children: [
3171
3295
  /* @__PURE__ */ jsx(TokenHeader, {
3172
3296
  path,
@@ -3401,7 +3525,7 @@ function countLeaves(node) {
3401
3525
  return n;
3402
3526
  }
3403
3527
  function TokenNavigator({ root, initiallyExpanded = 1, onSelect }) {
3404
- const { resolved, activeTheme } = useProject();
3528
+ const { resolved, activeTheme, cssVarPrefix } = useProject();
3405
3529
  const tree = useMemo(() => buildTree(resolved, root), [resolved, root]);
3406
3530
  const initialExpanded = useMemo(() => {
3407
3531
  const out = /* @__PURE__ */ new Set();
@@ -3426,16 +3550,22 @@ function TokenNavigator({ root, initiallyExpanded = 1, onSelect }) {
3426
3550
  else setSelectedPath(path);
3427
3551
  }, [onSelect]);
3428
3552
  if (tree.length === 0) return /* @__PURE__ */ jsx("div", {
3429
- "data-theme": activeTheme,
3430
- style: styles$2.wrapper,
3553
+ ...themeAttrs(cssVarPrefix, activeTheme),
3554
+ style: {
3555
+ ...chromeAliases(cssVarPrefix),
3556
+ ...styles$2.wrapper
3557
+ },
3431
3558
  children: /* @__PURE__ */ jsx("div", {
3432
3559
  style: styles$2.empty,
3433
3560
  children: root ? `No tokens under "${root}".` : "No tokens in the active theme."
3434
3561
  })
3435
3562
  });
3436
3563
  return /* @__PURE__ */ jsxs("div", {
3437
- "data-theme": activeTheme,
3438
- style: styles$2.wrapper,
3564
+ ...themeAttrs(cssVarPrefix, activeTheme),
3565
+ style: {
3566
+ ...chromeAliases(cssVarPrefix),
3567
+ ...styles$2.wrapper
3568
+ },
3439
3569
  children: [
3440
3570
  /* @__PURE__ */ jsxs("div", {
3441
3571
  style: styles$2.caption,
@@ -3752,16 +3882,22 @@ function TokenTable({ filter, type, showVar = true, caption }) {
3752
3882
  ]);
3753
3883
  const captionText = caption ?? `${rows.length} token${rows.length === 1 ? "" : "s"}${filter ? ` matching \`${filter}\`` : ""}${type ? ` · $type=${type}` : ""} · ${activeTheme}`;
3754
3884
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
3755
- "data-theme": activeTheme,
3756
- style: styles$1.wrapper,
3885
+ ...themeAttrs(cssVarPrefix, activeTheme),
3886
+ style: {
3887
+ ...chromeAliases(cssVarPrefix),
3888
+ ...styles$1.wrapper
3889
+ },
3757
3890
  children: /* @__PURE__ */ jsx("div", {
3758
3891
  style: styles$1.empty,
3759
3892
  children: "No tokens match this filter."
3760
3893
  })
3761
3894
  });
3762
3895
  return /* @__PURE__ */ jsx("div", {
3763
- "data-theme": activeTheme,
3764
- style: styles$1.wrapper,
3896
+ ...themeAttrs(cssVarPrefix, activeTheme),
3897
+ style: {
3898
+ ...chromeAliases(cssVarPrefix),
3899
+ ...styles$1.wrapper
3900
+ },
3765
3901
  children: /* @__PURE__ */ jsxs("table", {
3766
3902
  style: styles$1.table,
3767
3903
  children: [
@@ -3915,7 +4051,7 @@ function buildRow(path, composite) {
3915
4051
  };
3916
4052
  }
3917
4053
  function TypographyScale({ filter = "typography", sample = "The quick brown fox jumps over the lazy dog.", caption }) {
3918
- const { resolved, activeTheme } = useProject();
4054
+ const { resolved, activeTheme, cssVarPrefix } = useProject();
3919
4055
  const rows = useMemo(() => {
3920
4056
  return Object.entries(resolved).filter(([path, token]) => {
3921
4057
  if (token.$type !== "typography") return false;
@@ -3932,16 +4068,22 @@ function TypographyScale({ filter = "typography", sample = "The quick brown fox
3932
4068
  }, [resolved, filter]);
3933
4069
  const captionText = caption ?? `${rows.length} typography token${rows.length === 1 ? "" : "s"}${filter && filter !== "typography" ? ` matching \`${filter}\`` : ""} · ${activeTheme}`;
3934
4070
  if (rows.length === 0) return /* @__PURE__ */ jsx("div", {
3935
- "data-theme": activeTheme,
3936
- style: styles.wrapper,
4071
+ ...themeAttrs(cssVarPrefix, activeTheme),
4072
+ style: {
4073
+ ...chromeAliases(cssVarPrefix),
4074
+ ...styles.wrapper
4075
+ },
3937
4076
  children: /* @__PURE__ */ jsx("div", {
3938
4077
  style: styles.empty,
3939
4078
  children: "No typography tokens match this filter."
3940
4079
  })
3941
4080
  });
3942
4081
  return /* @__PURE__ */ jsxs("div", {
3943
- "data-theme": activeTheme,
3944
- style: styles.wrapper,
4082
+ ...themeAttrs(cssVarPrefix, activeTheme),
4083
+ style: {
4084
+ ...chromeAliases(cssVarPrefix),
4085
+ ...styles.wrapper
4086
+ },
3945
4087
  children: [/* @__PURE__ */ jsx("div", {
3946
4088
  style: styles.caption,
3947
4089
  children: captionText