@phcdevworks/spectre-tokens 3.0.0 → 3.2.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
@@ -7,7 +7,7 @@
7
7
  | Project team | `project-design` |
8
8
  | Repository role | Spectre L1 design-token contract |
9
9
  | Package/artifact | `@phcdevworks/spectre-tokens` |
10
- | Current version/status | 2.9.0 |
10
+ | Current version/status | 3.1.0 |
11
11
 
12
12
  ## Standard Workflow
13
13
 
@@ -136,6 +136,7 @@ import tokens from '@phcdevworks/spectre-tokens'
136
136
  const card = {
137
137
  background: tokens.surface.page,
138
138
  color: tokens.text.onPage.default,
139
+ maxWidth: tokens.layout.container.maxWidthProse,
139
140
  padding: tokens.space['16'],
140
141
  borderRadius: tokens.radii.md
141
142
  }
@@ -219,6 +220,7 @@ const card = {
219
220
  background: tokens.surface.card,
220
221
  color: tokens.text.onSurface.default,
221
222
  borderColor: tokens.component.iconBox.border,
223
+ maxWidth: tokens.layout.container.maxWidthProse,
222
224
  padding: tokens.space['16']
223
225
  }
224
226
  ```
@@ -246,6 +248,11 @@ CSS variable contract.
246
248
  .card {
247
249
  background: var(--sp-surface-card);
248
250
  color: var(--sp-text-on-surface-default);
251
+ max-width: var(--sp-layout-container-max-width-prose);
252
+ }
253
+
254
+ .app-shell {
255
+ width: var(--sp-layout-sidebar-width);
249
256
  }
250
257
  ```
251
258
 
@@ -268,6 +275,21 @@ export default {
268
275
  Use `tailwindTheme` directly only when a consumer needs the generated theme
269
276
  object outside the preset shape.
270
277
 
278
+ The generated Tailwind theme includes the layout width mappings
279
+ `maxWidth.container`, `maxWidth.prose`, and `width.sidebar`, derived from
280
+ `layout.container.maxWidth`, `layout.container.maxWidthProse`, and
281
+ `layout.sidebar.width`.
282
+
283
+ ```tsx
284
+ export function ArticleShell() {
285
+ return (
286
+ <main className="mx-auto max-w-prose">
287
+ <aside className="w-sidebar" />
288
+ </main>
289
+ )
290
+ }
291
+ ```
292
+
271
293
  ### Token model
272
294
 
273
295
  The generated token object includes these namespaces:
@@ -300,6 +322,11 @@ The exported runtime token object is a flattened string-based tree generated
300
322
  from `tokens/`. Source-only wrapper fields such as `value` and `metadata` are
301
323
  internal generation details and are not part of the public package contract.
302
324
 
325
+ The `layout` namespace includes section, stack, and container spacing tokens,
326
+ plus fixed layout width tokens for common consumer shells:
327
+ `layout.container.maxWidth`, `layout.container.maxWidthProse`, and
328
+ `layout.sidebar.width`.
329
+
303
330
  ## Public contract guarantees
304
331
 
305
332
  `contract.manifest.json` is the machine-readable contract authority for this
package/dist/index.cjs CHANGED
@@ -147,6 +147,51 @@ var coreTokens = {
147
147
  "active": "{colors.info.50}",
148
148
  "text": "{colors.neutral.900}"
149
149
  }
150
+ },
151
+ "checkbox": {
152
+ "bg": "{colors.white}",
153
+ "border": "{colors.neutral.300}",
154
+ "checkedBg": "{colors.info.600}",
155
+ "checkedBorder": "{colors.info.600}",
156
+ "text": "{colors.white}",
157
+ "disabledBg": "{colors.neutral.50}",
158
+ "disabledBorder": "{colors.neutral.200}"
159
+ },
160
+ "radio": {
161
+ "bg": "{colors.white}",
162
+ "border": "{colors.neutral.300}",
163
+ "checkedBg": "{colors.info.600}",
164
+ "checkedBorder": "{colors.info.600}",
165
+ "text": "{colors.white}",
166
+ "disabledBg": "{colors.neutral.50}",
167
+ "disabledBorder": "{colors.neutral.200}"
168
+ },
169
+ "select": {
170
+ "bg": "{colors.white}",
171
+ "border": "{colors.neutral.300}",
172
+ "text": "{colors.neutral.900}",
173
+ "placeholderText": "{colors.neutral.500}",
174
+ "disabledBg": "{colors.neutral.50}",
175
+ "disabledBorder": "{colors.neutral.200}",
176
+ "focusBorder": "{colors.info.500}"
177
+ },
178
+ "textarea": {
179
+ "bg": "{colors.white}",
180
+ "border": "{colors.neutral.300}",
181
+ "text": "{colors.neutral.900}",
182
+ "placeholder": "{colors.neutral.500}",
183
+ "disabledBg": "{colors.neutral.50}",
184
+ "disabledBorder": "{colors.neutral.200}",
185
+ "focusBorder": "{colors.info.500}"
186
+ },
187
+ "fieldset": {
188
+ "border": "{colors.neutral.200}",
189
+ "legendText": "{colors.neutral.900}"
190
+ },
191
+ "label": {
192
+ "text": "{colors.neutral.900}",
193
+ "disabledText": "{colors.neutral.400}",
194
+ "requiredIndicatorText": "{colors.error.600}"
150
195
  }
