@tenphi/glaze 1.4.0 → 2.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 +1 -1
- package/dist/index.cjs +104 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -21
- package/dist/index.d.mts +29 -21
- package/dist/index.mjs +104 -47
- package/dist/index.mjs.map +1 -1
- package/docs/api.md +96 -44
- package/docs/methodology.md +15 -13
- package/docs/migration.md +36 -0
- package/docs/okhst.md +4 -0
- package/package.json +1 -1
package/docs/api.md
CHANGED
|
@@ -411,9 +411,9 @@ promotion for that color.
|
|
|
411
411
|
|
|
412
412
|
## Manual contrast level
|
|
413
413
|
|
|
414
|
-
`contrastLevel`
|
|
415
|
-
It is a config field, so it works globally, per theme, per token, and
|
|
416
|
-
`extend()`:
|
|
414
|
+
`contrastLevel` puts the normal end of the two-tier contrast model on a `0–100`
|
|
415
|
+
slider. It is a config field, so it works globally, per theme, per token, and
|
|
416
|
+
through `extend()`:
|
|
417
417
|
|
|
418
418
|
```ts
|
|
419
419
|
glaze.configure({ contrastLevel: 60 });
|
|
@@ -421,12 +421,17 @@ const theme = glaze(280, 80, { contrastLevel: 60 });
|
|
|
421
421
|
glaze.color('#26fcb2', { contrastLevel: 60 });
|
|
422
422
|
```
|
|
423
423
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
|
424
|
+
The level moves the **normal** variants — `light` and `dark` — along that slider.
|
|
425
|
+
It says nothing about high contrast: `lightContrast` / `darkContrast` stay the
|
|
426
|
+
true high-contrast resolution at every level, and
|
|
427
|
+
[`modes.highContrast`](#output-modes) alone decides whether they are emitted.
|
|
428
|
+
|
|
429
|
+
| Value | Meaning |
|
|
430
|
+
| ---------------- | -------------------------------------------------------------------------- |
|
|
431
|
+
| `'auto'` | Default. The normal variants take the authored normal entries as-is. |
|
|
432
|
+
| `0` | The same thing, reached through the slider — output-identical to `'auto'`. |
|
|
433
|
+
| `100` | The normal variants *are* the high-contrast ones, so the tier is dropped. |
|
|
434
|
+
| anything between | The normal variants are resolved *at* that level. |
|
|
430
435
|
|
|
431
436
|
Levels `0` and `100` reproduce the classic `light` / `dark` and
|
|
432
437
|
`lightContrast` / `darkContrast` output **bit for bit**.
|
|
@@ -446,6 +451,9 @@ The interpolated values are then fed through the ordinary resolve, so a
|
|
|
446
451
|
contrast floor at any level is **solved**, not approximated, and `autoFlip`
|
|
447
452
|
decides once per level.
|
|
448
453
|
|
|
454
|
+
These feed the two **normal** passes only. The high-contrast passes bypass the
|
|
455
|
+
level entirely, so the tier resolves exactly as it does in `'auto'` mode.
|
|
456
|
+
|
|
449
457
|
Everything that does not vary by high contrast today — hue, saturation,
|
|
450
458
|
`darkDesaturation`, `opacity`, `pastel` — is unaffected by the level.
|
|
451
459
|
|
|
@@ -495,24 +503,35 @@ directly.
|
|
|
495
503
|
|
|
496
504
|
### High-contrast output
|
|
497
505
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
`highContrast: true` set in a build config while a user switches their
|
|
508
|
-
preference from auto to manual is fine, and silent.
|
|
506
|
+
The level and the high-contrast tier are independent, and they compose: the
|
|
507
|
+
slider raises the baseline, and a `prefers-contrast: more` block still escalates
|
|
508
|
+
on top of whatever baseline the user has chosen.
|
|
509
|
+
|
|
510
|
+
- `resolve()` returns four variants at every level. `lightContrast` /
|
|
511
|
+
`darkContrast` are the **true** high-contrast resolution — bit-identical to
|
|
512
|
+
what `'auto'` resolves for those slots, at any level.
|
|
513
|
+
- [`modes.highContrast`](#output-modes) alone decides whether the tier is
|
|
514
|
+
emitted, exactly as in `'auto'` mode. A level does not turn it off.
|
|
509
515
|
- `css()` always returns four strings and ignores `modes`, so its
|
|
510
|
-
`lightContrast` / `darkContrast` strings
|
|
511
|
-
|
|
512
|
-
|
|
516
|
+
`lightContrast` / `darkContrast` strings now carry genuinely escalated values
|
|
517
|
+
at a mid level, where they previously repeated the normal declarations. An
|
|
518
|
+
existing `@media (prefers-contrast: more)` block starts doing real work.
|
|
513
519
|
- A level on a **single theme or token** does not change which modes are
|
|
514
|
-
emitted
|
|
515
|
-
the
|
|
520
|
+
emitted — `modes` is global-only, and a palette must not have one sibling
|
|
521
|
+
collapse the shared token structure.
|
|
522
|
+
|
|
523
|
+
| `contrastLevel` | `modes.highContrast: false` (default) | `modes.highContrast: true` |
|
|
524
|
+
| ----------------- | ------------------------------------- | ---------------------------------------- |
|
|
525
|
+
| `'auto'` / `0` | `light`, `dark` | + `lightContrast`, `darkContrast` |
|
|
526
|
+
| `1`–`99` | `light`, `dark` at the level | + the tier, unchanged by the level |
|
|
527
|
+
| `100` (global) | `light`, `dark` = the HC values | same — the tier is dropped as a duplicate |
|
|
528
|
+
|
|
529
|
+
That last row is the one exception. At level 100 the normal variants *are* the
|
|
530
|
+
high-contrast ones, so a separate tier would be an exact duplicate: a global
|
|
531
|
+
level of 100 emits a single light/dark set, and even an explicit
|
|
532
|
+
`modes: { highContrast: true }` on the call is suppressed, because it has nothing
|
|
533
|
+
different left to ask for. A level of 100 on a single theme or token still
|
|
534
|
+
reports into the tier, with values equal to its own normal ones.
|
|
516
535
|
|
|
517
536
|
### Driving it at runtime
|
|
518
537
|
|
|
@@ -526,8 +545,9 @@ slider.oninput = () => {
|
|
|
526
545
|
};
|
|
527
546
|
```
|
|
528
547
|
|
|
529
|
-
|
|
530
|
-
|
|
548
|
+
A manual resolve runs the same four passes as an `'auto'` one. Only level 100
|
|
549
|
+
skips the two high-contrast passes, because the normal ones already produced
|
|
550
|
+
those values.
|
|
531
551
|
|
|
532
552
|
### Clearing it, exporting it, base links
|
|
533
553
|
|
|
@@ -540,7 +560,9 @@ also half the work of an `'auto'` one.
|
|
|
540
560
|
matches how `modes` and `states` are treated.
|
|
541
561
|
- **Set the level globally, or on both sides of a base link.** A per-token level
|
|
542
562
|
on a dependent but not on its base anchors the two at different levels — the
|
|
543
|
-
same caveat as a per-instance `lightTone` override.
|
|
563
|
+
same caveat as a per-instance `lightTone` override. It is visible in the
|
|
564
|
+
high-contrast tier too, since a dependent's high-contrast variant reads its
|
|
565
|
+
base's high-contrast slots (and at level 100, the base's mirrored normal ones).
|
|
544
566
|
|
|
545
567
|
`resolveContrastForLevel(spec, level, polarity?)` is exported for advanced use;
|
|
546
568
|
see [Contrast solver](#contrast-solver).
|
|
@@ -1767,11 +1789,11 @@ boundaries, not the tone transfer.
|
|
|
1767
1789
|
| `states.dark` | `'@media(prefers-color-scheme: dark)'` | State alias for dark mode tokens ([Tasty](https://tasty.style) export). Defaults to a media query so tokens react to the OS preference without registering custom states. |
|
|
1768
1790
|
| `states.highContrast` | `'@media(prefers-contrast: more)'` | State alias for HC tokens ([Tasty](https://tasty.style) export). |
|
|
1769
1791
|
| `modes.dark` | `true` | Include dark variants in exports. |
|
|
1770
|
-
| `modes.highContrast` | `false` | Include HC variants.
|
|
1792
|
+
| `modes.highContrast` | `false` | Include HC variants. Independent of [`contrastLevel`](#manual-contrast-level) — the level positions the normal variants while these stay the true HC resolution. A global level of `100` is the exception: the tier would duplicate the normal set, so it is dropped. |
|
|
1771
1793
|
| `shadowTuning` | `undefined` | Default tuning for all shadow colors. Per-color tuning merges field-by-field. |
|
|
1772
1794
|
| `autoFlip` | `true` | Default for each color's `autoFlip`. When solving `contrast` (or applying a relative `tone` that overshoots `[0, 100]`), allow crossing to the opposite side instead of clamping. With `false`, only the requested direction is considered; unmet contrasts pin the tone to that direction's extreme (and emit a warning) and overshooting offsets clamp to the boundary. Override per color via [`autoFlip`](#autoflip). |
|
|
1773
1795
|
| `inferRole` | `true` | Infer each color's [`role`](#roles) from its name when no explicit `role` is set. Set to `false` to opt out of name-based inference (the base-opposite and foreground-default fallbacks still apply). |
|
|
1774
|
-
| `contrastLevel` | `'auto'` | Manual contrast level, `0`–`100`,
|
|
1796
|
+
| `contrastLevel` | `'auto'` | Manual contrast level, `0`–`100`, putting the **normal** variants on a slider between themselves and the high-contrast ones. `0` reproduces the normal output and `100` the high-contrast output, bit for bit. The HC tier is unaffected. See [Manual contrast level](#manual-contrast-level). |
|
|
1775
1797
|
|
|
1776
1798
|
| Method | Description |
|
|
1777
1799
|
| ------------------------- | ----------------------------------------------------------------------------------- |
|
|
@@ -1779,7 +1801,7 @@ boundaries, not the tone transfer.
|
|
|
1779
1801
|
| `glaze.getConfig()` | Snapshot the current resolved config (shallow copy). |
|
|
1780
1802
|
| `glaze.resetConfig()` | Reset to defaults (also bumps the version counter). |
|
|
1781
1803
|
|
|
1782
|
-
Themes and standalone color tokens keep a sparse local `GlazeConfigOverride` and merge the live global at resolve time for omitted fields. Authoring `.export(override?)` freezes the effective merge at call time; restored instances pin that freeze. `pastel` is instance-only (theme/token override or per-color) — not set via `configure()`. `contrastLevel` is the one field the freeze treats as a live preference: only an instance-authored level is written to the snapshot ([why](#
|
|
1804
|
+
Themes and standalone color tokens keep a sparse local `GlazeConfigOverride` and merge the live global at resolve time for omitted fields. Authoring `.export(override?)` freezes the effective merge at call time; restored instances pin that freeze. `pastel` is instance-only (theme/token override or per-color) — not set via `configure()`. `contrastLevel` is the one field the freeze treats as a live preference: only an instance-authored level is written to the snapshot ([why](#clearing-it-exporting-it-base-links)).
|
|
1783
1805
|
|
|
1784
1806
|
---
|
|
1785
1807
|
|
|
@@ -1801,9 +1823,10 @@ palette.tokens({ modes: { dark: true, highContrast: true } });
|
|
|
1801
1823
|
|
|
1802
1824
|
Resolution priority (highest first):
|
|
1803
1825
|
|
|
1804
|
-
1. A global [`contrastLevel`](#manual-contrast-level) — pins
|
|
1805
|
-
`highContrast: false`, since
|
|
1806
|
-
|
|
1826
|
+
1. A global [`contrastLevel`](#manual-contrast-level) of `100` — pins
|
|
1827
|
+
`highContrast: false`, since the normal variants already *are* the
|
|
1828
|
+
high-contrast ones and the tier would duplicate them. Any other level leaves
|
|
1829
|
+
`highContrast` alone.
|
|
1807
1830
|
2. Per-call `modes` option on `tokens` / `tasty` / `json`.
|
|
1808
1831
|
3. `glaze.configure({ modes })` — global config.
|
|
1809
1832
|
4. Built-in default: `{ dark: true, highContrast: false }`.
|
|
@@ -1873,7 +1896,7 @@ import {
|
|
|
1873
1896
|
| Function | Description |
|
|
1874
1897
|
| ------------------------------------- | ------------------------------------------------------------------------ |
|
|
1875
1898
|
| `okhslToLinearSrgb(h, s, l)` | OKHSL (h: 0–360, s/l: 0–1) → linear sRGB tuple. |
|
|
1876
|
-
| `okhslToSrgb(h, s, l)` | OKHSL → gamma-encoded sRGB tuple (0–1 per channel).
|
|
1899
|
+
| `okhslToSrgb(h, s, l)` | OKHSL (h: 0–360, s/l: 0–1) → gamma-encoded sRGB tuple (0–1 per channel). |
|
|
1877
1900
|
| `okhslToOklab([h, s, l])` | OKHSL → OKLab `[L, a, b]`. |
|
|
1878
1901
|
| `oklabToOkhsl([L, a, b])` | OKLab → OKHSL. |
|
|
1879
1902
|
| `srgbToOkhsl([r, g, b])` | Gamma sRGB (0–1) → OKHSL. |
|
|
@@ -1886,15 +1909,44 @@ import {
|
|
|
1886
1909
|
|
|
1887
1910
|
### Format writers
|
|
1888
1911
|
|
|
1912
|
+
Every writer takes `h` on 0–360 and `s` / `l` / `t` on **0–1** — the scale every
|
|
1913
|
+
conversion above *returns*, and the scale `resolve()` stores in a
|
|
1914
|
+
`ResolvedColorVariant`. The percentages are an output detail: the writers scale
|
|
1915
|
+
by 100 themselves where the CSS syntax asks for one. (The one thing on a
|
|
1916
|
+
different scale is the pair of tone transfers below, `toTone` / `fromTone`,
|
|
1917
|
+
which speak the 0–100 tone axis the authoring API takes.)
|
|
1918
|
+
|
|
1919
|
+
```ts
|
|
1920
|
+
import {
|
|
1921
|
+
formatOkhsl,
|
|
1922
|
+
formatOkhst,
|
|
1923
|
+
formatRgb,
|
|
1924
|
+
formatHsl,
|
|
1925
|
+
formatOklch,
|
|
1926
|
+
} from '@tenphi/glaze';
|
|
1927
|
+
|
|
1928
|
+
formatOkhsl(280, 0.6, 0.95); // 'okhsl(280 60% 95%)'
|
|
1929
|
+
formatOkhst(280, 0.6, 0.95); // 'okhst(280 60% 95%)'
|
|
1930
|
+
formatRgb(280, 0.6, 0.95); // 'rgb(238.45 239.95 251.1)'
|
|
1931
|
+
formatHsl(280, 0.6, 0.95); // 'hsl(232.92 61.87% 95.99%)'
|
|
1932
|
+
formatOklch(280, 0.6, 0.95); // 'oklch(0.9571 0.015 280)'
|
|
1933
|
+
```
|
|
1934
|
+
|
|
1935
|
+
So a producer composes with a writer directly, with nothing to rescale in
|
|
1936
|
+
between:
|
|
1937
|
+
|
|
1889
1938
|
```ts
|
|
1890
|
-
|
|
1939
|
+
const v = glaze.color('#7A4DBF').resolve().light;
|
|
1940
|
+
const { h, s, l } = variantToOkhsl(v);
|
|
1891
1941
|
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
formatOklch(280, 60, 95); // 'oklch(0.95 ... 280)'
|
|
1942
|
+
formatOkhst(v.h, v.s, v.t); // 'okhst(298.52 70.41% 45.02%)'
|
|
1943
|
+
formatOkhsl(h, s, l); // 'okhsl(298.52 70.41% 45.27%)'
|
|
1944
|
+
formatRgb(h, s, l); // 'rgb(122 77 191)'
|
|
1896
1945
|
```
|
|
1897
1946
|
|
|
1947
|
+
A value above 1 can only be pre-2.0 percentage-scale input, so the writers
|
|
1948
|
+
`console.warn` about it once per writer rather than emit a wrong color quietly.
|
|
1949
|
+
|
|
1898
1950
|
To attach an alpha component, use `glaze.format(variant, format)` on a `ResolvedColorVariant` (which carries the `alpha` channel) instead of these raw writers.
|
|
1899
1951
|
|
|
1900
1952
|
### OKHST tone utilities
|
|
@@ -1914,12 +1966,12 @@ import {
|
|
|
1914
1966
|
|
|
1915
1967
|
| Function | Description |
|
|
1916
1968
|
| ------------------------------------------- | ------------------------------------------------------------------------- |
|
|
1917
|
-
| `toTone(l, eps?)` | OKHSL lightness (0–1) → tone (0–100). Defaults to `REF_EPS`.
|
|
1918
|
-
| `fromTone(t, eps?)` | Tone (0–100) → OKHSL lightness (0–1). Inverse of `toTone`.
|
|
1969
|
+
| `toTone(l, eps?)` | OKHSL lightness (0–1) → tone (**0–100**, the authoring scale — divide by 100 for `formatOkhst`). Defaults to `REF_EPS`. |
|
|
1970
|
+
| `fromTone(t, eps?)` | Tone (**0–100**) → OKHSL lightness (0–1). Inverse of `toTone`. |
|
|
1919
1971
|
| `toneFromY(y, eps?)` / `yFromTone(t, eps?)` | Same transfer in luminance space (0–1). |
|
|
1920
1972
|
| `okhstToOkhsl({ h, s, t })` | OKHST → OKHSL (`{ h, s, l }`). |
|
|
1921
1973
|
| `okhslToOkhst({ h, s, l })` | OKHSL → OKHST (`{ h, s, t }`). |
|
|
1922
|
-
| `variantToOkhsl(variant)` | `ResolvedColorVariant` (stores `t`) → `{ h, s, l
|
|
1974
|
+
| `variantToOkhsl(variant)` | `ResolvedColorVariant` (stores `t`) → `{ h, s, l }` for rendering (`alpha` stays on the variant). |
|
|
1923
1975
|
| `REF_EPS` | Reference epsilon (`0.05`) for the canonical tone axis. |
|
|
1924
1976
|
|
|
1925
1977
|
`ResolvedColorVariant` stores `{ h, s, t, alpha }` (tone, not lightness). Use
|
|
@@ -1964,6 +2016,6 @@ Exported constants: `APCA_PRESETS`, `APCA_HC_ENHANCEMENT` (`15`, the Enhanced Le
|
|
|
1964
2016
|
| `maxIterations` | `18` | Max binary-search iterations per branch. |
|
|
1965
2017
|
| `initialDirection` | higher-contrast side | Direction to search first (`'lighter'` or `'darker'`). |
|
|
1966
2018
|
| `flip` | `false` | When `true`, try the opposite direction if the initial one doesn't meet the target. When `false`, only the initial direction is searched — unmet contrasts pin the result to that direction's extreme. |
|
|
1967
|
-
| `preferInitial` | `false` | With `flip` on and **both** directions meeting the target, keep `initialDirection` instead of taking whichever result lands nearer `preferredTone`. Makes the chosen side independent of the target — what [`contrastLevel`](#manual-contrast-level) uses to keep a color on one side of its base across the ramp. The flip fallback is unaffected. |
|
|
2019
|
+
| `preferInitial` | `false` | With `flip` on and **both** directions meeting the target, keep `initialDirection` instead of taking whichever result lands nearer `preferredTone`. Makes the chosen side independent of the target — what [`contrastLevel`](#manual-contrast-level) uses to keep a color on one side of its base across the ramp (on the normal passes only; the high-contrast ones never probe). The flip fallback is unaffected. |
|
|
1968
2020
|
|
|
1969
2021
|
Result: `{ tone, contrast, met, branch: 'lighter' | 'darker' | 'preferred', flipped? }`. `flipped: true` indicates the initial direction failed and the opposite direction satisfied the target.
|
package/docs/methodology.md
CHANGED
|
@@ -642,24 +642,26 @@ In HC variants, Glaze bypasses the normal tone window and uses the full
|
|
|
642
642
|
`[0, 100]` range. Edge tones can reach the edge; contrast floors have more room
|
|
643
643
|
to solve.
|
|
644
644
|
|
|
645
|
-
### A slider
|
|
645
|
+
### A slider through the tier
|
|
646
646
|
|
|
647
647
|
The two-tier model assumes contrast is a binary OS preference. When contrast is
|
|
648
648
|
instead a setting *your users* control, set
|
|
649
|
-
[`contrastLevel`](api.md#manual-contrast-level) to a number and
|
|
650
|
-
|
|
651
|
-
palette you
|
|
649
|
+
[`contrastLevel`](api.md#manual-contrast-level) to a number and your **normal**
|
|
650
|
+
palette slides along a `0–100` ramp: level `0` is the palette you authored, `100`
|
|
651
|
+
is the HC palette you authored, and everything between is resolved at that level.
|
|
652
652
|
|
|
653
653
|
The authoring work is the same — the HC pairs above are what the slider ramps
|
|
654
|
-
toward, so a palette tuned for high contrast needs no new fields. Two
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
- The
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
654
|
+
toward, so a palette tuned for high contrast needs no new fields. Two things
|
|
655
|
+
worth planning for:
|
|
656
|
+
|
|
657
|
+
- The slider and the tier compose. The HC tier keeps resolving at full contrast
|
|
658
|
+
regardless of the level, so wire the level into your build or runtime *and*
|
|
659
|
+
keep your `prefers-contrast: more` block: a user who has raised the slider and
|
|
660
|
+
asked their OS for more contrast still gets the escalation on top. The one
|
|
661
|
+
exception is level `100`, where the two coincide and the tier is dropped as a
|
|
662
|
+
duplicate.
|
|
663
|
+
- `contrastLevel: 0` is the natural rest position for a slider you ship but
|
|
664
|
+
default off — it reproduces the `'auto'` output bit for bit.
|
|
663
665
|
|
|
664
666
|
## Checklist
|
|
665
667
|
|
package/docs/migration.md
CHANGED
|
@@ -12,6 +12,7 @@ If you're starting from scratch, see [methodology.md](methodology.md) first —
|
|
|
12
12
|
- [Wiring exports into the app](#wiring-exports-into-the-app)
|
|
13
13
|
- [Prefix map strategies](#prefix-map-strategies)
|
|
14
14
|
- [Migrating an existing color system](#migrating-from-an-existing-color-system)
|
|
15
|
+
- [Upgrading Glaze](#upgrading-glaze)
|
|
15
16
|
- [Common pitfalls](#common-pitfalls)
|
|
16
17
|
|
|
17
18
|
## Choosing an export
|
|
@@ -296,6 +297,40 @@ Glaze gives you light/dark/HC for free, but only the light mode is matched again
|
|
|
296
297
|
|
|
297
298
|
After migration, mark every default-only token (borders, shadows, disabled chip, code highlighting, etc.) `inherit: false`. Colored sibling themes only need the accent + tinted-surface chain — flagging the rest cuts the emitted token set per theme dramatically.
|
|
298
299
|
|
|
300
|
+
## Upgrading Glaze
|
|
301
|
+
|
|
302
|
+
### 2.0 — `format*` takes 0–1
|
|
303
|
+
|
|
304
|
+
The `format*` writers (`formatOkhsl`, `formatOkhst`, `formatRgb`, `formatHsl`,
|
|
305
|
+
`formatOklch`) used to take `s` / `l` / `t` on a 0–100 percentage scale while
|
|
306
|
+
everything that *produces* those values — `resolve()`, `variantToOkhsl`,
|
|
307
|
+
`srgbToOkhsl`, `oklabToOkhsl`, `okhslToSrgb` — returns them on 0–1. Composing
|
|
308
|
+
the two, which is the obvious thing to do, was off by 100x and failed silently:
|
|
309
|
+
`0.7` is a legal percentage, so you got a valid CSS string naming the wrong
|
|
310
|
+
(near-black) color.
|
|
311
|
+
|
|
312
|
+
The writers now take the 0–1 factors, so the whole library speaks one scale.
|
|
313
|
+
Drop the `* 100`:
|
|
314
|
+
|
|
315
|
+
```diff
|
|
316
|
+
- formatOkhsl(v.h, v.s * 100, l * 100);
|
|
317
|
+
+ formatOkhsl(v.h, v.s, l);
|
|
318
|
+
|
|
319
|
+
- formatOkhst(v.h, v.s * 100, v.t * 100);
|
|
320
|
+
+ formatOkhst(v.h, v.s, v.t);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Nothing else moves: `h` was always 0–360, `alpha` was always 0–1, and every
|
|
324
|
+
export method (`css()` / `tokens()` / `json()` / `tasty()` / `dtcg()` /
|
|
325
|
+
`tailwind()` / `glaze.format()`) emits the same colors — they were compensating
|
|
326
|
+
internally. Dropping the redundant `×100 ÷100` round-trip shifts float noise by
|
|
327
|
+
an ULP, which shows up nowhere except the (meaningless) hue term of a
|
|
328
|
+
fully-desaturated `hsl()` string.
|
|
329
|
+
|
|
330
|
+
A leftover `* 100` is not silent any more: a value above 1 cannot be a factor,
|
|
331
|
+
so the writers `console.warn` once per writer and you get an obviously-broken
|
|
332
|
+
`7040.68%` instead of a plausible wrong color.
|
|
333
|
+
|
|
299
334
|
## Common pitfalls
|
|
300
335
|
|
|
301
336
|
| Symptom | Cause | Fix |
|
|
@@ -307,6 +342,7 @@ After migration, mark every default-only token (borders, shadows, disabled chip,
|
|
|
307
342
|
| 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. |
|
|
308
343
|
| `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 })`. |
|
|
309
344
|
| `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. |
|
|
345
|
+
| `console.warn: 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). |
|
|
310
346
|
| `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. |
|
|
311
347
|
|
|
312
348
|
## See also
|
package/docs/okhst.md
CHANGED
|
@@ -98,6 +98,10 @@ hi(f) = hi + (100 - hi) * f
|
|
|
98
98
|
`[15, 95] → [0, 100]`. The render `eps` is not interpolated, and a `false` window
|
|
99
99
|
is already the full range and therefore level-invariant.
|
|
100
100
|
|
|
101
|
+
This continuous form applies to the normal variants only. High-contrast variants
|
|
102
|
+
are already at the full range, so the level does not widen them further — the
|
|
103
|
+
bypass above is what makes the high-contrast tier level-independent.
|
|
104
|
+
|
|
101
105
|
## Scheme adaptation
|
|
102
106
|
|
|
103
107
|
Each regular color has an adaptation `mode`:
|
package/package.json
CHANGED