@weasel-js/theme 1.5.2 → 1.6.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
@@ -23,7 +23,8 @@ import '@weasel-js/theme/fonts.css'; // optional — bundled Oswald + Inter
23
23
 
24
24
  `tokens.css` is required; component styles reference the custom properties it
25
25
  declares. `fonts.css` is optional — skip it and the token font stacks fall back
26
- to `system-ui`. Nothing is fetched from a third-party host either way.
26
+ to `system-ui`. It sets `:root`'s font as well as declaring the faces; import
27
+ `@weasel-js/theme/faces.css` instead for the `@font-face` rules alone. Nothing is fetched from a third-party host either way.
27
28
 
28
29
  Modes are selected with a data attribute, which cascades:
29
30
 
@@ -88,6 +89,43 @@ const { tokens, provenance, issues } = derive(slate, { mode: 'light' });
88
89
  const theme: Theme = { ...bake(slate), extends: weaselTheme };
89
90
  ```
90
91
 
92
+ ### Axes in DTCG
93
+
94
+ DTCG has one variant dimension, so a document from `toDTCG` holds mode in
95
+ `modes` and every other axis at its default value. That part is plain DTCG: a
96
+ tool that ignores extensions reads a theme at `density=comfortable` (or whatever
97
+ each axis defaults to). The other values ride in the root's
98
+ `$extensions["com.weasel.axes"]`, which `loadDTCG` reads back:
99
+
100
+ ```json
101
+ "$extensions": {
102
+ "com.weasel.axes": {
103
+ "axes": { "mode": { … }, "density": { "default": "comfortable", "values": { "compact": {}, "comfortable": {}, "roomy": {} } } },
104
+ "varies": { "gap": ["density"] },
105
+ "overrides": {
106
+ "density=compact": { "primitives": { "dimension": { "$type": "dimension", "gap": { "$value": "2px" } } }, "modes": {} },
107
+ "density=roomy": { "primitives": { "dimension": { "$type": "dimension", "gap": { "$value": "8px" } } }, "modes": {} }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ - `axes` — every axis the theme resolves with, mode included.
114
+ - `varies` — for each token that depends on an axis besides mode, which ones.
115
+ - `overrides` — a layer shaped like the document (`primitives` and `modes`) for
116
+ each combination of non-default values some token varies by. The key names
117
+ only the axes off their default, in axis order: `density=compact`,
118
+ `density=roomy,contrast=high`.
119
+
120
+ A token listed in `varies` takes its value at a selection from the layer whose
121
+ key matches that selection's non-default values on its own axes — the plain
122
+ groups when all are at default. Absent from that layer, it has no value there
123
+ and falls through to the theme it extends. Axes a token varies by
124
+ independently cost one layer per value; only a token whose value depends on two
125
+ axes at once adds layers for their combinations. This follows the same idea as
126
+ the DTCG resolver module's modifiers and Tokens Studio's theme groups: a base
127
+ set plus per-dimension overrides rather than one mode per combination.
128
+
91
129
  ## Editing tokens
92
130
 
93
131
  `src/generated/` is generated — never edit it. Change `themes/weasel.json`,