151
196
  },
152
197
  "buttons": {
@@ -401,6 +446,51 @@ var coreTokens = {
401
446
  "active": "{colors.info.50}",
402
447
  "text": "{colors.neutral.900}"
403
448
  }
449
+ },
450
+ "checkbox": {
451
+ "bg": "{colors.white}",
452
+ "border": "{colors.neutral.300}",
453
+ "checkedBg": "{colors.info.600}",
454
+ "checkedBorder": "{colors.info.600}",
455
+ "text": "{colors.white}",
456
+ "disabledBg": "{colors.neutral.50}",
457
+ "disabledBorder": "{colors.neutral.200}"
458
+ },
459
+ "radio": {
460
+ "bg": "{colors.white}",
461
+ "border": "{colors.neutral.300}",
462
+ "checkedBg": "{colors.info.600}",
463
+ "checkedBorder": "{colors.info.600}",
464
+ "text": "{colors.white}",
465
+ "disabledBg": "{colors.neutral.50}",
466
+ "disabledBorder": "{colors.neutral.200}"
467
+ },
468
+ "select": {
469
+ "bg": "{colors.white}",
470
+ "border": "{colors.neutral.300}",
471
+ "text": "{colors.neutral.900}",
472
+ "placeholderText": "{colors.neutral.500}",
473
+ "disabledBg": "{colors.neutral.50}",
474
+ "disabledBorder": "{colors.neutral.200}",
475
+ "focusBorder": "{colors.info.500}"
476
+ },
477
+ "textarea": {
478
+ "bg": "{colors.white}",
479
+ "border": "{colors.neutral.300}",
480
+ "text": "{colors.neutral.900}",
481
+ "placeholder": "{colors.neutral.500}",
482
+ "disabledBg": "{colors.neutral.50}",
483
+ "disabledBorder": "{colors.neutral.200}",
484
+ "focusBorder": "{colors.info.500}"
485
+ },
486
+ "fieldset": {
487
+ "border": "{colors.neutral.200}",
488
+ "legendText": "{colors.neutral.900}"
489
+ },
490
+ "label": {
491
+ "text": "{colors.neutral.900}",
492
+ "disabledText": "{colors.neutral.400}",
493
+ "requiredIndicatorText": "{colors.error.600}"
404
494
  }
405
495
  }
406
496
  },
@@ -550,6 +640,51 @@ var coreTokens = {
550
640
  "active": "{colors.info.900}",
551
641
  "text": "{colors.neutral.100}"
552
642
  }
