@phcdevworks/spectre-tokens 2.0.0 → 2.1.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/LICENSE +0 -0
- package/README.md +41 -24
- package/dist/index.cjs +69 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +18 -8
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +69 -9
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/tokens/components.json +387 -105
- package/tokens/modes.json +421 -104
- package/tokens/palette.json +6 -6
- package/tokens/primitives.json +6 -0
- package/tokens/semantic-roles.json +2 -1
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
# @phcdevworks/spectre-tokens
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### **The DNA (Layer 1 of the Spectre 8-Layer Arsenal)**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@phcdevworks/spectre-tokens` is the Single Source of Truth for the entire Spectre ecosystem. It defines the visual language—colors, typography, space, and semantic roles—that all other layers consume.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
🤝 **[Contributing Guide](CONTRIBUTING.md)** | 📝 **[Changelog](CHANGELOG.md)** | 🏛️ **[Spectre Arsenal](https://github.com/phcdevworks)**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🏗️ Core Architecture
|
|
12
|
+
|
|
13
|
+
This package is the foundation. It follows a strict **JSON-First** policy—authoritative values live in `tokens/` and are transformed into multiple consumption modes (CSS, JS/TS, Tailwind).
|
|
14
|
+
|
|
15
|
+
- 🧬 **Authoritative JSON**: Domain-specific token storage for better maintainability.
|
|
16
|
+
- 🧪 **Type-Safe DNA**: 100% strict TypeScript interfaces derived directly from JSON.
|
|
17
|
+
- 🌪️ **Multi-Format Output**: Generates CSS Variables, Tailwind Presets, and ESM/CJS exports.
|
|
18
|
+
- ♿ **Accessibility First**: Encodes WCAG constraints (contrast, touch targets) at the token level.
|
|
19
|
+
|
|
20
|
+
---
|
|
10
21
|
|
|
11
22
|
**Single source of truth:** JSON is the source. Everything else is generated.
|
|
12
23
|
|
|
13
|
-
- ✅
|
|
14
|
-
- ✅
|
|
15
|
-
- ✅
|
|
16
|
-
- ✅
|
|
17
|
-
- ✅
|
|
24
|
+
- ✅ **Modular Architecture**: domain-specific token storage for better maintainability
|
|
25
|
+
- ✅ **AI-Ready DNA**: Zero `any` types and 100% strict TypeScript build process
|
|
26
|
+
- ✅ **Auto-Generated Typings**: Strictly-typed TS interfaces derived directly from JSON
|
|
27
|
+
- ✅ **Multi-File Merging**: Type-safe merging of cross-domain token references
|
|
28
|
+
- ✅ **JS/TS objects**, Tailwind theme + preset, and CSS variable outputs
|
|
29
|
+
- ✅ **CRO-focused surfaces** (buttons, forms, states) and accessibility-first tokens
|
|
30
|
+
- ✅ **Type-safe outputs** with bundled `.d.ts` files
|
|
18
31
|
|
|
19
32
|
## Installation
|
|
20
33
|
|
|
@@ -132,7 +145,7 @@ The `tokens` object includes:
|
|
|
132
145
|
- `opacity`: Opacity scale (hover, active, disabled, focus, overlay, tooltip)
|
|
133
146
|
- `borders`: Border color tokens
|
|
134
147
|
- `surface`: Semantic surface backgrounds (page, card, input, overlay)
|
|
135
|
-
- `text`: Semantic text colors (onPage, onSurface with default/muted/subtle/meta)
|
|
148
|
+
- `text`: Semantic text colors (onPage, onSurface with default/muted/subtle/meta/**brand**)
|
|
136
149
|
- `component`: Component-specific tokens (card, input, button, badge, iconBox)
|
|
137
150
|
- `modes`: Theme mode definitions (default/light and dark)
|
|
138
151
|
|
|
@@ -429,6 +442,7 @@ For secondary/metadata text styling:
|
|
|
429
442
|
```ts
|
|
430
443
|
tokens.text.onPage.meta; // Metadata text on page backgrounds
|
|
431
444
|
tokens.text.onSurface.meta; // Metadata text on card/surface backgrounds
|
|
445
|
+
tokens.text.onPage.brand; // Brand accent text on page canvas
|
|
432
446
|
```
|
|
433
447
|
|
|
434
448
|
```css
|
|
@@ -744,12 +758,12 @@ tokens.borders.input; // "#cbd5f5"
|
|
|
744
758
|
|
|
745
759
|
| Folder | Responsibility |
|
|
746
760
|
| ---------- | ------------------------------------------------------------------------------------------------------------- |
|
|
747
|
-
| `tokens/` | Raw JSON token files
|
|
761
|
+
| `tokens/` | Raw JSON token files (modularized as `palette.json`, `typography.json`, `components.json`, etc.). |
|
|
748
762
|
| `src/` | TypeScript source that turns JSON into reusable formats (JS/TS exports, Tailwind theme, CSS helpers). |
|
|
749
|
-
| `scripts/` | Build utilities
|
|
763
|
+
| `scripts/` | Build utilities and strictly-typed token merging engines. |
|
|
750
764
|
| `dist/` | Generated artifacts: `index.js`, `index.cjs`, `index.d.ts`, and `index.css`. Regenerated via `npm run build`. |
|
|
751
765
|
|
|
752
|
-
Designers only touch the JSON under `tokens/`. Engineering evolves `src/` + `scripts/` when structure
|
|
766
|
+
Designers only touch the JSON under `tokens/`. Engineering evolves `src/` + `scripts/` when structure or transforms change.
|
|
753
767
|
|
|
754
768
|
## Build & Release
|
|
755
769
|
|
|
@@ -853,7 +867,7 @@ Spectre is a **specification-driven design system** built on three strict layers
|
|
|
853
867
|
- Designers own `tokens/*.json`; engineers maintain `src/` transforms
|
|
854
868
|
- Contrast targets and accessibility constraints are encoded at the token level
|
|
855
869
|
|
|
856
|
-
**Status**:
|
|
870
|
+
**Status**: v2.0.0 released. Transitioned to modular JSON storage and full AI-readiness.
|
|
857
871
|
|
|
858
872
|
### 2. @phcdevworks/spectre-ui (Framework-Agnostic UI Layer)
|
|
859
873
|
|
|
@@ -874,7 +888,7 @@ Spectre is a **specification-driven design system** built on three strict layers
|
|
|
874
888
|
- Every CSS selector has a matching recipe where applicable
|
|
875
889
|
- Tailwind preset is optional and non-authoritative
|
|
876
890
|
|
|
877
|
-
**Status**:
|
|
891
|
+
**Status**: v1.0.0 hardened and aligned to tokens. v2.0.0 compatibility ready.
|
|
878
892
|
|
|
879
893
|
### 3. Adapters (WordPress, Astro, etc.)
|
|
880
894
|
|
|
@@ -1420,7 +1434,7 @@ const customThemeCSS = generateCssVariables(tokens, {
|
|
|
1420
1434
|
**Question:** Can I add my own theme modes beyond default/dark?
|
|
1421
1435
|
|
|
1422
1436
|
**Answer:**
|
|
1423
|
-
Yes! Extend the `modes` object in your `
|
|
1437
|
+
Yes! Extend the `modes` object in your `tokens/modes.json`:
|
|
1424
1438
|
|
|
1425
1439
|
```json
|
|
1426
1440
|
{
|
|
@@ -1488,7 +1502,7 @@ Two approaches:
|
|
|
1488
1502
|
Semantic tokens in `modes` use the `{ value: "..." }` format for metadata. The TypeScript library automatically resolves these:
|
|
1489
1503
|
|
|
1490
1504
|
```ts
|
|
1491
|
-
// In
|
|
1505
|
+
// In tokens/*.json: { "value": "#f8fafc" }
|
|
1492
1506
|
tokens.surface.page; // Returns "#f8fafc" (string)
|
|
1493
1507
|
|
|
1494
1508
|
// The library handles resolution automatically
|
|
@@ -1506,15 +1520,18 @@ Issues and pull requests are welcome. If you are proposing token changes, update
|
|
|
1506
1520
|
|
|
1507
1521
|
For detailed contribution guidelines, see **[CONTRIBUTING.md](CONTRIBUTING.md)**.
|
|
1508
1522
|
|
|
1509
|
-
|
|
1523
|
+
---
|
|
1510
1524
|
|
|
1511
|
-
|
|
1525
|
+
## 🏛️ The Spectre Suite Hierarchy
|
|
1512
1526
|
|
|
1513
|
-
|
|
1527
|
+
Spectre is built on a non-negotiable hierarchy to prevent style leakage and duplication:
|
|
1528
|
+
|
|
1529
|
+
1. **Layer 1: DNA (This Package)** – The source of truth for all design values.
|
|
1530
|
+
2. **Layer 2: Blueprint (UI)** ([@phcdevworks/spectre-ui](https://github.com/phcdevworks/spectre-ui)) – Translates tokens into CSS structure and recipes.
|
|
1531
|
+
3. **Layer 3: Adapters** (WordPress, Astro, etc.) – Thin bridges that map Layer 2 to specific frameworks.
|
|
1514
1532
|
|
|
1515
|
-
|
|
1533
|
+
> **The Golden Rule**: Tokens define *meaning*. UI defines *structure*. Adapters define *delivery*.
|
|
1534
|
+
|
|
1535
|
+
---
|
|
1516
1536
|
|
|
1517
|
-
If Spectre Tokens helps your workflow, consider sponsoring:
|
|
1518
1537
|
|
|
1519
|
-
- [GitHub Sponsors](https://github.com/sponsors/phcdevworks)
|
|
1520
|
-
- [Buy Me a Coffee](https://buymeacoffee.com/phcdevworks)
|
package/dist/index.cjs
CHANGED
|
@@ -229,6 +229,9 @@ var coreTokens = {
|
|
|
229
229
|
},
|
|
230
230
|
"textDisabled": {
|
|
231
231
|
"value": "{colors.neutral.400}"
|
|
232
|
+
},
|
|
233
|
+
"focusRing": {
|
|
234
|
+
"value": "{colors.info.500} / 0.4"
|
|
232
235
|
}
|
|
233
236
|
},
|
|
234
237
|
"secondary": {
|
|
@@ -258,6 +261,9 @@ var coreTokens = {
|
|
|
258
261
|
},
|
|
259
262
|
"borderDisabled": {
|
|
260
263
|
"value": "{colors.neutral.200}"
|
|
264
|
+
},
|
|
265
|
+
"focusRing": {
|
|
266
|
+
"value": "{colors.info.500} / 0.4"
|
|
261
267
|
}
|
|
262
268
|
},
|
|
263
269
|
"ghost": {
|
|
@@ -278,6 +284,9 @@ var coreTokens = {
|
|
|
278
284
|
},
|
|
279
285
|
"textDisabled": {
|
|
280
286
|
"value": "{colors.neutral.400}"
|
|
287
|
+
},
|
|
288
|
+
"focusRing": {
|
|
289
|
+
"value": "{colors.info.500} / 0.4"
|
|
281
290
|
}
|
|
282
291
|
},
|
|
283
292
|
"danger": {
|
|
@@ -301,6 +310,9 @@ var coreTokens = {
|
|
|
301
310
|
},
|
|
302
311
|
"textDisabled": {
|
|
303
312
|
"value": "{colors.neutral.400}"
|
|
313
|
+
},
|
|
314
|
+
"focusRing": {
|
|
315
|
+
"value": "{colors.error.500} / 0.4"
|
|
304
316
|
}
|
|
305
317
|
},
|
|
306
318
|
"success": {
|
|
@@ -324,6 +336,9 @@ var coreTokens = {
|
|
|
324
336
|
},
|
|
325
337
|
"textDisabled": {
|
|
326
338
|
"value": "{colors.neutral.400}"
|
|
339
|
+
},
|
|
340
|
+
"focusRing": {
|
|
341
|
+
"value": "{colors.success.500} / 0.4"
|
|
327
342
|
}
|
|
328
343
|
},
|
|
329
344
|
"cta": {
|
|
@@ -350,6 +365,9 @@ var coreTokens = {
|
|
|
350
365
|
},
|
|
351
366
|
"shadow": {
|
|
352
367
|
"value": "0 4px 14px 0 {colors.warning.500} / 0.39"
|
|
368
|
+
},
|
|
369
|
+
"focusRing": {
|
|
370
|
+
"value": "{colors.warning.500} / 0.4"
|
|
353
371
|
}
|
|
354
372
|
},
|
|
355
373
|
"accent": {
|
|
@@ -373,6 +391,9 @@ var coreTokens = {
|
|
|
373
391
|
},
|
|
374
392
|
"textDisabled": {
|
|
375
393
|
"value": "{colors.neutral.400}"
|
|
394
|
+
},
|
|
395
|
+
"focusRing": {
|
|
396
|
+
"value": "{colors.accent.500} / 0.4"
|
|
376
397
|
}
|
|
377
398
|
}
|
|
378
399
|
},
|
|
@@ -774,6 +795,9 @@ var coreTokens = {
|
|
|
774
795
|
"pair": "modes.dark.component.badge.neutralText"
|
|
775
796
|
}
|
|
776
797
|
},
|
|
798
|
+
"neutralBgHover": {
|
|
799
|
+
"value": "{colors.neutral.600}"
|
|
800
|
+
},
|
|
777
801
|
"neutralText": {
|
|
778
802
|
"value": "{colors.neutral.100}",
|
|
779
803
|
"metadata": {}
|
|
@@ -784,6 +808,9 @@ var coreTokens = {
|
|
|
784
808
|
"pair": "modes.dark.component.badge.infoText"
|
|
785
809
|
}
|
|
786
810
|
},
|
|
811
|
+
"infoBgHover": {
|
|
812
|
+
"value": "{colors.info.700}"
|
|
813
|
+
},
|
|
787
814
|
"infoText": {
|
|
788
815
|
"value": "{colors.info.100}",
|
|
789
816
|
"metadata": {}
|
|
@@ -794,6 +821,9 @@ var coreTokens = {
|
|
|
794
821
|
"pair": "modes.dark.component.badge.successText"
|
|
795
822
|
}
|
|
796
823
|
},
|
|
824
|
+
"successBgHover": {
|
|
825
|
+
"value": "{colors.success.700}"
|
|
826
|
+
},
|
|
797
827
|
"successText": {
|
|
798
828
|
"value": "{colors.success.100}",
|
|
799
829
|
"metadata": {}
|
|
@@ -804,6 +834,9 @@ var coreTokens = {
|
|
|
804
834
|
"pair": "modes.dark.component.badge.warningText"
|
|
805
835
|
}
|
|
806
836
|
},
|
|
837
|
+
"warningBgHover": {
|
|
838
|
+
"value": "{colors.warning.700}"
|
|
839
|
+
},
|
|
807
840
|
"warningText": {
|
|
808
841
|
"value": "{colors.warning.100}",
|
|
809
842
|
"metadata": {}
|
|
@@ -814,6 +847,9 @@ var coreTokens = {
|
|
|
814
847
|
"pair": "modes.dark.component.badge.dangerText"
|
|
815
848
|
}
|
|
816
849
|
},
|
|
850
|
+
"dangerBgHover": {
|
|
851
|
+
"value": "{colors.error.700}"
|
|
852
|
+
},
|
|
817
853
|
"dangerText": {
|
|
818
854
|
"value": "{colors.error.100}",
|
|
819
855
|
"metadata": {}
|
|
@@ -952,16 +988,16 @@ var coreTokens = {
|
|
|
952
988
|
"900": "#0f172a"
|
|
953
989
|
},
|
|
954
990
|
"accent": {
|
|
955
|
-
"50": "#
|
|
956
|
-
"100": "#
|
|
991
|
+
"50": "#f5f3ff",
|
|
992
|
+
"100": "#ede9fe",
|
|
957
993
|
"200": "#ddd6fe",
|
|
958
|
-
"300": "#
|
|
959
|
-
"400": "#
|
|
994
|
+
"300": "#c4b5fd",
|
|
995
|
+
"400": "#a78bfa",
|
|
960
996
|
"500": "#8b5cf6",
|
|
961
997
|
"600": "#7c3aed",
|
|
962
998
|
"700": "#6d28d9",
|
|
963
|
-
"800": "#
|
|
964
|
-
"900": "#
|
|
999
|
+
"800": "#5b21b6",
|
|
1000
|
+
"900": "#4c1d95"
|
|
965
1001
|
},
|
|
966
1002
|
"success": {
|
|
967
1003
|
"50": "#f0fdf4",
|
|
@@ -1169,6 +1205,12 @@ var coreTokens = {
|
|
|
1169
1205
|
"card": "{colors.neutral.200}",
|
|
1170
1206
|
"input": "{colors.neutral.300}"
|
|
1171
1207
|
},
|
|
1208
|
+
"border": {
|
|
1209
|
+
"width": {
|
|
1210
|
+
"base": "1px",
|
|
1211
|
+
"thick": "2px"
|
|
1212
|
+
}
|
|
1213
|
+
},
|
|
1172
1214
|
"surface": {
|
|
1173
1215
|
"page": {
|
|
1174
1216
|
"value": "{colors.neutral.50}",
|
|
@@ -1228,7 +1270,8 @@ var coreTokens = {
|
|
|
1228
1270
|
"sm": "1rem",
|
|
1229
1271
|
"md": "1.5rem",
|
|
1230
1272
|
"lg": "2rem"
|
|
1231
|
-
}
|
|
1273
|
+
},
|
|
1274
|
+
"maxWidth": "72rem"
|
|
1232
1275
|
}
|
|
1233
1276
|
},
|
|
1234
1277
|
"font": {
|
|
@@ -1430,6 +1473,16 @@ var createCssVariableMap = (tokens2, options = {}) => {
|
|
|
1430
1473
|
assign(toVariableName(prefix, "layout", "container", "padding-inline", key), value);
|
|
1431
1474
|
});
|
|
1432
1475
|
}
|
|
1476
|
+
const container = layout.container;
|
|
1477
|
+
if (container?.maxWidth) {
|
|
1478
|
+
assign(toVariableName(prefix, "layout", "container", "max-width"), container.maxWidth);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
const border = baseTokens.border;
|
|
1482
|
+
if (border?.width) {
|
|
1483
|
+
Object.entries(border.width).forEach(([key, value]) => {
|
|
1484
|
+
assign(toVariableName(prefix, "border", "width", key), value);
|
|
1485
|
+
});
|
|
1433
1486
|
}
|
|
1434
1487
|
Object.entries(baseTokens.radii).forEach(([key, value]) => {
|
|
1435
1488
|
assign(toVariableName(prefix, "radius", key), value);
|
|
@@ -1808,7 +1861,7 @@ var createTailwindTheme = (source = tokens) => {
|
|
|
1808
1861
|
return {
|
|
1809
1862
|
colors,
|
|
1810
1863
|
spacing: { ...source.space ?? {} },
|
|
1811
|
-
borderRadius: { ...source.radii },
|
|
1864
|
+
borderRadius: { ...source.radii ?? {} },
|
|
1812
1865
|
fontFamily,
|
|
1813
1866
|
fontSize,
|
|
1814
1867
|
boxShadow: { ...source.shadows },
|
|
@@ -1816,7 +1869,14 @@ var createTailwindTheme = (source = tokens) => {
|
|
|
1816
1869
|
zIndex: { ...source.zIndex },
|
|
1817
1870
|
transitionDuration: { ...source.transitions.duration },
|
|
1818
1871
|
transitionTimingFunction: { ...source.transitions.easing },
|
|
1819
|
-
opacity: { ...source.opacity }
|
|
1872
|
+
opacity: { ...source.opacity },
|
|
1873
|
+
maxWidth: {
|
|
1874
|
+
container: source.layout?.container?.maxWidth
|
|
1875
|
+
},
|
|
1876
|
+
borderWidth: {
|
|
1877
|
+
DEFAULT: source.border?.width.base,
|
|
1878
|
+
...source.border?.width ?? {}
|
|
1879
|
+
}
|
|
1820
1880
|
};
|
|
1821
1881
|
};
|
|
1822
1882
|
var tailwindTheme = createTailwindTheme(tokens);
|