@tenphi/glaze 0.18.0 → 1.0.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 +84 -30
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.mts +8 -4
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/docs/api.md +519 -400
- package/docs/methodology.md +125 -50
- package/docs/migration.md +79 -144
- package/docs/okhst.md +116 -254
- package/package.json +1 -1
package/docs/migration.md
CHANGED
|
@@ -1,124 +1,39 @@
|
|
|
1
1
|
# Migration & Integration
|
|
2
2
|
|
|
3
|
-
How to
|
|
3
|
+
How to move an existing CSS, design-token, or application color system to
|
|
4
|
+
Glaze, then export the resulting palette in the shape your app and design tools
|
|
5
|
+
consume.
|
|
4
6
|
|
|
5
|
-
If you're starting from scratch, see [methodology.md](methodology.md) first — that's about
|
|
7
|
+
If you're starting from scratch, see [methodology.md](methodology.md) first — that's about _designing_ the palette. This doc is about _consuming_ it.
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## Contents
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
// before
|
|
17
|
-
theme.colors({ surface: { lightness: 97 }, text: { base: 'surface', lightness: '-52' } });
|
|
18
|
-
// after
|
|
19
|
-
theme.colors({ surface: { tone: 97 }, text: { base: 'surface', tone: '-52' } });
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
The same applies to `glaze.color({ ..., lightness })` (structured form) → `tone`, and the `{ h, s, l }` value object is unchanged (still OKHSL) — but you can now also pass `{ h, s, t }` (OKHST) or an `okhst(H S% T%)` string.
|
|
23
|
-
|
|
24
|
-
Tone is **0–100** like the old lightness, but the *scale is contrast-uniform*, not perceptual-lightness-uniform. Numeric values won't land at the same OKHSL lightness — equal tone steps now give equal WCAG contrast. Re-eyeball absolute values (especially mid-range ones); relative deltas and contrast-floored tokens usually need no change because they were already contrast-driven.
|
|
25
|
-
|
|
26
|
-
### Config window shape
|
|
27
|
-
|
|
28
|
-
The lightness windows became tone windows, and `darkCurve` was removed (no curve to tune). The `[lo, hi]` tuple form carries over directly:
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
// before
|
|
32
|
-
glaze.configure({ lightLightness: [10, 100], darkLightness: [15, 95], darkCurve: 0.5 });
|
|
33
|
-
// after
|
|
34
|
-
glaze.configure({
|
|
35
|
-
lightTone: [10, 100],
|
|
36
|
-
darkTone: [15, 95],
|
|
37
|
-
// darkCurve removed
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`lightLightness`/`darkLightness` → `lightTone`/`darkTone`. The window value is `[lo, hi]` (reference eps — the common form), `{ lo, hi, eps }` (advanced: explicit render curvature), or `false` to disable clamping. `false` removes the *boundaries* (full `[0, 100]` range), not the contrast-uniform tone curve. Per-token `glaze.color(value, config)` overrides use the same shape.
|
|
42
|
-
|
|
43
|
-
### The `contrast` prop now selects a metric
|
|
44
|
-
|
|
45
|
-
A bare number or preset is still **WCAG** and needs no change. To use APCA or split a pair across the metric, use the object form:
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
contrast: 4.5 // unchanged — WCAG 4.5
|
|
49
|
-
contrast: { wcag: 6 } // explicit WCAG
|
|
50
|
-
contrast: { apca: 60 } // APCA Lc floor
|
|
51
|
-
contrast: { wcag: [4.5, 7] } // pair inside the metric
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Forcing extremes: `'max'` / `'min'`
|
|
55
|
-
|
|
56
|
-
For colors that should sit at the scheme's tone extreme (pure-white knockouts, near-black scrims, deliberately faint disabled chips), reach for `tone: 'max'` / `tone: 'min'` instead of a large absolute number or a low contrast floor standing in for "push it all the way". `'max'` resolves to author tone 100, `'min'` to 0, and both flow through scheme mapping (so they invert in dark under `mode: 'auto'`). No `base` required.
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
// before — low contrast as a proxy for "stay near the surface"
|
|
60
|
-
'disabled-text': { base: 'chip', tone: '+1', contrast: 1.51, mode: 'fixed' }
|
|
61
|
-
// after — say it directly with tone
|
|
62
|
-
'disabled-text': { base: 'chip', tone: '+18', saturation: 0.4, autoFlip: false }
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### The `autoFlip` prop (previously `flip`)
|
|
66
|
-
|
|
67
|
-
The per-color configuration property `flip` has been renamed to `autoFlip` to align with the global `autoFlip` configuration option and to avoid confusion with dark-mode/scheme tone inversion (which is handled automatically by the system).
|
|
68
|
-
|
|
69
|
-
Relative `tone` offsets that overshoot `[0, 100]` now **mirror to the other side of the base by default** (controlled by the per-color `autoFlip`, which inherits the global `autoFlip`, default `true`). Previously such offsets always clamped to the boundary. If you relied on clamping — e.g. `tone: '+48'` to stack a color up to 100 — set `autoFlip: false` on that color (or `glaze.configure({ autoFlip: false })` globally) to restore the clamping behavior. `autoFlip` also governs the contrast solver's direction (its previous sole role).
|
|
70
|
-
|
|
71
|
-
### Resolved variants store tone
|
|
72
|
-
|
|
73
|
-
`ResolvedColorVariant` now exposes `t` (tone, 0–1) instead of `l`. If you read resolved internals, convert with `variantToOkhsl(variant).l`. Token/CSS/JSON output uses native formats by default (`oklch` for `tokens()` / `json()`, `okhsl` for `tasty()`); use `tasty({ format: 'okhsl' })` or `tasty({ format: 'okhst' })` for Glaze-native spaces.
|
|
74
|
-
|
|
75
|
-
### 0.16.0 — output format defaults and Tasty-only spaces
|
|
76
|
-
|
|
77
|
-
**Breaking changes in 0.16.0:**
|
|
78
|
-
|
|
79
|
-
| Export | Old default | New default |
|
|
80
|
-
|---|---|---|
|
|
81
|
-
| `tokens()` / `json()` (theme + palette) | `okhsl` | `oklch` |
|
|
82
|
-
| Standalone `.json()` | `okhsl` | `oklch` |
|
|
83
|
-
| `tasty()` | `okhsl` (unchanged) | `okhsl` |
|
|
84
|
-
|
|
85
|
-
`'okhsl'` and the new `'okhst'` output format are **Tasty-only**. Passing either to `css()`, `tailwind()`, `tokens()`, or `json()` throws. Migrate:
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
// before
|
|
89
|
-
theme.tokens({ format: 'okhsl' })
|
|
90
|
-
theme.json()
|
|
91
|
-
|
|
92
|
-
// after — pick one
|
|
93
|
-
theme.tasty({ format: 'okhsl' }) // Tasty #name keys, okhsl strings
|
|
94
|
-
theme.tokens({ format: 'oklch' }) // native CSS (new default)
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**New:** `splitHue` on `css()` / `tasty()` (theme + palette) and standalone `color.css()` emits hue as a separate custom property for runtime re-skinning. Requires `format: 'oklch'` and every color to be pastel. See [api.md → Hue channel splitting](api.md#hue-channel-splitting-splithue).
|
|
98
|
-
|
|
99
|
-
### Export snapshots
|
|
100
|
-
|
|
101
|
-
`theme.export()` / `color.export()` snapshots now carry `lightTone` / `darkTone` window objects (not `lightLightness` / `darkLightness`). Old exported JSON with the legacy keys will need its `config` block rewritten before `glaze.from()` / `glaze.colorFrom()`.
|
|
11
|
+
- [Choosing an export](#choosing-an-export)
|
|
12
|
+
- [Wiring exports into the app](#wiring-exports-into-the-app)
|
|
13
|
+
- [Prefix map strategies](#prefix-map-strategies)
|
|
14
|
+
- [Migrating an existing color system](#migrating-from-an-existing-color-system)
|
|
15
|
+
- [Common pitfalls](#common-pitfalls)
|
|
102
16
|
|
|
103
17
|
## Choosing an export
|
|
104
18
|
|
|
105
|
-
Glaze emits the same resolved colors in
|
|
19
|
+
Glaze emits the same resolved colors in seven shapes. Pick one based on your
|
|
20
|
+
renderer or tooling.
|
|
106
21
|
|
|
107
|
-
| Method
|
|
108
|
-
|
|
109
|
-
| `palette.tasty(options?)`
|
|
110
|
-
| `palette.tokens(options?)`
|
|
111
|
-
| `palette.css(options?)`
|
|
112
|
-
| `palette.json(options?)`
|
|
113
|
-
| `palette.dtcg(options?)`
|
|
114
|
-
| `palette.dtcgResolver(options?)` | `{ version, sets, modifiers, resolutionOrder }`
|
|
115
|
-
| `palette.tailwind(options?)`
|
|
22
|
+
| Method | Output shape | Use it for |
|
|
23
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| `palette.tasty(options?)` | `{ '#name': { '': value, '@media(prefers-color-scheme: dark)': value, '@media(prefers-contrast: more)': value } }` | The [Tasty](https://tasty.style) style system. Single object, state aliases keyed inside each token. |
|
|
25
|
+
| `palette.tokens(options?)` | `{ light: { name: value }, dark: { name: value }, ... }` | Most CSS-in-JS systems. Per-variant flat maps, easy to feed into a `:root { ... }` selector via your framework's globals. |
|
|
26
|
+
| `palette.css(options?)` | `{ light: '--name-color: rgb(...);', dark: '...', ... }` | Framework-free CSS / static stylesheets. Variant-grouped CSS custom property strings ready to wrap in `:root` and `prefers-color-scheme` queries. |
|
|
27
|
+
| `palette.json(options?)` | `{ themeName: { name: { light, dark, ... } } }` | Tooling, JSON pipelines. |
|
|
28
|
+
| `palette.dtcg(options?)` | `{ light: { name: { $type, $value } }, dark: { ... }, ... }` | W3C [DTCG 2025.10](https://www.designtokens.org/) `.tokens.json` — Figma, Tokens Studio, Style Dictionary, Terrazzo, Penpot. One document per scheme. |
|
|
29
|
+
| `palette.dtcgResolver(options?)` | `{ version, sets, modifiers, resolutionOrder }` | W3C DTCG **Resolver-Module** — a single document describing every scheme variant as `sets` + a `scheme` modifier with a context per variant. For resolver tools such as Dispersa. |
|
|
30
|
+
| `palette.tailwind(options?)` | `'@theme { --color-*: ... } .dark { ... } ...'` | Tailwind CSS v4. A single ready-to-paste `@theme` block plus dark / high-contrast overrides. |
|
|
116
31
|
|
|
117
|
-
`tasty()`, `tokens()`, `json()`, `dtcg()`, `dtcgResolver()`, and `tailwind()` accept `modes` (`{ dark, highContrast }`). `css()` always returns all four strings (`light`, `dark`, `lightContrast`, `darkContrast`).
|
|
32
|
+
`tasty()`, `tokens()`, `json()`, `dtcg()`, `dtcgResolver()`, and `tailwind()` accept `modes` (`{ dark, highContrast }`). `css()` always returns all four strings (`light`, `dark`, `lightContrast`, `darkContrast`). CSS-string exports accept `format` and default to `'oklch'` (`tokens`/`json`/`css`/`tailwind`/`tasty`; `'rgb'` and `'hsl'` also available). `'okhsl'` and `'okhst'` are supported only on [Tasty](https://tasty.style)-shaped exports (`tasty()`, standalone `token()` / `.tasty()`). `dtcg()` and `dtcgResolver()` ignore `format` and use `colorSpace` instead (`'srgb'` default, `'oklch'` opt-in). See [api.md → Palette](api.md#palette) for full options.
|
|
118
33
|
|
|
119
34
|
## Wiring exports into the app
|
|
120
35
|
|
|
121
|
-
### Tasty
|
|
36
|
+
### [Tasty](https://tasty.style)
|
|
122
37
|
|
|
123
38
|
Spread the result of `palette.tasty()` into a global style call:
|
|
124
39
|
|
|
@@ -127,7 +42,9 @@ import type { Styles } from '@tenphi/tasty';
|
|
|
127
42
|
import { useGlobalStyles } from '@tenphi/tasty';
|
|
128
43
|
import { tastyStatic } from '@tenphi/tasty/static';
|
|
129
44
|
|
|
130
|
-
export const PALETTE_TOKENS = palette.tasty({
|
|
45
|
+
export const PALETTE_TOKENS = palette.tasty({
|
|
46
|
+
/* prefix map */
|
|
47
|
+
}) as Styles;
|
|
131
48
|
|
|
132
49
|
// In your root component:
|
|
133
50
|
useGlobalStyles('body', PALETTE_TOKENS);
|
|
@@ -136,11 +53,14 @@ useGlobalStyles('body', PALETTE_TOKENS);
|
|
|
136
53
|
tastyStatic('body', PALETTE_TOKENS);
|
|
137
54
|
```
|
|
138
55
|
|
|
139
|
-
|
|
56
|
+
By default the dark / high-contrast variants are keyed by media-query states — `'@media(prefers-color-scheme: dark)'` and `'@media(prefers-contrast: more)'` — so the tokens react to the OS preference out of the box, with no extra [Tasty](https://tasty.style) setup.
|
|
57
|
+
|
|
58
|
+
If you'd rather drive the schemes from custom aliases (e.g. a manual toggle that also falls back to the OS preference), set your own [`glaze.configure({ states })`](api.md#configuration) and register what those states _mean_:
|
|
140
59
|
|
|
141
60
|
```ts
|
|
142
61
|
import { setGlobalPredefinedStates } from '@tenphi/tasty';
|
|
143
62
|
|
|
63
|
+
// glaze.configure({ states: { dark: '@dark', highContrast: '@hc' } });
|
|
144
64
|
setGlobalPredefinedStates({
|
|
145
65
|
'@dark':
|
|
146
66
|
'@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
|
|
@@ -151,7 +71,7 @@ setGlobalPredefinedStates({
|
|
|
151
71
|
|
|
152
72
|
The state names here must match the `states` you set in [`glaze.configure({ states })`](api.md#configuration).
|
|
153
73
|
|
|
154
|
-
You can also register the tokens as a Tasty recipe instead of spreading them globally:
|
|
74
|
+
You can also register the tokens as a [Tasty](https://tasty.style) recipe instead of spreading them globally:
|
|
155
75
|
|
|
156
76
|
```ts
|
|
157
77
|
import { configure, tasty } from '@tenphi/tasty';
|
|
@@ -180,15 +100,15 @@ const stylesheet = `
|
|
|
180
100
|
Each property name is `--<prefix><name>-color` by default. Override the suffix:
|
|
181
101
|
|
|
182
102
|
```ts
|
|
183
|
-
palette.css({ suffix: '' });
|
|
184
|
-
palette.css({ format: 'oklch' });
|
|
103
|
+
palette.css({ suffix: '' }); // → '--surface: rgb(...);'
|
|
104
|
+
palette.css({ format: 'oklch' }); // → '--surface-color: oklch(...);'
|
|
185
105
|
```
|
|
186
106
|
|
|
187
107
|
### Framework-agnostic JSON
|
|
188
108
|
|
|
189
109
|
```ts
|
|
190
110
|
const data = palette.json();
|
|
191
|
-
// → { primary: { surface: { light: '
|
|
111
|
+
// → { primary: { surface: { light: 'oklch(...)', dark: 'oklch(...)' } }, ... }
|
|
192
112
|
```
|
|
193
113
|
|
|
194
114
|
Feed into your tooling pipeline. Each color is grouped by theme name, then by token name, then by variant — no prefix logic to undo.
|
|
@@ -235,10 +155,10 @@ The `--color-*` namespace makes every color available as `bg-*` / `text-*` / `bo
|
|
|
235
155
|
|
|
236
156
|
`palette.tokens()` / `tasty()` / `css()` / `dtcg()` / `tailwind()` accept a `prefix` option:
|
|
237
157
|
|
|
238
|
-
| Value
|
|
239
|
-
|
|
240
|
-
| `true` (default)
|
|
241
|
-
| `false`
|
|
158
|
+
| Value | Result |
|
|
159
|
+
| ------------------------ | -------------------------------------------------------------------------- |
|
|
160
|
+
| `true` (default) | Every theme prefixes its tokens with `<themeName>-`. |
|
|
161
|
+
| `false` | No prefixes. Colliding keys produce a `console.warn`; first-write wins. |
|
|
242
162
|
| `Record<string, string>` | Per-theme prefix overrides. Themes not listed fall back to `<themeName>-`. |
|
|
243
163
|
|
|
244
164
|
The most common production pattern: **default theme unprefixed, every other theme prefixed with its name**:
|
|
@@ -249,15 +169,20 @@ palette.tasty({
|
|
|
249
169
|
default: '',
|
|
250
170
|
primary: 'primary-',
|
|
251
171
|
success: 'success-',
|
|
252
|
-
danger:
|
|
172
|
+
danger: 'danger-',
|
|
253
173
|
warning: 'warning-',
|
|
254
|
-
note:
|
|
174
|
+
note: 'note-',
|
|
255
175
|
},
|
|
256
176
|
});
|
|
257
177
|
```
|
|
258
178
|
|
|
259
179
|
This makes neutral tokens consume as `#surface`, `#border`, `#disabled-surface` (no theme namespace) while status colors live under `#danger-surface`, `#success-accent-text`, etc.
|
|
260
180
|
|
|
181
|
+
This explicit map is usually clearer for a neutral `default` theme. The
|
|
182
|
+
separate `primary` palette option below solves a different namespace problem:
|
|
183
|
+
it duplicates one named theme without a prefix while retaining that theme's
|
|
184
|
+
prefixed tokens.
|
|
185
|
+
|
|
261
186
|
### Alias themes for legacy names
|
|
262
187
|
|
|
263
188
|
Two aliases for the same theme instance produce identical token values under different prefixes — useful when you want to support a legacy token name without duplicating definitions:
|
|
@@ -266,7 +191,7 @@ Two aliases for the same theme instance produce identical token values under dif
|
|
|
266
191
|
const palette = glaze.palette({
|
|
267
192
|
default: defaultTheme,
|
|
268
193
|
primary: primaryTheme,
|
|
269
|
-
purple:
|
|
194
|
+
purple: primaryTheme, // legacy alias — same theme, different prefix
|
|
270
195
|
// ...
|
|
271
196
|
});
|
|
272
197
|
|
|
@@ -274,7 +199,7 @@ palette.tasty({
|
|
|
274
199
|
prefix: {
|
|
275
200
|
default: '',
|
|
276
201
|
primary: 'primary-',
|
|
277
|
-
purple:
|
|
202
|
+
purple: 'purple-', // emits #purple-surface alongside #primary-surface
|
|
278
203
|
},
|
|
279
204
|
});
|
|
280
205
|
```
|
|
@@ -283,13 +208,10 @@ Both `#primary-surface` and `#purple-surface` resolve to the exact same color. D
|
|
|
283
208
|
|
|
284
209
|
### `primary` (the unprefixed alias)
|
|
285
210
|
|
|
286
|
-
`glaze.palette(themes, { primary })` and the per-export `primary` option duplicate one theme's tokens
|
|
211
|
+
`glaze.palette(themes, { primary })` and the per-export `primary` option duplicate one theme's tokens _without_ prefix on top of any prefix map. Equivalent to listing that theme twice with different prefixes; useful when the "primary" theme is conceptually distinct from `default` and you want both sets of unprefixed tokens.
|
|
287
212
|
|
|
288
213
|
```ts
|
|
289
|
-
const palette = glaze.palette(
|
|
290
|
-
{ brand, accent },
|
|
291
|
-
{ primary: 'brand' },
|
|
292
|
-
);
|
|
214
|
+
const palette = glaze.palette({ brand, accent }, { primary: 'brand' });
|
|
293
215
|
palette.tokens();
|
|
294
216
|
// → { light: { 'brand-surface': '...', 'surface': '...', 'accent-surface': '...' } }
|
|
295
217
|
```
|
|
@@ -313,16 +235,19 @@ Walk your current color system and bucket every token into one of these categori
|
|
|
313
235
|
- **Shadows / overlays** — elevation, scrims.
|
|
314
236
|
- **One-off colors** — syntax highlighting, charts, illustrations.
|
|
315
237
|
|
|
316
|
-
Each bucket maps cleanly to one of the patterns in [methodology.md](methodology.md). The bucket determines the
|
|
238
|
+
Each bucket maps cleanly to one of the patterns in [methodology.md](methodology.md). The bucket determines the _shape_ of the Glaze definition (root vs dependent, `mode: 'auto'` vs `'fixed'`, contrast-floor vs absolute tone), not the value.
|
|
317
239
|
|
|
318
240
|
### 2. Reproduce the existing values
|
|
319
241
|
|
|
320
|
-
Pick a Glaze definition shape that lands the new color
|
|
242
|
+
Pick a Glaze definition shape that lands the new color _close to_ the legacy hex in light mode. The methodology doc explains the shape per bucket; the API doc covers the levers (`tone`, `saturation`, `contrast`, `mode`, `hue`).
|
|
321
243
|
|
|
322
244
|
Two tactics that make matching easier:
|
|
323
245
|
|
|
324
246
|
- **Anchor strong text at the edge** instead of solving for `'AAA'`. The contrast solver stops at the floor (cr=7), which usually leaves text noticeably softer than a legacy hex like `#1a1a1a`. An absolute `tone: 2` (or wherever the legacy token sits) preserves the look.
|
|
325
|
-
- **
|
|
247
|
+
- **Match the metric the old system actually used.** Numeric WCAG ratios are
|
|
248
|
+
useful when reproducing a measured legacy ratio. For new content roles,
|
|
249
|
+
prefer the APCA presets from the methodology. For low-stakes spacing, use a
|
|
250
|
+
tone delta instead of inventing a contrast target.
|
|
326
251
|
|
|
327
252
|
### 3. Keep the old token names
|
|
328
253
|
|
|
@@ -333,9 +258,19 @@ Use a custom `prefix` map (and theme aliases if needed) so the names your compon
|
|
|
333
258
|
// New: define them in Glaze, map the prefix so they emit unchanged.
|
|
334
259
|
|
|
335
260
|
defaultTheme.colors({
|
|
336
|
-
dark:
|
|
337
|
-
'dark-02': {
|
|
338
|
-
|
|
261
|
+
dark: { base: 'surface', tone: 2, saturation: 0.475 },
|
|
262
|
+
'dark-02': {
|
|
263
|
+
base: 'surface',
|
|
264
|
+
tone: '-1',
|
|
265
|
+
saturation: 0.375,
|
|
266
|
+
contrast: [9, 11],
|
|
267
|
+
},
|
|
268
|
+
'dark-03': {
|
|
269
|
+
base: 'surface',
|
|
270
|
+
tone: '-1',
|
|
271
|
+
saturation: 0.24,
|
|
272
|
+
contrast: [4.5, 5.5],
|
|
273
|
+
},
|
|
339
274
|
});
|
|
340
275
|
|
|
341
276
|
palette.tasty({ prefix: { default: '' } });
|
|
@@ -348,7 +283,7 @@ Once consumers are off the legacy names, rename the Glaze tokens to match your c
|
|
|
348
283
|
|
|
349
284
|
Glaze gives you light/dark/HC for free, but only the light mode is matched against the legacy palette. Before promoting the migration:
|
|
350
285
|
|
|
351
|
-
- Spot-check every surface, text, accent, and disabled pair in dark mode. The tone inversion plus per-color `mode` choices may produce results that
|
|
286
|
+
- Spot-check every surface, text, accent, and disabled pair in dark mode. The tone inversion plus per-color `mode` choices may produce results that _look right_ in light but feel off in dark (typical fix: switch a brand color to `mode: 'fixed'`, or anchor a foreground to `surface` instead of the brand fill — see [methodology.md](methodology.md)).
|
|
352
287
|
- If the legacy system had no high-contrast mode, audit the HC variants Glaze emits. Anywhere the resolved cr is too low or the color blows out, add an HC pair (`tone: ['-7', '-20']`, `contrast: [4.5, 7]`, etc.).
|
|
353
288
|
- Run real screens, not just the token grid. The interaction of multiple Glaze tokens against each other (text on chip, hover bg vs. fill, disabled label on disabled chip) is where mismatches show up.
|
|
354
289
|
|
|
@@ -358,16 +293,16 @@ After migration, mark every default-only token (borders, shadows, disabled chip,
|
|
|
358
293
|
|
|
359
294
|
## Common pitfalls
|
|
360
295
|
|
|
361
|
-
| Symptom
|
|
362
|
-
|
|
363
|
-
| Disabled state stops looking disabled in dark mode.
|
|
364
|
-
| Brand color flips to its complement in dark mode.
|
|
365
|
-
| Brand text washes out against the dark surface.
|
|
366
|
-
| Tokens look right in light, broken in HC.
|
|
367
|
-
| A relative `tone` like `'+48'` lands on the
|
|
368
|
-
| `palette.tokens()` emits unexpected unprefixed names.
|
|
369
|
-
| `console.warn: token "foo" collides with theme "bar"`.
|
|
370
|
-
| `console.warn: color "X" cannot meet contrast`.
|
|
296
|
+
| Symptom | Cause | Fix |
|
|
297
|
+
| ------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
298
|
+
| Disabled state stops looking disabled in dark mode. | Alpha-tinted overlay on `surface-text` (which inverts), giving asymmetric perceived contrast. | Replace it with an adaptive color anchored to `surface`; use a tone delta for visual spacing or a contrast floor when required. See [Chips and disabled states](methodology.md#chips-and-disabled-states). |
|
|
299
|
+
| Brand color flips to its complement in dark mode. | Default `mode: 'auto'` inverts the tone. | Set `mode: 'fixed'` so the tone is remapped (not inverted). |
|
|
300
|
+
| Brand text washes out against the dark surface. | Foreground was anchored to `accent-surface` (the brand fill), so contrast was only enforced against that fill — not the actual surface. | Anchor `accent-text` etc. to `surface` with `mode: 'auto'`. |
|
|
301
|
+
| Tokens look right in light, broken in HC. | The HC pass bypasses the tone window — solver runs over the full `[0, 100]` range. | Add explicit `[normal, hc]` pairs to `tone` / `contrast` for the affected tokens. |
|
|
302
|
+
| A relative `tone` like `'+48'` lands on the _wrong_ (darker) side of its base. | Overshooting offsets now mirror to the other side of the base by default (`autoFlip` inherits `autoFlip`). | Set `autoFlip: false` on the color to clamp to the boundary instead, or use `tone: 'max'`/`'min'` to force the extreme. |
|
|
303
|
+
| `palette.tokens()` emits unexpected unprefixed names. | A `primary` was set on the palette (or per-call) and is duplicating the theme's tokens without prefix. | Pass `primary: false` to disable for that export, or rename `glaze.palette(themes, { primary })`. |
|
|
304
|
+
| `console.warn: token "foo" collides with theme "bar"`. | Two themes resolved to the same output key under your prefix config. | Adjust the prefix map so each token is unique, or accept the first-write-wins behavior. |
|
|
305
|
+
| `console.warn: color "X" cannot meet contrast`. | The requested contrast target is physically unreachable for the color's hue/saturation against its base. | Lower the floor, change the base, or accept the closest passing variant. Use the `name` override on standalone colors to make the warning identifiable. |
|
|
371
306
|
|
|
372
307
|
## See also
|
|
373
308
|
|