643
+ },
644
+ "checkbox": {
645
+ "bg": "{colors.neutral.800}",
646
+ "border": "{colors.neutral.600}",
647
+ "checkedBg": "{colors.info.600}",
648
+ "checkedBorder": "{colors.info.600}",
649
+ "text": "{colors.white}",
650
+ "disabledBg": "{colors.neutral.900}",
651
+ "disabledBorder": "{colors.neutral.700}"
652
+ },
653
+ "radio": {
654
+ "bg": "{colors.neutral.800}",
655
+ "border": "{colors.neutral.600}",
656
+ "checkedBg": "{colors.info.600}",
657
+ "checkedBorder": "{colors.info.600}",
658
+ "text": "{colors.white}",
659
+ "disabledBg": "{colors.neutral.900}",
660
+ "disabledBorder": "{colors.neutral.700}"
661
+ },
662
+ "select": {
663
+ "bg": "{colors.neutral.800}",
664
+ "border": "{colors.neutral.600}",
665
+ "text": "{colors.neutral.50}",
666
+ "placeholderText": "{colors.neutral.400}",
667
+ "disabledBg": "{colors.neutral.900}",
668
+ "disabledBorder": "{colors.neutral.700}",
669
+ "focusBorder": "{colors.info.400}"
670
+ },
671
+ "textarea": {
672
+ "bg": "{colors.neutral.800}",
673
+ "border": "{colors.neutral.600}",
674
+ "text": "{colors.neutral.50}",
675
+ "placeholder": "{colors.neutral.400}",
676
+ "disabledBg": "{colors.neutral.900}",
677
+ "disabledBorder": "{colors.neutral.700}",
678
+ "focusBorder": "{colors.info.400}"
679
+ },
680
+ "fieldset": {
681
+ "border": "{colors.neutral.700}",
682
+ "legendText": "{colors.neutral.50}"
683
+ },
684
+ "label": {
685
+ "text": "{colors.neutral.50}",
686
+ "disabledText": "{colors.neutral.600}",
687
+ "requiredIndicatorText": "{colors.error.400}"
553
688
  }
554
689
  }
555
690
  }
@@ -929,7 +1064,11 @@ var coreTokens = {
929
1064
  "md": "1.5rem",
930
1065
  "lg": "2rem"
931
1066
  },
932
- "maxWidth": "72rem"
1067
+ "maxWidth": "72rem",
1068
+ "maxWidthProse": "65ch"
1069
+ },
1070
+ "sidebar": {
1071
+ "width": "16rem"
933
1072
  }
934
1073
  },
