@tenphi/glaze 0.0.0-snapshot.f3bb46b → 0.0.0-snapshot.f404191

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.
@@ -0,0 +1,543 @@
1
+ ---
2
+ title: Migration and upgrading
3
+ description: Move an existing color system to Glaze without renaming tokens, and upgrade between major Glaze versions.
4
+ ---
5
+
6
+ This page covers two kinds of move: bringing an existing CSS, design-token, or
7
+ application color system over to Glaze, and upgrading Glaze itself across a
8
+ major version. For designing a palette from scratch, see
9
+ [Designing a palette](./methodology.mdx); for choosing an export shape and
10
+ wiring it into your app, see [Exporting and integration](./exporting.mdx).
11
+
12
+ ## Migrating from an existing color system
13
+
14
+ The fastest path is **map first, design second**. Get every existing token name
15
+ producing a Glaze-resolved color (even a rough first pass), wire the new
16
+ palette in, then iterate on the resolved colors without touching component
17
+ code.
18
+
19
+ ### 1. Inventory the existing tokens
20
+
21
+ Walk your current color system and put every token into one of these buckets:
22
+
23
+ - **Surfaces**: backgrounds, panels, cards, banners.
24
+ - **Surface text**: body text, headings, captions, labels.
25
+ - **Borders, dividers, focus rings**: neutral structural lines.
26
+ - **Brand fills**: solid CTA backgrounds, badges, status banners.
27
+ - **Brand foregrounds**: link text, status text, icon colors on neutral
28
+ backgrounds.
29
+ - **Disabled**: disabled chip and its label.
30
+ - **Shadows and overlays**: elevation and state layers (`shadow` / `glow`),
31
+ and fixed-alpha overlays such as scrims (`opacity`).
32
+ - **One-off colors**: syntax highlighting, charts, illustrations.
33
+
34
+ Each bucket maps onto one of the patterns in
35
+ [Designing a palette](./methodology.mdx). The bucket decides the _shape_ of the
36
+ Glaze definition (root or dependent, `mode: 'auto'` or `'fixed'`, a contrast
37
+ floor or an absolute tone), not its value.
38
+
39
+ ### 2. Reproduce the existing values
40
+
41
+ Pick a definition shape that lands the new color _close to_ the legacy value in
42
+ light mode. [Designing a palette](./methodology.mdx) explains the shape per
43
+ bucket; the [Color definitions](./reference/color-definitions.md) reference
44
+ covers the levers (`tone`, `saturation`, `contrast`, `mode`, `hue`).
45
+
46
+ Three tactics make matching easier:
47
+
48
+ - **Anchor strong text at the edge** instead of solving for `'AAA'`. The
49
+ contrast solver stops at the floor, which usually leaves text noticeably
50
+ softer than the legacy value: on a white surface, a neutral
51
+ `contrast: 'AAA'` (7:1) solves to tone 36, while a legacy `#1a1a1a` sits at
52
+ tone 6.2 (17.4:1). An absolute `tone` preserves the look, but author it a
53
+ little below the measured value: the light
54
+ [tone window](./schemes.mdx#tone-windows) lifts authored tones (tone 0
55
+ renders at 4.95, tone 2 at 6.85), so a neutral `tone: 1.3` renders
56
+ `#1a1a1a`. With `lightTone: false` on the theme, light tones render exactly
57
+ as authored.
58
+ - **Match the metric the old system actually used.** Numeric WCAG ratios are
59
+ useful when you reproduce a measured legacy ratio. For new content roles,
60
+ prefer the APCA presets from the methodology. For low-stakes spacing, use a
61
+ tone delta instead of inventing a contrast target. See
62
+ [Contrast solving](./contrast.mdx).
63
+ - **Pin values that are a contract with `from`.** A brand color you must honor
64
+ can be given as a literal: `{ from: '#2f5bff' }` reproduces that exact value
65
+ in the light scheme whatever the theme's seed saturation, while dark and high
66
+ contrast still adapt. Add `base` and `contrast` when it must stay legible
67
+ against something. See [`from`](./reference/color-definitions.md#from).
68
+
69
+ ### 3. Keep the old token names
70
+
71
+ Use a custom `prefix` map (and [alias themes](./exporting.mdx#alias-themes-for-legacy-names)
72
+ if needed) so the names your components already consume keep working:
73
+
74
+ ```ts
75
+ // Old: components consume `#dark`, `#dark-02`, `#dark-03`.
76
+ // New: define them in Glaze, map the prefix so they emit unchanged.
77
+
78
+ defaultTheme.colors({
79
+ dark: { base: 'surface', tone: 2, saturation: 0.475 },
80
+ 'dark-02': {
81
+ base: 'surface',
82
+ tone: '-1',
83
+ saturation: 0.375,
84
+ contrast: [9, 11],
85
+ },
86
+ 'dark-03': {
87
+ base: 'surface',
88
+ tone: '-1',
89
+ saturation: 0.24,
90
+ contrast: [4.5, 5.5],
91
+ },
92
+ });
93
+
94
+ palette.tasty({ prefix: { default: '' } });
95
+ // → '#dark', '#dark-02', '#dark-03': components don't change.
96
+ ```
97
+
98
+ Once consumers are off the legacy names, rename the Glaze tokens to match your
99
+ conventions. [Prefix map strategies](./exporting.mdx#prefix-map-strategies)
100
+ shows every naming option with real output.
101
+
102
+ ### 4. Verify dark mode and high contrast before promoting
103
+
104
+ Glaze gives you light, dark, and high contrast for free, but only the light
105
+ scheme was matched against the legacy palette. Before you promote the
106
+ migration:
107
+
108
+ - Spot-check every surface, text, accent, and disabled pair in dark mode. The
109
+ tone inversion plus the per-color `mode` can produce results that look right
110
+ in light but feel off in dark. The usual fixes: switch a brand color to
111
+ `mode: 'fixed'`, or anchor a foreground to `surface` instead of the brand
112
+ fill (see [adaptation modes](./schemes.mdx#adaptation-modes) and
113
+ [Designing a palette](./methodology.mdx)).
114
+ - If the legacy system had no high-contrast mode, audit the high-contrast
115
+ variants Glaze emits. Wherever the resolved contrast is too low or a color
116
+ blows out, add a `[normal, highContrast]` pair (`tone: ['-7', '-20']`,
117
+ `contrast: [4.5, 7]`, and so on).
118
+ - Run real screens, not just the token grid. The interaction of several Glaze
119
+ tokens against each other (text on a chip, a hover background against its
120
+ fill, a disabled label on a disabled chip) is where mismatches show up.
121
+
122
+ ### 5. Trim what `extend()` doesn't need
123
+
124
+ After the migration, mark every default-only token (borders, shadows, glows,
125
+ the disabled chip, code highlighting, and so on) `inherit: false`. Colored
126
+ sibling themes created with `extend()` only need the accent and tinted-surface
127
+ chain; flagging the rest cuts the token set each theme emits dramatically.
128
+
129
+ ## Upgrading Glaze
130
+
131
+ ### 3.0 — shadows and glows
132
+
133
+ `shadow` was rebuilt so `intensity` produces the same visible change on every
134
+ surface, and `glow` was added as its mirror. Both emit a translucent pigment
135
+ whose opacity is solved, per surface and per scheme, so the composite lands an
136
+ exact **tone step** away from `bg`: darker for `shadow`, lighter for `glow`.
137
+ See [Shadows and glows](./shadows-and-glows.mdx).
138
+
139
+ What changed:
140
+
141
+ - **`intensity` is a tone step.** In 2.x it went through a `tanh` curve in
142
+ OKHSL lightness, so the same number darkened white by 9 tones, a surface
143
+ rendered at tone 35 by 13.9, and one rendered at tone 6 by 4.4. Now
144
+ `intensity: 10` is 10 tones on every surface with 10 tones of room. A
145
+ step past black (or white, for a glow) is pinned to the strongest composite
146
+ the pigment reaches, and Glaze warns; see
147
+ [Unreachable steps](./shadows-and-glows.mdx#unreachable-steps).
148
+ - **`fg` is the object, not a contrast reference.** In 2.x, strength scaled
149
+ with `|l_bg − l_fg|` and the docs pointed `fg` at `text`, which ran opposite
150
+ to the physics: a white card on a light surface got almost no shadow. Now
151
+ `fg` is the element casting the shadow; a darker object deepens it, a lighter
152
+ one softens it, and an object at the surface's tone (or no `fg`) gives
153
+ exactly `intensity`.
154
+ - **The pigment is neutral by default**: pure black for `shadow`, pure white
155
+ for `glow`. The surface keeps its hue and the output is clean: `intensity: 10`
156
+ on a white surface emits `rgb(0 0 0 / 0.1326)`, which composites to tone 90.
157
+ - **The `ShadowTuning` fields were replaced.** `saturationFactor`,
158
+ `maxSaturation`, `lightnessFactor`, `lightnessBounds`, `minGapTarget`,
159
+ `alphaMax`, and `bgHueBlend` are gone. The new knobs are `objectInfluence`,
160
+ `tint`, `reach`, and `hueBleed`, shared by `shadowTuning` and the new
161
+ `glowTuning`. The type is now `LightingTuning`, and `ShadowTuning` is an
162
+ alias of it. The new `GlowTuning` is its own interface: `LightingTuning`
163
+ plus `headroom`, which a shadow's tuning rejects.
164
+ - **`GLAZE_EXPORT_VERSION` is 2.** A version-1 theme or palette snapshot that
165
+ contains shadow colors or a `shadowTuning` now throws on restore instead of
166
+ silently re-rendering every shadow.
167
+ - **`ColorDef` has a fourth member, `GlowColorDef`.** Exhaustive `switch`es
168
+ over `def.type` need a `'glow'` branch.
169
+
170
+ How 2.x shadows map onto 3.0 (2.x steps measured with browser compositing;
171
+ tones are where the surface renders, so under the default light window a
172
+ `tone: 10` surface, rendered at 14.5, stepped 10.0):
173
+
174
+ | 2.x definition | 2.x step for `intensity: 10` | 3.0 equivalent |
175
+ | --- | --- | --- |
176
+ | No `fg`, light surface (tone 97–100) | ≈ 9 tones | `intensity: 9`, or keep `10` (a tone stronger) |
177
+ | No `fg`, mid surface (tone 50) | ≈ 13.6 tones | `intensity: 13.6`, or settle on one value for all surfaces |
178
+ | No `fg`, dark surface (tone 10) | ≈ 7.6 tones, and saturating | `intensity: 7.6`; dark shadows were weaker than authored and now aren't |
179
+ | `fg: 'text'` on a light surface | ≈ 5.5–8 tones, by the text's tone (7.8 for near-black text, 5.6 for `'AAA'` text on a tone-95 surface) | Drop `fg` and use the step your text gave (`intensity: 8` for near-black text), or point `fg` at the element and re-tune |
180
+ | `fg` = a near-white card on light | ≈ 0.3 tones (barely visible) | `fg: 'card'`, then pick `intensity` for the look you want |
181
+
182
+ Then:
183
+
184
+ 1. Replace `fg: 'text'` (or any contrast-reference `fg`) with either no `fg` or
185
+ the element that casts the shadow.
186
+ 2. Pick `intensity` as the number of tones you want. For a ladder, `4` / `8` /
187
+ `12` reads as evenly spaced on every surface with room for the deepest step.
188
+ Check the dark schemes: a white `auto` page sits at tone 9.25 in dark and at
189
+ tone 0 in dark high contrast. Shadows on it deeper than about `8`–`9` (a
190
+ saturated page has a little less room) pin to black and warn in dark, and
191
+ every shadow on it stays transparent and warns in dark high contrast. Use
192
+ glows for dark elevation, on a surface that also leaves them room in light
193
+ ([Dark-mode elevation](./shadows-and-glows.mdx#dark-mode-elevation)). Leaving
194
+ a shadow token out of the dark schemes hides the pinned result but not the
195
+ warning: every color resolves in all four schemes.
196
+ 3. Delete the old fields inside `tuning` / `shadowTuning` (`saturationFactor`,
197
+ `alphaMax`, …); TypeScript flags them. A tinted pigment is
198
+ `tuning: { tint: 0.3, reach: 0.85 }`. There is no opacity cap: lower
199
+ `intensity` for a lighter overlay.
200
+ 4. Replace hand-tuned translucent white mixes (dark-mode elevation, edge
201
+ highlights, lightening state layers) with
202
+ `{ type: 'glow', bg, intensity }`. Direction is fixed per type, so a
203
+ `shadow` darkens and a `glow` lightens in light and dark alike. A glow on a
204
+ white light-mode surface has nothing to lighten and warns, unless it has
205
+ HDR headroom (below).
206
+ 5. Re-export snapshots. A 2.x snapshot with shadows or a `shadowTuning` throws
207
+ on restore, so re-author it. In code, rebuild the theme with 3.0 shadow defs
208
+ and call `export()`. In the JSON, fix the shadow defs, drop
209
+ `config.shadowTuning`, and set `version` to `2` (a palette snapshot has one at
210
+ the top and one per theme), then load it and export again. A snapshot
211
+ without shadows passes the version check and restores, but it resolves with
212
+ the other 3.0 changes on this page, and one that holds a value 3.0 rejects
213
+ throws, on its first output or (for a token's color value) when restored
214
+ (see [stricter input validation](#30--stricter-input-validation)).
215
+
216
+ `glaze.shadow()` keeps its signature with the new semantics, and `glaze.glow()`
217
+ takes the same input. See
218
+ [`glaze.shadow()` / `glaze.glow()`](./reference/utilities.md#glazeshadowinput--glazeglowinput).
219
+
220
+ HDR glows are new in 3.0 and opt-in, so they need no migration. A glow
221
+ variant gets an `hdr` value only with a `headroom` above 0
222
+ (`glowTuning.headroom`, or a glow's own `tuning.headroom`; the default is 0),
223
+ and exports carry it only with `modes.hdr` (default `false`), or for `css()`
224
+ its `hdr` option. At the defaults nothing changes. See
225
+ [HDR glows](./shadows-and-glows.mdx#hdr-glows) and
226
+ [HDR output](./exporting.mdx#hdr-output).
227
+
228
+ ### 3.0 — even dark steps for tone deltas
229
+
230
+ In 2.x an `auto` tone delta's dark variant stepped from the base's light tone.
231
+ That tone carries the light window's lift, and on a contrast-solved base or a
232
+ mix it sits wherever light put it, so dark steps came out uneven: on a tone-50
233
+ base, `'+4'` stepped −5.6 in dark and `'-4'` +1.3, and in `glaze(280, 40)` a
234
+ `'-4'` hover on an `'AAA'` button stepped darker in dark as well (−5.5).
235
+
236
+ In 3.0 a dark delta steps from where its base sits on the authored scale: the
237
+ base's authored tone, or, for a `fixed` or `static` base, an `auto`
238
+ contrast-solved base, a mix, or an `auto` `'max'` / `'min'` on a base, the
239
+ base's own dark tone read back through the dark window. A dark delta then
240
+ lands where the same authored tone would, on every base, along chains of
241
+ deltas, and for `from` colors. At the default dark window that is about 0.87×
242
+ the delta: `'+4'` steps −3.5, `'-4'` +3.5, and the `'AAA'` hover above +3.5.
243
+ Under a custom dark `eps` the steps follow that window's curve instead of a
244
+ fixed scale. On a `fixed` or `static` base the `auto` dependent still inverts
245
+ on its own, mirrored around wherever the base sits. See
246
+ [How relative tone adapts](./schemes.mdx#how-relative-tone-adapts).
247
+
248
+ What moves:
249
+
250
+ - **Dark variants** of `auto` tone-delta colors, and anything solved, mixed,
251
+ or lit from them in dark: at the default light window, by up to about
252
+ 4 tones on the lowest bases, about 2 on a tone-50 base, and a fraction of a
253
+ tone on a light surface. Deltas on a contrast-solved, mixed, or extreme base
254
+ move more (the `'AAA'` hover above moves 9 tones), and so do deltas on a
255
+ base past the dark window or under a custom light window: the move grows
256
+ with how far the window lifts the base, so `lightTone: [15, 100]` moves a
257
+ tone-50 base's deltas about 4 tones and up to 8 at the bottom, and a `hi`
258
+ below 100 moves a white surface's about 0.7 tones per tone it drops (about
259
+ 3.5 at `hi` 95). A custom light `eps` moves them too. A contrast-solved delta whose 2.x dark step
260
+ crossed its base now lands on the side that mirrors light, which can move
261
+ it most of the scale: in `glaze(0, 0)`,
262
+ `{ base: 'fill', tone: '-1', contrast: 3 }` on a tone-50 fill goes from
263
+ 16.2 to 89.0 in dark.
264
+ - **`auto` deltas on a `fixed` or `static` base**, in dark and dark high
265
+ contrast. 2.x reflected them across the whole scale, so how far one landed
266
+ from its base depended on the base's tone. They now mirror around the base:
267
+ in `glaze(280, 30)`, an `auto` `'+30'` label on a `fixed` tone-52 fill goes
268
+ from 31.5 to 26.0 tones below it in dark (34 to 30 in dark high contrast),
269
+ and a `'-4'` hover on `{ base: 'surface', tone: '-10', mode: 'fixed' }`
270
+ over a tone-97 surface goes from 22.0 to 3.5 tones above it.
271
+ - **High-contrast variants**, only for deltas on contrast-solved, mixed,
272
+ extreme, `fixed`, or `static` bases, or under a custom light `eps`: at the
273
+ default dark `eps`, a high-contrast dark step is now exactly the delta,
274
+ short of the limits below. `contrastLevel: 100` still equals the
275
+ high-contrast tier.
276
+ - **`glaze.color()` links** whose base token has its own `darkTone`, is a
277
+ value-form token with its own `lightTone`, or is contrast-solved or an
278
+ `auto` `'max'` / `'min'` on a base. They now step like any other link in
279
+ dark, and a `'+0'` link lands on its base there: in 2.x a `'+0'` link on an
280
+ `'AAA'` token over `#f7f7fb` sat 8.95 tones below it in dark. Links on
281
+ other `auto` bases already stepped this way; links on a `fixed` or `static`
282
+ base move as described for those bases above.
283
+ - **Other light variants** only through a float-noise tie: a contrast-solved
284
+ color whose preferred tone lands within 1e-9 tones of its base's (a `'+0'`
285
+ / `'-0'` delta, or an absolute tone equal to the base's) takes the solver's
286
+ own tie rule instead of a side picked by float noise, in every scheme, so
287
+ it can land on the other side of its base. Under a manual `contrastLevel`,
288
+ a level probe that lands on its base pins no side either.
289
+
290
+ Two limits apply. The flip is still decided on the light tone, so a step
291
+ that fits in light can run past 0 or 100 from the anchor and stop at the dark
292
+ window's edge. On an `auto` base placed by a tone that happens at the bottom,
293
+ where the light window lifts the light tone: `'-4'` on tone 2 steps about
294
+ +1.7 in dark, and on tone 0 it doesn't move. On a base anchored at its own
295
+ dark tone it can happen at either end, in high contrast too: in
296
+ `glaze(280, 40)`, a `'-4'` hover on `contrast: 12` text over a tone-97
297
+ surface steps +2.3 in dark, not +3.5. A base sitting past the dark window
298
+ (pushed there by a contrast floor or an extreme, or placed there as a
299
+ `fixed` or `static` color) is stepped from where it sits: a step back toward
300
+ the window moves the full scaled delta, and one pointing further out stops
301
+ at the base.
302
+ Re-check dark values you have pinned in tests or snapshots.
303
+
304
+ ### 3.0 — other changes to resolved colors
305
+
306
+ These fixes move colors that 2.x resolved from the same input. Re-check values
307
+ you have pinned:
308
+
309
+ - **Contrast-solved colors.** The solver keeps its 1% (WCAG) / 0.5 Lc (APCA)
310
+ margin and lands on the side it reports. Saturated hues that read darker
311
+ than their gray tone (blues, violets, reds, oranges) land on their own
312
+ crossing instead of stopping at the gray seed: an `'AA'` text at hue 280 and
313
+ saturation 100 on a light gray surface goes from 5.03:1 to 4.55:1, 2.8 tones
314
+ nearer its authored tone. A contrast-solved color with no tone of its own
315
+ on a mid-tone base, where both sides meet the floor at the same distance,
316
+ now keeps the side it searches first instead of a side picked by search
317
+ noise. It starts toward the extreme that scores higher, and darker on a
318
+ gray base at tone 50, so it can land on the other side of its base: in
319
+ `glaze(0, 0)`, `{ base: 'b', contrast: 3 }` goes from 11.3 to 84.1 on a
320
+ tone-45 base and from 93.6 to 20.8 on a tone-55 one. Apart from those side
321
+ changes, most colors move less than half a tone, a few saturated ones up to
322
+ about 5.
323
+ - **Standalone `glaze.color()` tokens** default to the `'text'` role; 2.x
324
+ resolved a token without a `base` as a surface. `name` no longer drives role
325
+ inference. An APCA floor on a token without `role` can land elsewhere:
326
+ `glaze.color({ from: '#ffffff', contrast: { apca: 60 } })` now gives
327
+ `rgb(141.23 141.23 141.23)`, not `rgb(151.87 151.87 151.87)`. Set
328
+ `role: 'surface'` to keep a fill's 2.x polarity. WCAG floors don't change.
329
+ A relative high-contrast tone on a token (`tone: [50, '+20']`) is measured
330
+ from the token's own color; 2.x read `'+20'` as tone 20.
331
+ - **Value-form `glaze.color()` links on a structured base**
332
+ (`glaze.color({ from, base })` with `base` made by
333
+ `glaze.color({ hue, saturation, tone })`), in light, and in dark where the
334
+ painted light tone changes which way `autoFlip` sends a step. 2.x read such
335
+ a base at its raw input tone in light, not at the tone it renders, so the
336
+ link measured against a color that is never painted: a `'+0'` link on
337
+ `glaze.color({ hue: 280, saturation: 80, tone: 50 })` sat 2.5 tones below
338
+ it, and an `'AA'` link measured 4.16:1 against it, with no warning. A
339
+ `'+9.8'` link on a tone-90 structured base, which fit under 100 at the raw
340
+ tone, now flips in light, and so lands elsewhere in dark too. Links now
341
+ resolve against what the base paints in every scheme.
342
+ - **Transparent mixes with `contrast`** solve against browser compositing
343
+ (`source-over` on gamma-encoded sRGB) instead of linear light. A white
344
+ `'AA'` overlay on a surface rendered at tone 12
345
+ (`{ tone: 12, mode: 'static' }`) goes from alpha 0.26, which rendered at
346
+ 2.3:1, to 0.48; a black overlay with a 1.2:1 floor on a tone-97 surface goes
347
+ from 0.18 to 0.09.
348
+ - **`glaze(seed, config)`** applies the config. 2.x read the object form's
349
+ override only from a third argument, so the documented two-argument call
350
+ dropped it. `glaze(seed, undefined, config)` still works but is deprecated.
351
+
352
+ ### 3.0 — stricter input validation
353
+
354
+ 3.0 throws a `glaze:` error for input that 2.x resolved, usually into wrong or
355
+ `NaN` colors:
356
+
357
+ | Input | 2.x |
358
+ | --- | --- |
359
+ | A tone window with `lo > hi` (`lightTone: [90, 20]`) | Inverted the scale |
360
+ | A window endpoint that isn't a finite number (`NaN`, `Infinity`, `'10'`) | `NaN` colors, or a string read as a number |
361
+ | An object window whose `eps` is missing, not above 0, or above `1e6` | The default `eps` when missing; `NaN` colors at 0 or below and from about `1e15` |
362
+ | A window that isn't `[lo, hi]`, `{ lo, hi, eps }`, or `false` (`50`, `[10]`, `true`, `null`) | `NaN` colors; `configure()` ignored `null`, and a theme or token override with `null` threw a `TypeError` when it resolved |
363
+ | A `darkDesaturation` that isn't a finite number (`NaN`, `Infinity`, `'0.5'`, `true`) | `NaN` dark colors (`NaN`), fully gray ones (`Infinity`, `true`), or a string read as a number |
364
+ | A relative tone in the high-contrast entry of a root color (`tone: [50, '+20']`, no `base`) | Read `'+20'` as tone 20. Now throws: add a `base`, or write the tone you got (`[50, 20]`) |
365
+ | A hex color with a non-hex digit (`'#1z2z3z'`) in `glaze.color()`, `glaze.fromHex()`, a color's `from`, or the `bg` / `fg` of `glaze.shadow()` | Read only the first digit of each pair (`#010203`) |
366
+ | A color-function component that isn't a number (`'hsl(abc 50% 50%)'`, `'rgb(Infinity 0 0)'`) | `NaN` colors, or a silent gray |
367
+ | A value object with a negative `s`, `l`, `t`, or `c` (`{ l: 0.5, c: -0.05, h: 30 }`) | A plausible color: a negative chroma turned the hue around |
368
+ | A malformed `contrast`: a misspelled preset (`'aa'`, `{ apca: 'Body' }`), `NaN`, `{}`, both `wcag` and `apca`, or a pair without two entries | A `TypeError` from the warning code, or a color pinned to black or white; both keys used APCA, and a longer pair its first two entries |
369
+ | A color field that isn't a finite number (`tone: NaN`, `saturation: NaN`), a relative string that isn't `'+N'` / `'-N'` (`hue: 'abc'`, `tone: '+-5'`, `tone: '+5px'`), an `opacity` outside 0–1, or a non-finite mix `value` or shadow `intensity` | `NaN` colors, or an alpha outside 0–1; a trailing unit was read past (`'+5px'` as `'+5'`) |
370
+ | A theme seed whose hue or saturation isn't a finite number (`glaze({ hue: 280 })` without `saturation`, `glaze.fromRgb(NaN, 0, 0)`) | `NaN` colors |
371
+ | `null` for `contrastLevel` or `darkDesaturation` | Ignored: the current value stayed |
372
+
373
+ ```text
374
+ glaze: lightTone lo (90) is above hi (20).
375
+ A window runs from its dark end to its light end: [lo, hi] with lo ≤ hi,
376
+ e.g. [20, 90].
377
+
378
+ glaze: color "a" has relative "tone" without "base".
379
+
380
+ glaze: invalid hex color "#1z2z3z".
381
+
382
+ glaze: color "text" has an invalid "contrast" "aa". Use a WCAG ratio or
383
+ 'AA' / 'AAA' / 'AA-large' / 'AAA-large', { wcag: … }, { apca: … }, or a
384
+ [normal, highContrast] pair of these.
385
+ ```
386
+
387
+ `configure()` throws at the call and leaves the config as it was. A theme or
388
+ token override (`glaze(hue, saturation, config)`, `glaze.color(value, config)`,
389
+ `extend({ config })`) is checked when it resolves, so it throws on the first
390
+ output or `resolve()`, and so are a theme's colors. A theme or palette
391
+ snapshot that holds such a value still restores with `glaze.themeFrom()` /
392
+ `paletteFrom()` and throws on its first output, and so does a token snapshot
393
+ whose frozen config holds one. A token snapshot whose color value (its input,
394
+ or a raw `base`) 3.0 rejects throws in `glaze.colorFrom()` itself, as
395
+ `glaze.color()` does, and so does a theme snapshot whose seed does. Fix the
396
+ value in the JSON and export again.
397
+
398
+ The exported `parseHex()` / `parseHexAlpha()` return `null` for such hex, as
399
+ their type always allowed; 2.x read the first digit of each pair, and
400
+ `'#-1-2-3'` gave negative channels. Check for `null` before using the result.
401
+
402
+ Color strings also change in two ways that move colors instead of throwing. A
403
+ hue in `turn`, `rad`, or `grad` is converted (2.x read `hsl(0.5turn 50% 50%)`
404
+ as hue 0.5°, not 180°), and the CSS keyword `none` reads as 0. Out-of-range
405
+ color-function values clamp as CSS clamps them, which moves an `rgb()` channel
406
+ outside 0–255, an `okhsl()` / `okhst()` saturation outside 0–100%, a negative
407
+ `okhsl()` lightness (2.x gave `NaN` or a wrong tone), a negative `oklch()`
408
+ chroma (2.x turned its hue around), and an `oklch()` lightness below about
409
+ −0.37 (2.x emitted `NaN`). A saturation past 100% moves a token in dark, and
410
+ one outside 0–100% moves a theme color's `from` in every scheme: 2.x painted
411
+ its light variant out of gamut, which could turn the hue
412
+ (`'okhsl(200 -20% 50%)'` came out reddish), and colors solved, mixed, or lit
413
+ from it move with it. An `hsl()` or
414
+ `oklch()` lightness past its range already rendered clamped. A value object's
415
+ 0–1 field between 1 and 1.5 clamps to 1 too, which moves a saturation there
416
+ the same way.
417
+
418
+ Two out-of-range values clamp instead, which can move output: window endpoints
419
+ clamp to 0–100 (2.x extended a `[-10, 120]` window past the range), and
420
+ `darkDesaturation` clamps to 0–1 (2.x let `-0.5` raise dark saturation). See
421
+ [Validation](./reference/configuration.md#validation).
422
+
423
+ ### 3.0 — output options
424
+
425
+ Options an output method accepted but never read are gone from its type, so
426
+ TypeScript flags them. Delete them; the output doesn't change.
427
+
428
+ - `palette.json()` takes `GlazeJsonOptions` only: no `prefix`.
429
+ - `splitHue` is gone from `palette.tokens()`, `dtcg()`, `dtcgResolver()`, and
430
+ `tailwind()` (it left `GlazePaletteExportOptions`), and from `token.token()` /
431
+ `token.tasty()`.
432
+ - `theme.tasty()` takes the new `GlazeTastyOptions`, without `prefix`.
433
+ `GlazeTokenOptions` is now just `format`, `modes`, and `states`, as taken by
434
+ `token.token()` / `token.tasty()`.
435
+ - `palette.tasty()` and `palette.css()` take the new
436
+ `GlazePaletteTastyOptions` / `GlazePaletteCssOptions`, without `name`: their
437
+ hue vars are always named after each theme.
438
+
439
+ `splitHue` also stops failing silently. With a `format` other than `'oklch'`
440
+ it now throws instead of emitting inline colors, and a color that sets its own
441
+ hue under the theme hue var's name (a `brand` color with `name: 'brand'`, or a
442
+ color named after another theme in an unprefixed palette) throws instead of
443
+ rendering at the theme's hue, unless it is achromatic in light. In `css()`,
444
+ a color's value property that lands on a hue var (`suffix: '-hue'`, or
445
+ `suffix: ''` with a color named `*-hue`) throws the same way instead of
446
+ emitting a `var()` cycle. Hue values in its
447
+ declarations are rounded to 2 decimals, so a `from` color emits
448
+ `--logo-hue: 266.16` rather than `266.15797905637027`, and a color achromatic
449
+ in light no longer emits a dead `--*-hue` declaration in dark. See
450
+ [`splitHue`](./reference/output.md#hue-channel-splitting-splithue).
451
+
452
+ ### 3.0 — contrast solver utilities
453
+
454
+ For code that calls the solver directly:
455
+
456
+ - `findValueForMixContrast()` no longer takes `targetLinearRgb`. It was
457
+ required in 2.x but never read: `luminanceAtValue` describes the mix. Delete
458
+ it from the options object; results don't change. TypeScript flags it as an
459
+ excess property and suggests `baseLinearRgb`, but the fix is to delete it,
460
+ not rename it.
461
+ - `findToneForContrast()` returns `branch: 'preferred'`, met, for a preferred
462
+ tone that clears the floor but not the 1% / 0.5 Lc margin whenever the
463
+ search can't improve on it: no searched side meets the floor, or the
464
+ starting side's only position is the preferred tone (it sits on that side's
465
+ bound). 2.x labelled it with the side it had searched, which could name a
466
+ side of the base it doesn't sit on. A WCAG search that started away from it
467
+ lost it to the far extreme: white at 7.24:1 against a tone-35 gray with a
468
+ 7.2:1 floor came back as black at 2.9:1, unmet. With no room to search
469
+ (`toneRange`), it came back `met: false`.
470
+ - Results move with the solver fixes above. The WCAG gray seed is only the
471
+ first probe, so the [`findToneForContrast`
472
+ example](./reference/utilities.md#findtoneforcontrastoptions) now returns
473
+ tone 0.4846 at 4.55:1, not 0.4759 at 4.67:1. With no `initialDirection`, a
474
+ tie between the two ends' scores starts darker.
475
+
476
+ ### 2.0 — `format*` takes 0–1
477
+
478
+ The `format*` writers (`formatOkhsl`, `formatOkhst`, `formatRgb`, `formatHsl`,
479
+ `formatOklch`) used to take `s` / `l` / `t` on a 0–100 percentage scale, while
480
+ everything that _produces_ those values (`resolve()`, `variantToOkhsl`,
481
+ `srgbToOkhsl`, `oklabToOkhsl`, `okhslToSrgb`) returns them on 0–1. Composing
482
+ the two, which is the obvious thing to do, was off by 100x and failed
483
+ silently: `0.7` is a legal percentage, so you got a valid CSS string naming the
484
+ wrong (near-black) color.
485
+
486
+ The writers now take the 0–1 factors, so the whole library speaks one scale.
487
+ Drop the `* 100`:
488
+
489
+ ```diff
490
+ - formatOkhsl(v.h, v.s * 100, l * 100);
491
+ + formatOkhsl(v.h, v.s, l);
492
+
493
+ - formatOkhst(v.h, v.s * 100, v.t * 100);
494
+ + formatOkhst(v.h, v.s, v.t);
495
+ ```
496
+
497
+ Nothing else moves: `h` was always 0–360, `alpha` was always 0–1, and every
498
+ export method (`css()`, `tokens()`, `json()`, `tasty()`, `dtcg()`,
499
+ `tailwind()`, `glaze.format()`) emits the same colors, because they were
500
+ compensating internally. Dropping the redundant `×100 ÷100` round-trip shifts
501
+ float noise by an ULP, which shows up nowhere except the (meaningless) hue term
502
+ of a fully desaturated `hsl()` string. `toTone` / `fromTone` still speak the
503
+ 0–100 tone axis the authoring API takes, so divide a tone from them by 100
504
+ before passing it to `formatOkhst`.
505
+
506
+ A leftover `* 100` is no longer silent: a value above 1 cannot be a factor, so
507
+ the writers `console.warn` once per writer, and you get an obviously broken
508
+ string such as `okhsl(280 7040.68% 5000%)` instead of a plausible wrong color.
509
+ See [format writers](./reference/utilities.md#format-writers).
510
+
511
+ ### 0.14 — `lightness` became `tone`
512
+
513
+ Colors used to be authored on OKHSL lightness. They are now authored on
514
+ **tone**, a contrast-uniform 0–100 axis (see [Tone and OKHST](./okhst.mdx)):
515
+
516
+ - The `lightness` prop is gone everywhere (theme colors, `glaze.color()`
517
+ structured input, tone deltas); use `tone`. Equal tone steps give equal
518
+ WCAG contrast, so numeric values don't map to the same OKHSL lightness as
519
+ before. Re-check absolute mid-range values.
520
+ - The config windows `lightLightness` / `darkLightness` became `lightTone` /
521
+ `darkTone`, and `darkCurve` was removed.
522
+ - `ResolvedColorVariant` stores `{ h, s, t, alpha }` instead of `{ h, s, l }`.
523
+ Use `variantToOkhsl()` to recover OKHSL lightness.
524
+ - Tone deltas that overshoot `[0, 100]` mirror to the other side of the base
525
+ by default instead of clamping. Set `autoFlip: false` on the color
526
+ (or globally) to clamp.
527
+
528
+ ## Common pitfalls
529
+
530
+ | Symptom | Cause | Fix |
531
+ | --- | --- | --- |
532
+ | A disabled state stops looking disabled in dark mode. | An alpha-tinted overlay on `surface-text` (which inverts) gives asymmetric perceived contrast. | Replace it with an adaptive color anchored to `surface`: a tone delta for visual spacing, or a contrast floor when one is required. See [chips and disabled states](./methodology.mdx#chips-and-disabled-states). |
533
+ | A brand fill turns dark in dark mode and stops reading as the brand. | The default `mode: 'auto'` inverts the tone. | Set `mode: 'fixed'` so the tone is remapped into the dark window, not inverted. See [adaptation modes](./schemes.mdx#adaptation-modes). |
534
+ | Brand text washes out against the dark surface. | The foreground was anchored to `accent-surface` (the brand fill), so contrast was enforced only against that fill, not against the surface it sits on. | Anchor `accent-text` and friends to `surface` with `mode: 'auto'`. |
535
+ | Tokens look right in light but broken in high contrast. | High contrast bypasses the tone window, so absolute tones and deltas land on the full `[0, 100]` range (a white `auto` page is black in dark high contrast), and floors without an explicit high-contrast value rise a tier (`'AA'` → `'AAA'`, APCA +15 Lc). | Add explicit `[normal, highContrast]` pairs to `tone` / `contrast` for the affected tokens. |
536
+ | A tone delta like `'+48'` lands on the _wrong_ (darker) side of its base. | Overshooting tone deltas mirror to the other side of the base by default (a color's `autoFlip` defaults to the global `autoFlip`, which is on). | Set `autoFlip: false` on the color to clamp to the boundary instead, or use `tone: 'max'` / `'min'` to force the extreme. |
537
+ | `palette.tokens()` emits unexpected unprefixed names. | A `primary` was set on the palette (or per call) and duplicates that theme's tokens without a prefix. | Pass `primary: false` to disable it for that export, or change `glaze.palette(themes, { primary })`. See [the `primary` alias](./exporting.mdx#the-primary-alias). |
538
+ | `glaze: token "surface" from theme "danger" collides with theme "default" — skipping.` | Two themes resolved to the same output name under your prefix config. | Adjust the prefix map so each name is unique, or accept first-write-wins. See [Collisions](./exporting.mdx#collisions). |
539
+ | `glaze: formatOkhsl() got a value above 1 …` | Pre-2.0 percentage-scale input to a `format*` writer (a leftover `* 100`). | Pass the 0–1 factors the converters return; see [2.0 — `format*` takes 0–1](#20--format-takes-01). |
540
+ | `glaze: color "X" cannot meet WCAG … in light scheme (got …)` | The contrast target is physically unreachable for the color's hue and saturation against its base. The color pins to the extreme of the side it searched first, which may not be the closer one; see [When a floor can't be met](./contrast.mdx#when-a-floor-cant-be-met). | Lower the floor or change the base. If only the high-contrast schemes fail, give `contrast` an explicit, reachable high-contrast entry (`['AA', 'AA']`). On standalone colors, set `name` so the warning is identifiable; see [`name`](./reference/color-tokens.md#name). |
541
+ | `glaze: mix "X" cannot meet WCAG … against its base in light scheme (got …)` | Even the pure target doesn't reach the floor against the mix's `base`. The mix pins to the pure target, or to the pure base when its `value` is already 100; see [Contrast on mixes](./mixes.mdx#contrast-on-mixes). | Mix toward a target further from the base, or lower the floor. If only the high-contrast schemes fail, give `contrast` an explicit, reachable high-contrast entry. Keep `value` below 100 when you set a floor. |
542
+ | `glaze: shadow "X" cannot reach a 10.0-tone step …` (or `glow`) | The surface has fewer tones of room than `intensity` asks for: a glow on white, a deep shadow on near-black, or any shadow on a light `auto` page in dark high contrast (at or near tone 0 there). The overlay is pinned to its strongest composite (transparent when the surface is already at the pigment's extreme). | Lower `intensity` or give the overlay a surface with room in every scheme, and use glows for dark elevation. Otherwise expect the warning: every color resolves in all four schemes, so not using the token in a scheme doesn't silence it. A glow with `headroom` gets an HDR value past white instead and warns only when the cap leaves the step short (`… even with 1 stop of headroom (reached …)`): lower `intensity` or raise `headroom`. See [Unreachable steps](./shadows-and-glows.mdx#unreachable-steps). |
543
+ | `glaze.themeFrom: this snapshot is export version 1 (Glaze 1.1–2) …` | A 2.x snapshot with shadow colors or `shadowTuning`; shadows changed meaning in 3.0. | Re-author the shadows and export again; see [3.0 — shadows and glows](#30--shadows-and-glows). |