@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/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<h1 align="center">Glaze</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
OKHST-based color theme generator with WCAG contrast solving
|
|
8
|
+
OKHST-based color theme generator with WCAG and APCA contrast solving
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
@@ -16,18 +16,25 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
Glaze generates
|
|
19
|
+
Glaze generates **light**, **dark**, and **high-contrast** color schemes from a
|
|
20
|
+
single hue/saturation seed. Relationships stay explicit: colors either define
|
|
21
|
+
an absolute tone or depend on a named base through a tone delta and an optional
|
|
22
|
+
contrast floor.
|
|
20
23
|
|
|
21
24
|
## Features
|
|
22
25
|
|
|
23
|
-
- **OKHST color space** — OKHSL with a contrast-
|
|
26
|
+
- **OKHST color space** — OKHSL with a contrast-shaped **tone** axis. Equal
|
|
27
|
+
steps give equal WCAG contrast for neutrals and a useful approximation for
|
|
28
|
+
chromatic colors. See [OKHST in Glaze](docs/okhst.md) and the
|
|
29
|
+
[full OKHST specification](https://github.com/tenphi/okhst).
|
|
24
30
|
- **WCAG 2 + APCA contrast solving** — automatic tone adjustment to meet a WCAG ratio or APCA Lc floor
|
|
25
31
|
- **Unified dark mode** — one tone space for light, dark, and high-contrast; dark is a single `100 − t` inversion, no fitted curve
|
|
26
32
|
- **Mix colors** — blend two colors with OKHSL or sRGB interpolation, opaque or transparent, with optional contrast solving
|
|
27
33
|
- **Shadow colors** — OKHSL-native shadow computation with automatic alpha, fg/bg tinting, and per-scheme adaptation
|
|
28
34
|
- **Light + Dark + High-Contrast** — all schemes from one definition
|
|
29
35
|
- **Per-color hue override** — absolute or relative hue shifts within a theme
|
|
30
|
-
- **Multi-format output** —
|
|
36
|
+
- **Multi-format output** — native `rgb`, `hsl`, and `oklch`, plus
|
|
37
|
+
[Tasty](https://tasty.style)-compatible `okhsl` and `okhst`
|
|
31
38
|
- **CSS custom properties export** — ready-to-use `--var: value;` declarations per scheme
|
|
32
39
|
- **W3C DTCG export** — spec-conformant `.tokens.json` (2025.10) for Figma, Tokens Studio, Style Dictionary, and every DTCG tool
|
|
33
40
|
- **W3C DTCG Resolver-Module export** — opt-in single-document `dtcgResolver()` (sets + a `scheme` modifier with a context per variant) for resolver tools such as Dispersa
|
|
@@ -57,43 +64,90 @@ yarn add @tenphi/glaze
|
|
|
57
64
|
```ts
|
|
58
65
|
import { glaze } from '@tenphi/glaze';
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
primary.colors({
|
|
63
|
-
surface: { tone: 97, saturation: 0.75 },
|
|
64
|
-
text: { base: 'surface', tone: '-52', contrast: 'AAA' },
|
|
65
|
-
border: { base: 'surface', tone: ['-7', '-20'], contrast: 'AA-large' },
|
|
66
|
-
'accent-fill': { tone: 52, mode: 'fixed' },
|
|
67
|
-
'accent-text': { base: 'accent-fill', tone: 'max', mode: 'fixed' },
|
|
68
|
-
'shadow-md': { type: 'shadow', bg: 'surface', fg: 'text', intensity: 10 },
|
|
67
|
+
glaze.configure({
|
|
68
|
+
modes: { dark: true, highContrast: true },
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
const defaultTheme = glaze(280, 80);
|
|
72
|
+
|
|
73
|
+
defaultTheme.colors({
|
|
74
|
+
surface: { tone: 97, saturation: 0.15 },
|
|
75
|
+
'surface-text': {
|
|
76
|
+
base: 'surface',
|
|
77
|
+
tone: '-1',
|
|
78
|
+
contrast: { apca: ['content', 'body'] },
|
|
79
|
+
},
|
|
80
|
+
border: {
|
|
81
|
+
base: 'surface',
|
|
82
|
+
tone: ['-8', '-16'],
|
|
83
|
+
inherit: false,
|
|
84
|
+
},
|
|
85
|
+
'accent-surface': { tone: 52, mode: 'fixed' },
|
|
86
|
+
'accent-surface-text': {
|
|
87
|
+
base: 'accent-surface',
|
|
88
|
+
tone: '+1',
|
|
89
|
+
contrast: 'AA',
|
|
90
|
+
mode: 'fixed',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
73
93
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
{ primary: 'primary' },
|
|
77
|
-
);
|
|
94
|
+
const dangerTheme = defaultTheme.extend({ hue: 23 });
|
|
95
|
+
const palette = glaze.palette({ default: defaultTheme, danger: dangerTheme });
|
|
78
96
|
|
|
79
|
-
const tokens = palette.tokens(
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
const tokens = palette.tokens({
|
|
98
|
+
prefix: { default: '', danger: 'danger-' },
|
|
99
|
+
});
|
|
100
|
+
// → {
|
|
101
|
+
// light: { surface: 'oklch(...)', 'danger-surface': 'oklch(...)', ... },
|
|
102
|
+
// dark: { surface: 'oklch(...)', 'danger-surface': 'oklch(...)', ... },
|
|
103
|
+
// lightContrast: { ... },
|
|
104
|
+
// darkContrast: { ... },
|
|
105
|
+
// }
|
|
82
106
|
```
|
|
83
107
|
|
|
84
108
|
## Concepts at a glance
|
|
85
109
|
|
|
86
|
-
1. **
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
110
|
+
1. **A theme has one hue/saturation seed.** Create status themes with
|
|
111
|
+
`extend()` so they inherit the same relationships while changing hue.
|
|
112
|
+
2. **A color is a root or a dependency.** Roots use an absolute `tone` or
|
|
113
|
+
`'max'`/`'min'`. Dependent colors name a `base` and may use a signed
|
|
114
|
+
**tone delta** such as `'-8'` plus a `contrast` floor.
|
|
115
|
+
3. **Tone is an authoring axis, not a contrast guarantee.** Equal tone deltas
|
|
116
|
+
are exact WCAG steps for neutrals. Chromatic colors can drift in rendered
|
|
117
|
+
luminance, so Glaze measures contrast floors against the resolved colors.
|
|
118
|
+
4. **`contrast` is a floor.** A bare number or preset means WCAG;
|
|
119
|
+
`{ wcag }` and `{ apca }` select the metric explicitly. The solver preserves
|
|
120
|
+
the requested tone whenever it already passes.
|
|
121
|
+
5. **Each color chooses its dark adaptation.** `mode: 'auto'` uses dark tone
|
|
122
|
+
inversion (`100 - t`), `fixed` keeps the authored side of the tone scale,
|
|
123
|
+
and `static` skips scheme adaptation.
|
|
124
|
+
6. **Tone windows bound ordinary schemes.** `lightTone` and `darkTone`
|
|
125
|
+
configure the light/dark render ranges. High-contrast variants use the full
|
|
126
|
+
range. Values that accept `[normal, highContrast]` pairs can tighten
|
|
127
|
+
deliberately in HC.
|
|
128
|
+
|
|
129
|
+
In Glaze, a **scheme variant** is one of `light`, `dark`, `lightContrast`, or
|
|
130
|
+
`darkContrast`. Export `modes` choose which variants are included; [Tasty](https://tasty.style)
|
|
131
|
+
`states` choose how those variants are activated in an application.
|
|
132
|
+
|
|
133
|
+
## Choosing an output
|
|
134
|
+
|
|
135
|
+
- `tasty()` returns [Tasty](https://tasty.style) `#token` bindings, including its custom `okhsl()` or
|
|
136
|
+
`okhst()` serialization.
|
|
137
|
+
- `tokens()` and `json()` return JavaScript data and default to native
|
|
138
|
+
`oklch()` values.
|
|
139
|
+
- `css()` returns custom-property declarations.
|
|
140
|
+
- `dtcg()` / `dtcgResolver()` target design-token tooling.
|
|
141
|
+
- `tailwind()` emits a Tailwind CSS v4 theme.
|
|
91
142
|
|
|
92
143
|
## Documentation
|
|
93
144
|
|
|
94
|
-
- [
|
|
95
|
-
- [
|
|
96
|
-
|
|
145
|
+
- Start with [the methodology](docs/methodology.md) to design a palette.
|
|
146
|
+
- Use [migration and integration](docs/migration.md) to wire it into an
|
|
147
|
+
application or replace an existing color system.
|
|
148
|
+
- Keep the [API reference](docs/api.md) nearby for every method and option.
|
|
149
|
+
- Read [OKHST in Glaze](docs/okhst.md) for the product-level color model, or
|
|
150
|
+
the [full OKHST specification](https://github.com/tenphi/okhst) for its math.
|
|
97
151
|
- [`AGENTS.md`](AGENTS.md) — source-tree orientation for contributors.
|
|
98
152
|
|
|
99
153
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -690,8 +690,8 @@ function defaultConfig() {
|
|
|
690
690
|
},
|
|
691
691
|
darkDesaturation: .1,
|
|
692
692
|
states: {
|
|
693
|
-
dark: "@dark",
|
|
694
|
-
highContrast: "@
|
|
693
|
+
dark: "@media(prefers-color-scheme: dark)",
|
|
694
|
+
highContrast: "@media(prefers-contrast: more)"
|
|
695
695
|
},
|
|
696
696
|
modes: {
|
|
697
697
|
dark: true,
|