@phcdevworks/spectre-tokens 4.14.0 → 4.16.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/README.md CHANGED
@@ -17,7 +17,7 @@ contracts for specific frameworks and runtimes.
17
17
  | Project team | `project-design` |
18
18
  | Repository role | Spectre L1 design-token contract |
19
19
  | Package/artifact | `@phcdevworks/spectre-tokens` |
20
- | Current version/status | 4.14.0 |
20
+ | Current version/status | 4.16.0 |
21
21
 
22
22
  ## Standard Workflow
23
23
 
@@ -351,7 +351,8 @@ There are three ways to set text size, from most to least opinionated:
351
351
 
352
352
  1. **Text roles** (`--sp-heading-h1-*`, `--sp-display-1-*`, `--sp-body-*`,
353
353
  `--sp-lead-*`): size, line height, weight, and letter-spacing for a
354
- specific job. Use these first.
354
+ specific job. Use these first. Large headings and display text resize
355
+ with the viewport (see [Responsive text roles](#responsive-text-roles)).
355
356
  2. **Size presets** `font.{xs…9xl}` (`--sp-font-lg-size`,
356
357
  `--sp-font-lg-line-height`, `--sp-font-lg-weight`,
357
358
  `--sp-font-lg-letter-spacing`): a size together with the line height and
@@ -387,6 +388,61 @@ a {
387
388
  | `tracking` (letter-spacing) | `tightest` −0.075em through `widest` 0.1em | `--sp-tracking-*` |
388
389
  | `textDecoration` | `thickness.{thin,base,thick}` (1/2/3px), `offset.{sm,md,lg}` (0.125/0.2/0.3em) | `--sp-text-decoration-*` |
389
390
 
391
+ ### Responsive text roles
392
+
393
+ Headings `h1`–`h5` and display `1`–`3` are mobile first. The role's own
394
+ value is the phone size, and `typography.responsive.md.*` holds the size from
395
+ the `md` breakpoint (768px) up. In CSS, `@media (min-width: 768px)` re-points
396
+ `--sp-heading-*-size`/`-line-height` and `--sp-display-*-size`/`-line-height`
397
+ at `--sp-typography-responsive-md-*`, so consumers keep using one variable
398
+ and need no breakpoint of their own.
399
+
400
+ | Role | Below 768px | 768px and up |
401
+ | --- | --- | --- |
402
+ | `display.1` | 36px | 72px |
403
+ | `display.2` | 36px | 60px |
404
+ | `display.3` | 36px | 48px |
405
+ | `display.4`–`6` | 36 / 30 / 24px | same |
406
+ | `heading.h1` | 36px | 60px |
407
+ | `heading.h2` | 30px | 48px |
408
+ | `heading.h3` | 24px | 36px |
409
+ | `heading.h4` | 20px | 30px |
410
+ | `heading.h5` | 20px | 24px |
411
+ | `heading.h6` | 20px | same |
412
+
413
+ Weights and families do not change. Each size keeps the line height of its
414
+ scale step.
415
+
416
+ ### Action colour
417
+
418
+ `action` is the theme's own action colour: the one a site uses for its main
419
+ buttons, stat units, and quote rules. It defaults to `brand`.
420
+
421
+ | Token | CSS variable | Default (light) |
422
+ | --- | --- | --- |
423
+ | `action.bg`, `bgHover`, `bgActive` | `--sp-action-bg`, `-bg-hover`, `-bg-active` | `brand` 700, 800, 900 |
424
+ | `action.text` | `--sp-action-text` | white |
425
+ | `action.focusRing` | `--sp-action-focus-ring` | `brand` 500 at 40% |
426
+ | `action.onPage`, `onSurface` | `--sp-action-on-page`, `-on-surface` | `brand` 700 |
427
+ | `action.rail` | `--sp-action-rail` | `brand` 700 |
428
+
429
+ A theme sets the colour with an attribute on the root element, not by
430
+ declaring `--sp-*`:
431
+
432
+ ```html
433
+ <html data-spectre-action="emerald">
434
+ ```
435
+
436
+ The value is `brand`, `accent`, `info`, or any `colors.palette` family except
437
+ `yellow` and `integration-icy-blue`, which miss a contrast minimum. Hover and
438
+ active shades come from the same family. In dark mode the text and rail
439
+ roles move to step 400, and high-contrast mode uses 800/900/900 fills and
440
+ 900 text. `check:contrast` checks every selectable family against every pair.
441
+
442
+ The attribute works on `<html>` only. The role variables are resolved on the
443
+ root, so putting it on a nested element has no effect. Colour modes still
444
+ apply anywhere, and they pick up the root's family.
445
+
390
446
  ### Accent rails
391
447
 
392
448
  A rail is the coloured edge on a card, badge, quote, and similar components.
@@ -508,6 +564,7 @@ The generated token object includes these namespaces:
508
564
  - `fontSize`
509
565
  - `control`
510
566
  - `elevation`
567
+ - `action`
511
568
 
512
569
  The exported runtime token object is a flattened string-based tree generated
513
570
  from `tokens/`. Source-only wrapper fields such as `value` and `metadata` are
package/dist/index.cjs CHANGED
@@ -1955,6 +1955,11 @@ var coreTokens = {
1955
1955
  }
1956
1956
  },
1957
1957
  "dark": {
1958
+ "action": {
1959
+ "onPage": "{colors.brand.400}",
1960
+ "onSurface": "{colors.brand.400}",
1961
+ "rail": "{colors.brand.400}"
1962
+ },
1958
1963
  "surface": {
1959
1964
  "page": "{colors.neutral.900}",
1960
1965
  "card": "{colors.neutral.800}",
@@ -2823,9 +2828,32 @@ var coreTokens = {
2823
2828
  "visited": "{colors.accent.300}",
2824
2829
  "underline": "{colors.brand.400} / 0.4",
2825
2830
  "underlineHover": "{colors.brand.300}"
2831
+ },
2832
+ "buttons": {
2833
+ "secondary": {
2834
+ "bg": "transparent",
2835
+ "bgHover": "{colors.neutral.800}",
2836
+ "bgActive": "{colors.neutral.700}",
2837
+ "bgDisabled": "transparent",
2838
+ "text": "{colors.info.300}",
2839
+ "textDisabled": "{colors.neutral.500}",
2840
+ "border": "{colors.info.400}",
2841
+ "borderDisabled": "{colors.neutral.700}",
2842
+ "focusRing": "{colors.info.500} / 0.4",
2843
+ "focusVisible": "{colors.info.500} / 0.4"
2844
+ }
2826
2845
  }
2827
2846
  },
2828
2847
  "highContrast": {
2848
+ "action": {
2849
+ "bg": "{colors.brand.800}",
2850
+ "bgHover": "{colors.brand.900}",
2851
+ "bgActive": "{colors.brand.900}",
2852
+ "text": "{colors.white}",
2853
+ "onPage": "{colors.brand.900}",
2854
+ "onSurface": "{colors.brand.900}",
2855
+ "rail": "{colors.brand.900}"
2856
+ },
2829
2857
  "surface": {
2830
2858
  "page": "{colors.white}",
2831
2859
  "card": "{colors.white}",
@@ -4678,6 +4706,16 @@ var coreTokens = {
4678
4706
  "underline": "{colors.brand.600} / 0.4",
4679
4707
  "underlineHover": "{colors.brand.700}"
4680
4708
  },
4709
+ "action": {
4710
+ "bg": "{colors.brand.700}",
4711
+ "bgHover": "{colors.brand.800}",
4712
+ "bgActive": "{colors.brand.900}",
4713
+ "text": "{colors.white}",
4714
+ "focusRing": "{colors.brand.500} / 0.4",
4715
+ "onPage": "{colors.brand.700}",
4716
+ "onSurface": "{colors.brand.700}",
4717
+ "rail": "{colors.brand.700}"
4718
+ },
4681
4719
  "text": {
4682
4720
  "onPage": {
4683
4721
  "default": "{colors.neutral.900}",
@@ -5001,38 +5039,38 @@ var coreTokens = {
5001
5039
  "heading": {
5002
5040
  "h1": {
5003
5041
  "fontFamily": "{typography.families.sans}",
5004
- "fontSize": "{typography.scale.6xl.fontSize}",
5005
- "lineHeight": "{typography.scale.6xl.lineHeight}",
5042
+ "fontSize": "{typography.scale.4xl.fontSize}",
5043
+ "lineHeight": "{typography.scale.4xl.lineHeight}",
5006
5044
  "fontWeight": 800,
5007
- "letterSpacing": "{typography.scale.6xl.letterSpacing}"
5045
+ "letterSpacing": "{typography.scale.4xl.letterSpacing}"
5008
5046
  },
5009
5047
  "h2": {
5010
5048
  "fontFamily": "{typography.families.sans}",
5011
- "fontSize": "{typography.scale.5xl.fontSize}",
5012
- "lineHeight": "{typography.scale.5xl.lineHeight}",
5049
+ "fontSize": "{typography.scale.3xl.fontSize}",
5050
+ "lineHeight": "{typography.scale.3xl.lineHeight}",
5013
5051
  "fontWeight": 700,
5014
- "letterSpacing": "{typography.scale.5xl.letterSpacing}"
5052
+ "letterSpacing": "{typography.scale.3xl.letterSpacing}"
5015
5053
  },
5016
5054
  "h3": {
5017
5055
  "fontFamily": "{typography.families.sans}",
5018
- "fontSize": "{typography.scale.4xl.fontSize}",
5019
- "lineHeight": "{typography.scale.4xl.lineHeight}",
5056
+ "fontSize": "{typography.scale.2xl.fontSize}",
5057
+ "lineHeight": "{typography.scale.2xl.lineHeight}",
5020
5058
  "fontWeight": 700,
5021
- "letterSpacing": "{typography.scale.4xl.letterSpacing}"
5059
+ "letterSpacing": "{typography.scale.2xl.letterSpacing}"
5022
5060
  },
5023
5061
  "h4": {
5024
5062
  "fontFamily": "{typography.families.sans}",
5025
- "fontSize": "{typography.scale.3xl.fontSize}",
5026
- "lineHeight": "{typography.scale.3xl.lineHeight}",
5063
+ "fontSize": "{typography.scale.xl.fontSize}",
5064
+ "lineHeight": "{typography.scale.xl.lineHeight}",
5027
5065
  "fontWeight": 600,
5028
- "letterSpacing": "{typography.scale.3xl.letterSpacing}"
5066
+ "letterSpacing": "{typography.scale.xl.letterSpacing}"
5029
5067
  },
5030
5068
  "h5": {
5031
5069
  "fontFamily": "{typography.families.sans}",
5032
- "fontSize": "{typography.scale.2xl.fontSize}",
5033
- "lineHeight": "{typography.scale.2xl.lineHeight}",
5070
+ "fontSize": "{typography.scale.xl.fontSize}",
5071
+ "lineHeight": "{typography.scale.xl.lineHeight}",
5034
5072
  "fontWeight": 600,
5035
- "letterSpacing": "{typography.scale.2xl.letterSpacing}"
5073
+ "letterSpacing": "{typography.scale.xl.letterSpacing}"
5036
5074
  },
5037
5075
  "h6": {
5038
5076
  "fontFamily": "{typography.families.sans}",
@@ -5052,24 +5090,24 @@ var coreTokens = {
5052
5090
  "display": {
5053
5091
  "1": {
5054
5092
  "fontFamily": "{typography.families.sans}",
5055
- "fontSize": "{typography.scale.7xl.fontSize}",
5056
- "lineHeight": "{typography.scale.7xl.lineHeight}",
5093
+ "fontSize": "{typography.scale.4xl.fontSize}",
5094
+ "lineHeight": "{typography.scale.4xl.lineHeight}",
5057
5095
  "fontWeight": 800,
5058
- "letterSpacing": "{typography.scale.7xl.letterSpacing}"
5096
+ "letterSpacing": "{typography.scale.4xl.letterSpacing}"
5059
5097
  },
5060
5098
  "2": {
5061
5099
  "fontFamily": "{typography.families.sans}",
5062
- "fontSize": "{typography.scale.6xl.fontSize}",
5063
- "lineHeight": "{typography.scale.6xl.lineHeight}",
5100
+ "fontSize": "{typography.scale.4xl.fontSize}",
5101
+ "lineHeight": "{typography.scale.4xl.lineHeight}",
5064
5102
  "fontWeight": 800,
5065
- "letterSpacing": "{typography.scale.6xl.letterSpacing}"
5103
+ "letterSpacing": "{typography.scale.4xl.letterSpacing}"
5066
5104
  },
5067
5105
  "3": {
5068
5106
  "fontFamily": "{typography.families.sans}",
5069
- "fontSize": "{typography.scale.5xl.fontSize}",
5070
- "lineHeight": "{typography.scale.5xl.lineHeight}",
5107
+ "fontSize": "{typography.scale.4xl.fontSize}",
5108
+ "lineHeight": "{typography.scale.4xl.lineHeight}",
5071
5109
  "fontWeight": 700,
5072
- "letterSpacing": "{typography.scale.5xl.letterSpacing}"
5110
+ "letterSpacing": "{typography.scale.4xl.letterSpacing}"
5073
5111
  },
5074
5112
  "4": {
5075
5113
  "fontFamily": "{typography.families.sans}",
@@ -5099,6 +5137,46 @@ var coreTokens = {
5099
5137
  "lineHeight": "{typography.scale.xl.lineHeight}",
5100
5138
  "fontWeight": 400,
5101
5139
  "letterSpacing": "{typography.scale.xl.letterSpacing}"
5140
+ },
5141
+ "responsive": {
5142
+ "md": {
5143
+ "heading": {
5144
+ "h1": {
5145
+ "fontSize": "{typography.scale.6xl.fontSize}",
5146
+ "lineHeight": "{typography.scale.6xl.lineHeight}"
5147
+ },
5148
+ "h2": {
5149
+ "fontSize": "{typography.scale.5xl.fontSize}",
5150
+ "lineHeight": "{typography.scale.5xl.lineHeight}"
5151
+ },
5152
+ "h3": {
5153
+ "fontSize": "{typography.scale.4xl.fontSize}",
5154
+ "lineHeight": "{typography.scale.4xl.lineHeight}"
5155
+ },
5156
+ "h4": {
5157
+ "fontSize": "{typography.scale.3xl.fontSize}",
5158
+ "lineHeight": "{typography.scale.3xl.lineHeight}"
5159
+ },
5160
+ "h5": {
5161
+ "fontSize": "{typography.scale.2xl.fontSize}",
5162
+ "lineHeight": "{typography.scale.2xl.lineHeight}"
5163
+ }
5164
+ },
5165
+ "display": {
5166
+ "1": {
5167
+ "fontSize": "{typography.scale.7xl.fontSize}",
5168
+ "lineHeight": "{typography.scale.7xl.lineHeight}"
5169
+ },
5170
+ "2": {
5171
+ "fontSize": "{typography.scale.6xl.fontSize}",
5172
+ "lineHeight": "{typography.scale.6xl.lineHeight}"
5173
+ },
5174
+ "3": {
5175
+ "fontSize": "{typography.scale.5xl.fontSize}",
5176
+ "lineHeight": "{typography.scale.5xl.lineHeight}"
5177
+ }
5178
+ }
5179
+ }
5102
5180
  }
5103
5181
  }
5104
5182
  };
@@ -5130,6 +5208,42 @@ var layoutResponsive = (layout) => {
5130
5208
  const responsive = isPlainObject(layout) ? layout.responsive : void 0;
5131
5209
  return isPlainObject(responsive) ? responsive : {};
5132
5210
  };
5211
+ var ROLE_FIELD_SUFFIXES = {
5212
+ fontFamily: "family",
5213
+ fontSize: "size",
5214
+ lineHeight: "line-height",
5215
+ fontWeight: "weight",
5216
+ letterSpacing: "letter-spacing"
5217
+ };
5218
+ var typographyResponsive = (typography) => {
5219
+ const responsive = isPlainObject(typography) ? typography.responsive : void 0;
5220
+ if (!isPlainObject(responsive)) return [];
5221
+ return Object.entries(responsive).flatMap(
5222
+ ([breakpoint, groups]) => Object.entries(groups).flatMap(([group, node]) => {
5223
+ const roles = Object.keys(node).some((key) => key in ROLE_FIELD_SUFFIXES) ? [[[group], node]] : Object.entries(node).map(([level, fields]) => [[group, level], fields]);
5224
+ return roles.flatMap(
5225
+ ([roleParts, fields]) => Object.entries(fields).map(([field, value]) => {
5226
+ const suffix = ROLE_FIELD_SUFFIXES[field];
5227
+ if (suffix === void 0) {
5228
+ throw new Error(`typography.responsive.${breakpoint}.${roleParts.join(".")}.${field} is not a typography role field`);
5229
+ }
5230
+ return { breakpoint, roleParts: [...roleParts], suffix, value };
5231
+ })
5232
+ );
5233
+ })
5234
+ );
5235
+ };
5236
+ var ACTION_SYSTEM_FAMILIES = ["brand", "accent", "info"];
5237
+ var ACTION_EXCLUDED_PALETTE_FAMILIES = /* @__PURE__ */ new Set(["yellow", "integration-icy-blue"]);
5238
+ var actionFamilies = (tokens2) => {
5239
+ const colors = tokens2.colors;
5240
+ const palette = isPlainObject(colors.palette) ? colors.palette : {};
5241
+ return Object.fromEntries([
5242
+ ...ACTION_SYSTEM_FAMILIES.map((name) => [name, colors[name]]),
5243
+ ...Object.entries(palette).filter(([name]) => !ACTION_EXCLUDED_PALETTE_FAMILIES.has(name))
5244
+ ]);
5245
+ };
5246
+ var actionSteps = (tokens2) => Object.keys(tokens2.colors.brand);
5133
5247
  var resolveTokenReference = (tokens2, reference) => {
5134
5248
  const path = reference.slice(1, -1).split(".");
5135
5249
  let current = tokens2;
@@ -5216,6 +5330,9 @@ var createCssVariableMap = (tokens2, options = {}) => {
5216
5330
  Object.entries(baseTokens.colors).forEach(([group, scale]) => {
5217
5331
  assignColorGroup([group], scale);
5218
5332
  });
5333
+ actionSteps(tokens2).forEach((step) => {
5334
+ assign(toVariableName(prefix, "action", step), baseTokens.colors.brand[step]);
5335
+ });
5219
5336
  if (baseTokens.space) {
5220
5337
  Object.entries(baseTokens.space).forEach(([key, value]) => {
5221
5338
  assign(toVariableName(prefix, "space", key), value);
@@ -5370,11 +5487,9 @@ var createCssVariableMap = (tokens2, options = {}) => {
5370
5487
  assign(toVariableName(prefix, "font", key, "letter-spacing"), scaleEntry.letterSpacing);
5371
5488
  });
5372
5489
  const assignRole = (rolePrefixParts, entry) => {
5373
- assign(toVariableName(prefix, ...rolePrefixParts, "family"), entry.fontFamily);
5374
- assign(toVariableName(prefix, ...rolePrefixParts, "size"), entry.fontSize);
5375
- assign(toVariableName(prefix, ...rolePrefixParts, "line-height"), entry.lineHeight);
5376
- assign(toVariableName(prefix, ...rolePrefixParts, "weight"), entry.fontWeight);
5377
- assign(toVariableName(prefix, ...rolePrefixParts, "letter-spacing"), entry.letterSpacing);
5490
+ Object.entries(ROLE_FIELD_SUFFIXES).forEach(([field, suffix]) => {
5491
+ assign(toVariableName(prefix, ...rolePrefixParts, suffix), entry[field]);
5492
+ });
5378
5493
  };
5379
5494
  const heading = baseTokens.typography?.heading;
5380
5495
  if (heading) {
@@ -5396,6 +5511,9 @@ var createCssVariableMap = (tokens2, options = {}) => {
5396
5511
  if (lead) {
5397
5512
  assignRole(["lead"], lead);
5398
5513
  }
5514
+ typographyResponsive(baseTokens.typography).forEach(({ breakpoint, roleParts, suffix, value }) => {
5515
+ assign(toVariableName(prefix, "typography", "responsive", breakpoint, ...roleParts, suffix), value);
5516
+ });
5399
5517
  Object.entries(baseTokens.shadows).forEach(([key, value]) => {
5400
5518
  if (typeof value === "string") {
5401
5519
  assign(toVariableName(prefix, "shadow", key), value);
@@ -5551,14 +5669,31 @@ var generateCssVariables = (tokens2, options = {}) => {
5551
5669
  addDark(varName, pickSemantic(tokens2, getPath(darkLink, [key]), value));
5552
5670
  addHighContrast(varName, pickSemantic(tokens2, getPath(highContrastLink, [key]), value));
5553
5671
  });
5554
- const highContrastButtons = getPath(highContrastMode, ["buttons"]);
5555
- if (isPlainObject(highContrastButtons)) {
5556
- Object.entries(highContrastButtons).forEach(([variant, states]) => {
5672
+ const actionValue = (value) => {
5673
+ const match = typeof value === "string" ? value.match(/^\{colors\.brand\.([^}]+)\}(?:\s*\/\s*([0-9.]+))?$/) : null;
5674
+ if (!match) return pickSemantic(tokens2, value);
5675
+ const ramp = `var(${toVariableName(prefix, "action", match[1])})`;
5676
+ return match[2] === void 0 ? ramp : `color-mix(in srgb, ${ramp} ${Math.round(Number(match[2]) * 1e3) / 10}%, transparent)`;
5677
+ };
5678
+ const darkAction = getPath(darkMode, ["action"]);
5679
+ const highContrastAction = getPath(highContrastMode, ["action"]);
5680
+ Object.entries(tokens2.action ?? {}).forEach(([key, value]) => {
5681
+ const varName = toVariableName(prefix, "action", kebabPathSegment(key));
5682
+ addBase(varName, actionValue(value));
5683
+ addDark(varName, actionValue(getPath(darkAction, [key]) ?? value));
5684
+ addHighContrast(varName, actionValue(getPath(highContrastAction, [key]) ?? value));
5685
+ });
5686
+ const addButtonOverrides = (mode, add) => {
5687
+ const buttons = getPath(mode, ["buttons"]);
5688
+ if (!isPlainObject(buttons)) return;
5689
+ Object.entries(buttons).forEach(([variant, states]) => {
5557
5690
  Object.entries(states).forEach(([state, value]) => {
5558
- addHighContrast(toVariableName(prefix, "button", variant, state), pickSemantic(tokens2, value));
5691
+ add(toVariableName(prefix, "button", variant, state), pickSemantic(tokens2, value));
5559
5692
  });
5560
5693
  });
5561
- }
5694
+ };
5695
+ addButtonOverrides(darkMode, addDark);
5696
+ addButtonOverrides(highContrastMode, addHighContrast);
5562
5697
  const mapLines = Object.entries(declarations).filter(([name]) => !modeScopedNames.has(name)).map(([name, value]) => ` ${name}: ${value};`);
5563
5698
  const rootBlock = `${selector} {
5564
5699
  ${[...baseLines, ...mapLines].join("\n")}
@@ -5599,6 +5734,16 @@ ${indent}}`;
5599
5734
  const systemDarkBlock = `@media (prefers-color-scheme: dark) {
5600
5735
  ${modeBlock(themeSelectors("system"), modeLines(darkEntries), " ")}
5601
5736
  }`;
5737
+ const steps = actionSteps(tokens2);
5738
+ const actionBlocks = Object.entries(actionFamilies(tokens2)).map(([name, scale]) => {
5739
+ const lines = steps.map((step) => {
5740
+ if (scale[step] === void 0) throw new Error(`Action family "${name}" has no ${step} step`);
5741
+ return ` ${toVariableName(prefix, "action", step)}: ${resolveValue(tokens2, scale[step])};`;
5742
+ });
5743
+ return `${selector}[data-spectre-action="${name}"] {
5744
+ ${lines.join("\n")}
5745
+ }`;
5746
+ });
5602
5747
  const control = tokens2.control;
5603
5748
  const compact = isPlainObject(control) && isPlainObject(control.compact) ? control.compact : {};
5604
5749
  const densityLines = Object.entries(compact).flatMap(
@@ -5611,27 +5756,50 @@ ${modeBlock(themeSelectors("system"), modeLines(darkEntries), " ")}
5611
5756
  ${densityLines.join("\n")}
5612
5757
  }`] : [];
5613
5758
  const breakpoints = tokens2.breakpoints;
5614
- const responsiveBlocks = Object.entries(layoutResponsive(tokens2.layout)).map(([breakpoint, scales]) => {
5615
- const minWidth = breakpoints[breakpoint];
5616
- if (minWidth === void 0) {
5617
- throw new Error(`layout.responsive.${breakpoint} does not name a breakpoints entry`);
5759
+ const responsiveLines = /* @__PURE__ */ new Map();
5760
+ const addResponsive = (namespace, breakpoint, name, source) => {
5761
+ if (breakpoints[breakpoint] === void 0) {
5762
+ throw new Error(`${namespace}.responsive.${breakpoint} does not name a breakpoints entry`);
5618
5763
  }
5619
- const lines = LAYOUT_SCALES.flatMap(
5620
- ({ path, varParts }) => Object.keys(layoutScale(scales, path)).map((key) => {
5621
- const name = toVariableName(prefix, "layout", ...varParts, kebabCase(key));
5622
- const source = toVariableName(prefix, "layout", "responsive", breakpoint, ...varParts, kebabCase(key));
5623
- return ` ${name}: var(${source});`;
5624
- })
5764
+ responsiveLines.set(breakpoint, [...responsiveLines.get(breakpoint) ?? [], ` ${name}: var(${source});`]);
5765
+ };
5766
+ Object.entries(layoutResponsive(tokens2.layout)).forEach(([breakpoint, scales]) => {
5767
+ LAYOUT_SCALES.forEach(({ path, varParts }) => {
5768
+ Object.keys(layoutScale(scales, path)).forEach((key) => {
5769
+ addResponsive(
5770
+ "layout",
5771
+ breakpoint,
5772
+ toVariableName(prefix, "layout", ...varParts, kebabCase(key)),
5773
+ toVariableName(prefix, "layout", "responsive", breakpoint, ...varParts, kebabCase(key))
5774
+ );
5775
+ });
5776
+ });
5777
+ });
5778
+ typographyResponsive(tokens2.typography).forEach(({ breakpoint, roleParts, suffix }) => {
5779
+ addResponsive(
5780
+ "typography",
5781
+ breakpoint,
5782
+ toVariableName(prefix, ...roleParts, suffix),
5783
+ toVariableName(prefix, "typography", "responsive", breakpoint, ...roleParts, suffix)
5625
5784
  );
5626
- return `@media (min-width: ${resolveValue(tokens2, minWidth)}) {
5785
+ });
5786
+ const responsiveBlocks = Object.keys(breakpoints).filter((breakpoint) => responsiveLines.has(breakpoint)).map(
5787
+ (breakpoint) => `@media (min-width: ${resolveValue(tokens2, breakpoints[breakpoint])}) {
5627
5788
  ${selector} {
5628
- ${lines.join("\n")}
5789
+ ${responsiveLines.get(breakpoint).join("\n")}
5629
5790
  }
5630
- }`;
5631
- });
5632
- return [rootBlock, darkBlock, highContrastBlock, lightBlock, systemDarkBlock, ...densityBlocks, ...responsiveBlocks].join(
5633
- "\n"
5634
- ) + "\n";
5791
+ }`
5792
+ );
5793
+ return [
5794
+ rootBlock,
5795
+ darkBlock,
5796
+ highContrastBlock,
5797
+ lightBlock,
5798
+ systemDarkBlock,
5799
+ ...actionBlocks,
5800
+ ...densityBlocks,
5801
+ ...responsiveBlocks
5802
+ ].join("\n") + "\n";
5635
5803
  };
5636
5804
 
5637
5805
  // src/index.ts