935
1074
  "font": {
@@ -1124,6 +1263,42 @@ var DROPDOWN_FIELDS = [
1124
1263
  { name: "item-active", modePath: ["item", "active"], aliasPath: ["item", "active"] },
1125
1264
  { name: "item-text", modePath: ["item", "text"], aliasPath: ["item", "text"] }
1126
1265
  ];
1266
+ var SELECTION_CONTROL_FIELDS = [
1267
+ { name: "bg", tokenKey: "bg" },
1268
+ { name: "border", tokenKey: "border" },
1269
+ { name: "checked-bg", tokenKey: "checkedBg" },
1270
+ { name: "checked-border", tokenKey: "checkedBorder" },
1271
+ { name: "text", tokenKey: "text" },
1272
+ { name: "disabled-bg", tokenKey: "disabledBg" },
1273
+ { name: "disabled-border", tokenKey: "disabledBorder" }
1274
+ ];
1275
+ var SELECT_FIELDS = [
1276
+ { name: "bg", tokenKey: "bg" },
1277
+ { name: "border", tokenKey: "border" },
1278
+ { name: "text", tokenKey: "text" },
1279
+ { name: "placeholder-text", tokenKey: "placeholderText" },
1280
+ { name: "disabled-bg", tokenKey: "disabledBg" },
1281
+ { name: "disabled-border", tokenKey: "disabledBorder" },
1282
+ { name: "focus-border", tokenKey: "focusBorder" }
1283
+ ];
1284
+ var TEXTAREA_FIELDS = [
1285
+ { name: "bg", tokenKey: "bg" },
1286
+ { name: "border", tokenKey: "border" },
1287
+ { name: "text", tokenKey: "text" },
1288
+ { name: "placeholder", tokenKey: "placeholder" },
1289
+ { name: "disabled-bg", tokenKey: "disabledBg" },
1290
+ { name: "disabled-border", tokenKey: "disabledBorder" },
1291
+ { name: "focus-border", tokenKey: "focusBorder" }
1292
+ ];
1293
+ var FIELDSET_FIELDS = [
1294
+ { name: "border", tokenKey: "border" },
1295
+ { name: "legend-text", tokenKey: "legendText" }
1296
+ ];
1297
+ var LABEL_FIELDS = [
1298
+ { name: "text", tokenKey: "text" },
1299
+ { name: "disabled-text", tokenKey: "disabledText" },
1300
+ { name: "required-indicator-text", tokenKey: "requiredIndicatorText" }
1301
+ ];
1127
1302
  var resolveTokenReference = (tokens2, reference) => {
1128
1303
  const path = reference.slice(1, -1).split(".");
1129
1304
  let current = tokens2;
@@ -1231,6 +1406,13 @@ var createCssVariableMap = (tokens2, options = {}) => {
1231
1406
  if (container?.maxWidth) {
1232
1407
  assign(toVariableName(prefix, "layout", "container", "max-width"), container.maxWidth);
1233
1408
  }
1409
+ if (container?.maxWidthProse) {
1410
+ assign(toVariableName(prefix, "layout", "container", "max-width-prose"), container.maxWidthProse);
1411
+ }
1412
+ const sidebar = layout.sidebar;
1413
+ if (sidebar?.width) {
1414
+ assign(toVariableName(prefix, "layout", "sidebar", "width"), sidebar.width);
1415
+ }
1234
1416
  }
1235
1417
  const border = baseTokens.border;
1236
1418
  if (border?.width) {
@@ -1332,6 +1514,7 @@ var generateCssVariables = (tokens2, options = {}) => {
1332
1514
  const surfaceAliases = tokens2.surface ?? {};
1333
1515
  const textAliases = tokens2.text ?? {};
1334
1516
  const componentAliases = tokens2.component ?? {};
1517
+ const linkTokens = tokens2.link ?? {};
1335
1518
  const semanticEntries = [
1336
1519
  { varParts: ["surface", "page"], modePath: ["surface", "page"], aliasSrc: surfaceAliases, aliasPath: ["page"] },
1337
1520
  { varParts: ["surface", "card"], modePath: ["surface", "card"], aliasSrc: surfaceAliases, aliasPath: ["card"] },
@@ -1339,6 +1522,10 @@ var generateCssVariables = (tokens2, options = {}) => {
1339
1522
  { varParts: ["surface", "overlay"], modePath: ["surface", "overlay"], aliasSrc: surfaceAliases, aliasPath: ["overlay"] },
1340
1523
  { varParts: ["surface", "subtle"], modePath: ["surface", "subtle"] },
1341
1524
  { varParts: ["surface", "hero"], modePath: ["surface", "hero"], aliasSrc: surfaceAliases, aliasPath: ["hero"] },
1525
+ { varParts: ["surface", "hover"], modePath: ["surface", "hover"], aliasSrc: surfaceAliases, aliasPath: ["hover"] },
1526
+ { varParts: ["surface", "selected"], modePath: ["surface", "selected"], aliasSrc: surfaceAliases, aliasPath: ["selected"] },
1527
+ { varParts: ["surface", "active"], modePath: ["surface", "active"], aliasSrc: surfaceAliases, aliasPath: ["active"] },
1528
+ { varParts: ["surface", "divider"], modePath: ["surface", "divider"], aliasSrc: surfaceAliases, aliasPath: ["divider"] },
1342
1529
  { varParts: ["text", "on", "page", "default"], modePath: ["text", "onPage", "default"], aliasSrc: textAliases, aliasPath: ["onPage", "default"] },
1343
1530
  { varParts: ["text", "on", "page", "muted"], modePath: ["text", "onPage", "muted"], aliasSrc: textAliases, aliasPath: ["onPage", "muted"] },
1344
1531
  { varParts: ["text", "on", "page", "subtle"], modePath: ["text", "onPage", "subtle"], aliasSrc: textAliases, aliasPath: ["onPage", "subtle"] },
@@ -1394,6 +1581,42 @@ var generateCssVariables = (tokens2, options = {}) => {
1394
1581
  modePath: ["component", "dropdown", ...modePath],
1395
1582
  aliasSrc: componentAliases,
1396
1583
  aliasPath: ["dropdown", ...aliasPath]
1584
+ })),
1585
+ ...SELECTION_CONTROL_FIELDS.map(({ name, tokenKey }) => ({
1586
+ varParts: ["checkbox", name],
1587
+ modePath: ["component", "checkbox", tokenKey],
1588
+ aliasSrc: componentAliases,
1589
+ aliasPath: ["checkbox", tokenKey]
1590
+ })),
1591
+ ...SELECTION_CONTROL_FIELDS.map(({ name, tokenKey }) => ({
1592
+ varParts: ["radio", name],
1593
+ modePath: ["component", "radio", tokenKey],
1594
+ aliasSrc: componentAliases,
1595
+ aliasPath: ["radio", tokenKey]
1596
+ })),
1597
+ ...SELECT_FIELDS.map(({ name, tokenKey }) => ({
1598
+ varParts: ["select", name],
1599
+ modePath: ["component", "select", tokenKey],
1600
+ aliasSrc: componentAliases,
1601
+ aliasPath: ["select", tokenKey]
1602
+ })),
1603
+ ...TEXTAREA_FIELDS.map(({ name, tokenKey }) => ({
1604
+ varParts: ["textarea", name],
1605
+ modePath: ["component", "textarea", tokenKey],
1606
+ aliasSrc: componentAliases,
1607
+ aliasPath: ["textarea", tokenKey]
1608
+ })),
1609
+ ...FIELDSET_FIELDS.map(({ name, tokenKey }) => ({
1610
+ varParts: ["fieldset", name],
1611
+ modePath: ["component", "fieldset", tokenKey],
1612
+ aliasSrc: componentAliases,
1613
+ aliasPath: ["fieldset", tokenKey]
1614
+ })),
1615
+ ...LABEL_FIELDS.map(({ name, tokenKey }) => ({
1616
+ varParts: ["label", name],
1617
+ modePath: ["component", "label", tokenKey],
1618
+ aliasSrc: componentAliases,
1619
+ aliasPath: ["label", tokenKey]
1397
1620
  }))
1398
1621
  ];
1399
1622
  const baseLines = [];
@@ -1410,6 +1633,12 @@ var generateCssVariables = (tokens2, options = {}) => {
1410
1633
  addBase(varName, pickSemantic(tokens2, getPath(defaultMode, modePath), ...aliasCandidate));
1411
1634
  addDark(varName, pickSemantic(tokens2, getPath(darkMode, modePath), getPath(defaultMode, modePath), ...aliasCandidate));
1412
1635
  });
1636
+ Object.entries(linkTokens).forEach(([key, value]) => {
1637
+ const varName = toVariableName(prefix, "link", key);
1638
+ const resolved = pickSemantic(tokens2, value);
1639
+ addBase(varName, resolved);
1640
+ addDark(varName, resolved);
1641
+ });
1413
1642
  const rootBlock = `${selector} {
1414
1643
  ${[...baseLines, ...mapLines].join("\n")}
1415
1644
  }`;
@@ -1461,7 +1690,11 @@ var createTailwindTheme = (source = tokens) => {
1461
1690
  transitionTimingFunction: { ...source.transitions.easing },
1462
1691
  opacity: { ...source.opacity },
1463
1692
  maxWidth: {
1464
- container: source.layout?.container?.maxWidth
1693
+ container: source.layout?.container?.maxWidth,
1694
+ prose: source.layout?.container?.maxWidthProse
1695
+ },
1696
+ width: {
1697
+ sidebar: source.layout?.sidebar?.width
1465
1698
  },
1466
1699
  borderWidth: {
1467
1700
  DEFAULT: source.border?.width.base,