@phcdevworks/spectre-tokens 4.14.0 → 4.15.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 +59 -2
- package/dist/index.cjs +197 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +510 -16
- package/dist/index.d.cts +69 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +197 -46
- package/dist/index.js.map +1 -1
- package/dist/tokens.dtcg.json +203 -24
- package/package.json +8 -8
- package/tokens/modes.json +71 -0
- package/tokens/semantic-roles.json +56 -0
- package/tokens/typography.json +64 -24
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.
|
|
20
|
+
| Current version/status | 4.15.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}",
|
|
@@ -2826,6 +2831,15 @@ var coreTokens = {
|
|
|
2826
2831
|
}
|
|
2827
2832
|
},
|
|
2828
2833
|
"highContrast": {
|
|
2834
|
+
"action": {
|
|
2835
|
+
"bg": "{colors.brand.800}",
|
|
2836
|
+
"bgHover": "{colors.brand.900}",
|
|
2837
|
+
"bgActive": "{colors.brand.900}",
|
|
2838
|
+
"text": "{colors.white}",
|
|
2839
|
+
"onPage": "{colors.brand.900}",
|
|
2840
|
+
"onSurface": "{colors.brand.900}",
|
|
2841
|
+
"rail": "{colors.brand.900}"
|
|
2842
|
+
},
|
|
2829
2843
|
"surface": {
|
|
2830
2844
|
"page": "{colors.white}",
|
|
2831
2845
|
"card": "{colors.white}",
|
|
@@ -4678,6 +4692,16 @@ var coreTokens = {
|
|
|
4678
4692
|
"underline": "{colors.brand.600} / 0.4",
|
|
4679
4693
|
"underlineHover": "{colors.brand.700}"
|
|
4680
4694
|
},
|
|
4695
|
+
"action": {
|
|
4696
|
+
"bg": "{colors.brand.700}",
|
|
4697
|
+
"bgHover": "{colors.brand.800}",
|
|
4698
|
+
"bgActive": "{colors.brand.900}",
|
|
4699
|
+
"text": "{colors.white}",
|
|
4700
|
+
"focusRing": "{colors.brand.500} / 0.4",
|
|
4701
|
+
"onPage": "{colors.brand.700}",
|
|
4702
|
+
"onSurface": "{colors.brand.700}",
|
|
4703
|
+
"rail": "{colors.brand.700}"
|
|
4704
|
+
},
|
|
4681
4705
|
"text": {
|
|
4682
4706
|
"onPage": {
|
|
4683
4707
|
"default": "{colors.neutral.900}",
|
|
@@ -5001,38 +5025,38 @@ var coreTokens = {
|
|
|
5001
5025
|
"heading": {
|
|
5002
5026
|
"h1": {
|
|
5003
5027
|
"fontFamily": "{typography.families.sans}",
|
|
5004
|
-
"fontSize": "{typography.scale.
|
|
5005
|
-
"lineHeight": "{typography.scale.
|
|
5028
|
+
"fontSize": "{typography.scale.4xl.fontSize}",
|
|
5029
|
+
"lineHeight": "{typography.scale.4xl.lineHeight}",
|
|
5006
5030
|
"fontWeight": 800,
|
|
5007
|
-
"letterSpacing": "{typography.scale.
|
|
5031
|
+
"letterSpacing": "{typography.scale.4xl.letterSpacing}"
|
|
5008
5032
|
},
|
|
5009
5033
|
"h2": {
|
|
5010
5034
|
"fontFamily": "{typography.families.sans}",
|
|
5011
|
-
"fontSize": "{typography.scale.
|
|
5012
|
-
"lineHeight": "{typography.scale.
|
|
5035
|
+
"fontSize": "{typography.scale.3xl.fontSize}",
|
|
5036
|
+
"lineHeight": "{typography.scale.3xl.lineHeight}",
|
|
5013
5037
|
"fontWeight": 700,
|
|
5014
|
-
"letterSpacing": "{typography.scale.
|
|
5038
|
+
"letterSpacing": "{typography.scale.3xl.letterSpacing}"
|
|
5015
5039
|
},
|
|
5016
5040
|
"h3": {
|
|
5017
5041
|
"fontFamily": "{typography.families.sans}",
|
|
5018
|
-
"fontSize": "{typography.scale.
|
|
5019
|
-
"lineHeight": "{typography.scale.
|
|
5042
|
+
"fontSize": "{typography.scale.2xl.fontSize}",
|
|
5043
|
+
"lineHeight": "{typography.scale.2xl.lineHeight}",
|
|
5020
5044
|
"fontWeight": 700,
|
|
5021
|
-
"letterSpacing": "{typography.scale.
|
|
5045
|
+
"letterSpacing": "{typography.scale.2xl.letterSpacing}"
|
|
5022
5046
|
},
|
|
5023
5047
|
"h4": {
|
|
5024
5048
|
"fontFamily": "{typography.families.sans}",
|
|
5025
|
-
"fontSize": "{typography.scale.
|
|
5026
|
-
"lineHeight": "{typography.scale.
|
|
5049
|
+
"fontSize": "{typography.scale.xl.fontSize}",
|
|
5050
|
+
"lineHeight": "{typography.scale.xl.lineHeight}",
|
|
5027
5051
|
"fontWeight": 600,
|
|
5028
|
-
"letterSpacing": "{typography.scale.
|
|
5052
|
+
"letterSpacing": "{typography.scale.xl.letterSpacing}"
|
|
5029
5053
|
},
|
|
5030
5054
|
"h5": {
|
|
5031
5055
|
"fontFamily": "{typography.families.sans}",
|
|
5032
|
-
"fontSize": "{typography.scale.
|
|
5033
|
-
"lineHeight": "{typography.scale.
|
|
5056
|
+
"fontSize": "{typography.scale.xl.fontSize}",
|
|
5057
|
+
"lineHeight": "{typography.scale.xl.lineHeight}",
|
|
5034
5058
|
"fontWeight": 600,
|
|
5035
|
-
"letterSpacing": "{typography.scale.
|
|
5059
|
+
"letterSpacing": "{typography.scale.xl.letterSpacing}"
|
|
5036
5060
|
},
|
|
5037
5061
|
"h6": {
|
|
5038
5062
|
"fontFamily": "{typography.families.sans}",
|
|
@@ -5052,24 +5076,24 @@ var coreTokens = {
|
|
|
5052
5076
|
"display": {
|
|
5053
5077
|
"1": {
|
|
5054
5078
|
"fontFamily": "{typography.families.sans}",
|
|
5055
|
-
"fontSize": "{typography.scale.
|
|
5056
|
-
"lineHeight": "{typography.scale.
|
|
5079
|
+
"fontSize": "{typography.scale.4xl.fontSize}",
|
|
5080
|
+
"lineHeight": "{typography.scale.4xl.lineHeight}",
|
|
5057
5081
|
"fontWeight": 800,
|
|
5058
|
-
"letterSpacing": "{typography.scale.
|
|
5082
|
+
"letterSpacing": "{typography.scale.4xl.letterSpacing}"
|
|
5059
5083
|
},
|
|
5060
5084
|
"2": {
|
|
5061
5085
|
"fontFamily": "{typography.families.sans}",
|
|
5062
|
-
"fontSize": "{typography.scale.
|
|
5063
|
-
"lineHeight": "{typography.scale.
|
|
5086
|
+
"fontSize": "{typography.scale.4xl.fontSize}",
|
|
5087
|
+
"lineHeight": "{typography.scale.4xl.lineHeight}",
|
|
5064
5088
|
"fontWeight": 800,
|
|
5065
|
-
"letterSpacing": "{typography.scale.
|
|
5089
|
+
"letterSpacing": "{typography.scale.4xl.letterSpacing}"
|
|
5066
5090
|
},
|
|
5067
5091
|
"3": {
|
|
5068
5092
|
"fontFamily": "{typography.families.sans}",
|
|
5069
|
-
"fontSize": "{typography.scale.
|
|
5070
|
-
"lineHeight": "{typography.scale.
|
|
5093
|
+
"fontSize": "{typography.scale.4xl.fontSize}",
|
|
5094
|
+
"lineHeight": "{typography.scale.4xl.lineHeight}",
|
|
5071
5095
|
"fontWeight": 700,
|
|
5072
|
-
"letterSpacing": "{typography.scale.
|
|
5096
|
+
"letterSpacing": "{typography.scale.4xl.letterSpacing}"
|
|
5073
5097
|
},
|
|
5074
5098
|
"4": {
|
|
5075
5099
|
"fontFamily": "{typography.families.sans}",
|
|
@@ -5099,6 +5123,46 @@ var coreTokens = {
|
|
|
5099
5123
|
"lineHeight": "{typography.scale.xl.lineHeight}",
|
|
5100
5124
|
"fontWeight": 400,
|
|
5101
5125
|
"letterSpacing": "{typography.scale.xl.letterSpacing}"
|
|
5126
|
+
},
|
|
5127
|
+
"responsive": {
|
|
5128
|
+
"md": {
|
|
5129
|
+
"heading": {
|
|
5130
|
+
"h1": {
|
|
5131
|
+
"fontSize": "{typography.scale.6xl.fontSize}",
|
|
5132
|
+
"lineHeight": "{typography.scale.6xl.lineHeight}"
|
|
5133
|
+
},
|
|
5134
|
+
"h2": {
|
|
5135
|
+
"fontSize": "{typography.scale.5xl.fontSize}",
|
|
5136
|
+
"lineHeight": "{typography.scale.5xl.lineHeight}"
|
|
5137
|
+
},
|
|
5138
|
+
"h3": {
|
|
5139
|
+
"fontSize": "{typography.scale.4xl.fontSize}",
|
|
5140
|
+
"lineHeight": "{typography.scale.4xl.lineHeight}"
|
|
5141
|
+
},
|
|
5142
|
+
"h4": {
|
|
5143
|
+
"fontSize": "{typography.scale.3xl.fontSize}",
|
|
5144
|
+
"lineHeight": "{typography.scale.3xl.lineHeight}"
|
|
5145
|
+
},
|
|
5146
|
+
"h5": {
|
|
5147
|
+
"fontSize": "{typography.scale.2xl.fontSize}",
|
|
5148
|
+
"lineHeight": "{typography.scale.2xl.lineHeight}"
|
|
5149
|
+
}
|
|
5150
|
+
},
|
|
5151
|
+
"display": {
|
|
5152
|
+
"1": {
|
|
5153
|
+
"fontSize": "{typography.scale.7xl.fontSize}",
|
|
5154
|
+
"lineHeight": "{typography.scale.7xl.lineHeight}"
|
|
5155
|
+
},
|
|
5156
|
+
"2": {
|
|
5157
|
+
"fontSize": "{typography.scale.6xl.fontSize}",
|
|
5158
|
+
"lineHeight": "{typography.scale.6xl.lineHeight}"
|
|
5159
|
+
},
|
|
5160
|
+
"3": {
|
|
5161
|
+
"fontSize": "{typography.scale.5xl.fontSize}",
|
|
5162
|
+
"lineHeight": "{typography.scale.5xl.lineHeight}"
|
|
5163
|
+
}
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5102
5166
|
}
|
|
5103
5167
|
}
|
|
5104
5168
|
};
|
|
@@ -5130,6 +5194,42 @@ var layoutResponsive = (layout) => {
|
|
|
5130
5194
|
const responsive = isPlainObject(layout) ? layout.responsive : void 0;
|
|
5131
5195
|
return isPlainObject(responsive) ? responsive : {};
|
|
5132
5196
|
};
|
|
5197
|
+
var ROLE_FIELD_SUFFIXES = {
|
|
5198
|
+
fontFamily: "family",
|
|
5199
|
+
fontSize: "size",
|
|
5200
|
+
lineHeight: "line-height",
|
|
5201
|
+
fontWeight: "weight",
|
|
5202
|
+
letterSpacing: "letter-spacing"
|
|
5203
|
+
};
|
|
5204
|
+
var typographyResponsive = (typography) => {
|
|
5205
|
+
const responsive = isPlainObject(typography) ? typography.responsive : void 0;
|
|
5206
|
+
if (!isPlainObject(responsive)) return [];
|
|
5207
|
+
return Object.entries(responsive).flatMap(
|
|
5208
|
+
([breakpoint, groups]) => Object.entries(groups).flatMap(([group, node]) => {
|
|
5209
|
+
const roles = Object.keys(node).some((key) => key in ROLE_FIELD_SUFFIXES) ? [[[group], node]] : Object.entries(node).map(([level, fields]) => [[group, level], fields]);
|
|
5210
|
+
return roles.flatMap(
|
|
5211
|
+
([roleParts, fields]) => Object.entries(fields).map(([field, value]) => {
|
|
5212
|
+
const suffix = ROLE_FIELD_SUFFIXES[field];
|
|
5213
|
+
if (suffix === void 0) {
|
|
5214
|
+
throw new Error(`typography.responsive.${breakpoint}.${roleParts.join(".")}.${field} is not a typography role field`);
|
|
5215
|
+
}
|
|
5216
|
+
return { breakpoint, roleParts: [...roleParts], suffix, value };
|
|
5217
|
+
})
|
|
5218
|
+
);
|
|
5219
|
+
})
|
|
5220
|
+
);
|
|
5221
|
+
};
|
|
5222
|
+
var ACTION_SYSTEM_FAMILIES = ["brand", "accent", "info"];
|
|
5223
|
+
var ACTION_EXCLUDED_PALETTE_FAMILIES = /* @__PURE__ */ new Set(["yellow", "integration-icy-blue"]);
|
|
5224
|
+
var actionFamilies = (tokens2) => {
|
|
5225
|
+
const colors = tokens2.colors;
|
|
5226
|
+
const palette = isPlainObject(colors.palette) ? colors.palette : {};
|
|
5227
|
+
return Object.fromEntries([
|
|
5228
|
+
...ACTION_SYSTEM_FAMILIES.map((name) => [name, colors[name]]),
|
|
5229
|
+
...Object.entries(palette).filter(([name]) => !ACTION_EXCLUDED_PALETTE_FAMILIES.has(name))
|
|
5230
|
+
]);
|
|
5231
|
+
};
|
|
5232
|
+
var actionSteps = (tokens2) => Object.keys(tokens2.colors.brand);
|
|
5133
5233
|
var resolveTokenReference = (tokens2, reference) => {
|
|
5134
5234
|
const path = reference.slice(1, -1).split(".");
|
|
5135
5235
|
let current = tokens2;
|
|
@@ -5216,6 +5316,9 @@ var createCssVariableMap = (tokens2, options = {}) => {
|
|
|
5216
5316
|
Object.entries(baseTokens.colors).forEach(([group, scale]) => {
|
|
5217
5317
|
assignColorGroup([group], scale);
|
|
5218
5318
|
});
|
|
5319
|
+
actionSteps(tokens2).forEach((step) => {
|
|
5320
|
+
assign(toVariableName(prefix, "action", step), baseTokens.colors.brand[step]);
|
|
5321
|
+
});
|
|
5219
5322
|
if (baseTokens.space) {
|
|
5220
5323
|
Object.entries(baseTokens.space).forEach(([key, value]) => {
|
|
5221
5324
|
assign(toVariableName(prefix, "space", key), value);
|
|
@@ -5370,11 +5473,9 @@ var createCssVariableMap = (tokens2, options = {}) => {
|
|
|
5370
5473
|
assign(toVariableName(prefix, "font", key, "letter-spacing"), scaleEntry.letterSpacing);
|
|
5371
5474
|
});
|
|
5372
5475
|
const assignRole = (rolePrefixParts, entry) => {
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
assign(toVariableName(prefix, ...rolePrefixParts, "weight"), entry.fontWeight);
|
|
5377
|
-
assign(toVariableName(prefix, ...rolePrefixParts, "letter-spacing"), entry.letterSpacing);
|
|
5476
|
+
Object.entries(ROLE_FIELD_SUFFIXES).forEach(([field, suffix]) => {
|
|
5477
|
+
assign(toVariableName(prefix, ...rolePrefixParts, suffix), entry[field]);
|
|
5478
|
+
});
|
|
5378
5479
|
};
|
|
5379
5480
|
const heading = baseTokens.typography?.heading;
|
|
5380
5481
|
if (heading) {
|
|
@@ -5396,6 +5497,9 @@ var createCssVariableMap = (tokens2, options = {}) => {
|
|
|
5396
5497
|
if (lead) {
|
|
5397
5498
|
assignRole(["lead"], lead);
|
|
5398
5499
|
}
|
|
5500
|
+
typographyResponsive(baseTokens.typography).forEach(({ breakpoint, roleParts, suffix, value }) => {
|
|
5501
|
+
assign(toVariableName(prefix, "typography", "responsive", breakpoint, ...roleParts, suffix), value);
|
|
5502
|
+
});
|
|
5399
5503
|
Object.entries(baseTokens.shadows).forEach(([key, value]) => {
|
|
5400
5504
|
if (typeof value === "string") {
|
|
5401
5505
|
assign(toVariableName(prefix, "shadow", key), value);
|
|
@@ -5551,6 +5655,20 @@ var generateCssVariables = (tokens2, options = {}) => {
|
|
|
5551
5655
|
addDark(varName, pickSemantic(tokens2, getPath(darkLink, [key]), value));
|
|
5552
5656
|
addHighContrast(varName, pickSemantic(tokens2, getPath(highContrastLink, [key]), value));
|
|
5553
5657
|
});
|
|
5658
|
+
const actionValue = (value) => {
|
|
5659
|
+
const match = typeof value === "string" ? value.match(/^\{colors\.brand\.([^}]+)\}(?:\s*\/\s*([0-9.]+))?$/) : null;
|
|
5660
|
+
if (!match) return pickSemantic(tokens2, value);
|
|
5661
|
+
const ramp = `var(${toVariableName(prefix, "action", match[1])})`;
|
|
5662
|
+
return match[2] === void 0 ? ramp : `color-mix(in srgb, ${ramp} ${Math.round(Number(match[2]) * 1e3) / 10}%, transparent)`;
|
|
5663
|
+
};
|
|
5664
|
+
const darkAction = getPath(darkMode, ["action"]);
|
|
5665
|
+
const highContrastAction = getPath(highContrastMode, ["action"]);
|
|
5666
|
+
Object.entries(tokens2.action ?? {}).forEach(([key, value]) => {
|
|
5667
|
+
const varName = toVariableName(prefix, "action", kebabPathSegment(key));
|
|
5668
|
+
addBase(varName, actionValue(value));
|
|
5669
|
+
addDark(varName, actionValue(getPath(darkAction, [key]) ?? value));
|
|
5670
|
+
addHighContrast(varName, actionValue(getPath(highContrastAction, [key]) ?? value));
|
|
5671
|
+
});
|
|
5554
5672
|
const highContrastButtons = getPath(highContrastMode, ["buttons"]);
|
|
5555
5673
|
if (isPlainObject(highContrastButtons)) {
|
|
5556
5674
|
Object.entries(highContrastButtons).forEach(([variant, states]) => {
|
|
@@ -5599,6 +5717,16 @@ ${indent}}`;
|
|
|
5599
5717
|
const systemDarkBlock = `@media (prefers-color-scheme: dark) {
|
|
5600
5718
|
${modeBlock(themeSelectors("system"), modeLines(darkEntries), " ")}
|
|
5601
5719
|
}`;
|
|
5720
|
+
const steps = actionSteps(tokens2);
|
|
5721
|
+
const actionBlocks = Object.entries(actionFamilies(tokens2)).map(([name, scale]) => {
|
|
5722
|
+
const lines = steps.map((step) => {
|
|
5723
|
+
if (scale[step] === void 0) throw new Error(`Action family "${name}" has no ${step} step`);
|
|
5724
|
+
return ` ${toVariableName(prefix, "action", step)}: ${resolveValue(tokens2, scale[step])};`;
|
|
5725
|
+
});
|
|
5726
|
+
return `${selector}[data-spectre-action="${name}"] {
|
|
5727
|
+
${lines.join("\n")}
|
|
5728
|
+
}`;
|
|
5729
|
+
});
|
|
5602
5730
|
const control = tokens2.control;
|
|
5603
5731
|
const compact = isPlainObject(control) && isPlainObject(control.compact) ? control.compact : {};
|
|
5604
5732
|
const densityLines = Object.entries(compact).flatMap(
|
|
@@ -5611,27 +5739,50 @@ ${modeBlock(themeSelectors("system"), modeLines(darkEntries), " ")}
|
|
|
5611
5739
|
${densityLines.join("\n")}
|
|
5612
5740
|
}`] : [];
|
|
5613
5741
|
const breakpoints = tokens2.breakpoints;
|
|
5614
|
-
const
|
|
5615
|
-
|
|
5616
|
-
if (
|
|
5617
|
-
throw new Error(
|
|
5742
|
+
const responsiveLines = /* @__PURE__ */ new Map();
|
|
5743
|
+
const addResponsive = (namespace, breakpoint, name, source) => {
|
|
5744
|
+
if (breakpoints[breakpoint] === void 0) {
|
|
5745
|
+
throw new Error(`${namespace}.responsive.${breakpoint} does not name a breakpoints entry`);
|
|
5618
5746
|
}
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5747
|
+
responsiveLines.set(breakpoint, [...responsiveLines.get(breakpoint) ?? [], ` ${name}: var(${source});`]);
|
|
5748
|
+
};
|
|
5749
|
+
Object.entries(layoutResponsive(tokens2.layout)).forEach(([breakpoint, scales]) => {
|
|
5750
|
+
LAYOUT_SCALES.forEach(({ path, varParts }) => {
|
|
5751
|
+
Object.keys(layoutScale(scales, path)).forEach((key) => {
|
|
5752
|
+
addResponsive(
|
|
5753
|
+
"layout",
|
|
5754
|
+
breakpoint,
|
|
5755
|
+
toVariableName(prefix, "layout", ...varParts, kebabCase(key)),
|
|
5756
|
+
toVariableName(prefix, "layout", "responsive", breakpoint, ...varParts, kebabCase(key))
|
|
5757
|
+
);
|
|
5758
|
+
});
|
|
5759
|
+
});
|
|
5760
|
+
});
|
|
5761
|
+
typographyResponsive(tokens2.typography).forEach(({ breakpoint, roleParts, suffix }) => {
|
|
5762
|
+
addResponsive(
|
|
5763
|
+
"typography",
|
|
5764
|
+
breakpoint,
|
|
5765
|
+
toVariableName(prefix, ...roleParts, suffix),
|
|
5766
|
+
toVariableName(prefix, "typography", "responsive", breakpoint, ...roleParts, suffix)
|
|
5625
5767
|
);
|
|
5626
|
-
|
|
5768
|
+
});
|
|
5769
|
+
const responsiveBlocks = Object.keys(breakpoints).filter((breakpoint) => responsiveLines.has(breakpoint)).map(
|
|
5770
|
+
(breakpoint) => `@media (min-width: ${resolveValue(tokens2, breakpoints[breakpoint])}) {
|
|
5627
5771
|
${selector} {
|
|
5628
|
-
${
|
|
5772
|
+
${responsiveLines.get(breakpoint).join("\n")}
|
|
5629
5773
|
}
|
|
5630
|
-
}
|
|
5631
|
-
|
|
5632
|
-
return [
|
|
5633
|
-
|
|
5634
|
-
|
|
5774
|
+
}`
|
|
5775
|
+
);
|
|
5776
|
+
return [
|
|
5777
|
+
rootBlock,
|
|
5778
|
+
darkBlock,
|
|
5779
|
+
highContrastBlock,
|
|
5780
|
+
lightBlock,
|
|
5781
|
+
systemDarkBlock,
|
|
5782
|
+
...actionBlocks,
|
|
5783
|
+
...densityBlocks,
|
|
5784
|
+
...responsiveBlocks
|
|
5785
|
+
].join("\n") + "\n";
|
|
5635
5786
|
};
|
|
5636
5787
|
|
|
5637
5788
|
// src/index.ts
|