@tenphi/glaze 0.18.0 → 0.19.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/docs/api.md CHANGED
@@ -127,12 +127,12 @@ theme.tokens()
127
127
 
128
128
  ### `theme.tasty(options?)`
129
129
 
130
- Tasty style-to-state bindings for the [Tasty style system](https://tasty.style/docs). Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
130
+ Tasty style-to-state bindings for the [Tasty style system](https://tasty.style/docs). Uses `#name` color token keys and state aliases. By default the dark and high-contrast variants are keyed by media-query states (`'@media(prefers-color-scheme: dark)'`, `'@media(prefers-contrast: more)'`) so tokens work without registering custom states.
131
131
 
132
132
  ```ts
133
133
  theme.tasty()
134
134
  // → {
135
- // '#surface': { '': 'okhsl(...)', '@dark': 'okhsl(...)' },
135
+ // '#surface': { '': 'okhsl(...)', '@media(prefers-color-scheme: dark)': 'okhsl(...)' },
136
136
  // ...
137
137
  // }
138
138
  ```
@@ -143,13 +143,13 @@ theme.tasty()
143
143
  |---|---|---|
144
144
  | `format` | `'okhsl'` | Output color format. `'okhsl'` and `'okhst'` are supported here (Tasty-only spaces). |
145
145
  | `modes` | global config | Which scheme variants to include. |
146
- | `states.dark` | `'@dark'` (or global config) | State alias for dark mode tokens. |
147
- | `states.highContrast` | `'@high-contrast'` (or global config) | State alias for high-contrast tokens. |
146
+ | `states.dark` | `'@media(prefers-color-scheme: dark)'` (or global config) | State alias for dark mode tokens. |
147
+ | `states.highContrast` | `'@media(prefers-contrast: more)'` (or global config) | State alias for high-contrast tokens. |
148
148
  | `splitHue` | `false` | Emit hue as a separate custom property (`$name-hue` token + `var()` in `oklch` values). Requires `format: 'oklch'` and every color to be pastel. |
149
149
  | `name` | `'theme'` | Base name for the theme-level hue var (`$theme-hue` / `--theme-hue`). Palette export auto-derives this from the theme name. |
150
150
  | `prefix` | (palette only) | See [Palette](#palette). |
151
151
 
152
- When both `dark` and `highContrast` modes are enabled, dark high-contrast variants are emitted under the combined key `<dark> & <highContrast>` (e.g. `'@dark & @high-contrast'`).
152
+ When both `dark` and `highContrast` modes are enabled, dark high-contrast variants are emitted under the combined key `<dark> & <highContrast>` (e.g. `'@media(prefers-color-scheme: dark) & @media(prefers-contrast: more)'`).
153
153
 
154
154
  ### `theme.json(options?)`
155
155
 
@@ -1293,8 +1293,8 @@ glaze.configure({
1293
1293
  darkTone: [15, 95], // [lo, hi]; or { lo, hi, eps } / false to disable clamping
1294
1294
  darkDesaturation: 0.1,
1295
1295
  states: {
1296
- dark: '@dark',
1297
- highContrast: '@high-contrast',
1296
+ dark: '@media(prefers-color-scheme: dark)',
1297
+ highContrast: '@media(prefers-contrast: more)',
1298
1298
  },
1299
1299
  modes: {
1300
1300
  dark: true,
@@ -1316,8 +1316,8 @@ A `ToneWindow` is `[lo, hi]` (OKHSL-lightness endpoints, reference eps — the c
1316
1316
  | `lightTone` | `[10, 100]` | Light scheme tone window: `[lo, hi]`, `{ lo, hi, eps }`, or `false` to disable clamping. Bypassed in HC. |
1317
1317
  | `darkTone` | `[15, 95]` | Dark scheme tone window: `[lo, hi]`, `{ lo, hi, eps }`, or `false` to disable clamping. Bypassed in HC. |
1318
1318
  | `darkDesaturation` | `0.1` | Saturation reduction in dark scheme (0–1). |
1319
- | `states.dark` | `'@dark'` | State alias for dark mode tokens (Tasty export). |
1320
- | `states.highContrast` | `'@high-contrast'` | State alias for HC tokens. |
1319
+ | `states.dark` | `'@media(prefers-color-scheme: dark)'` | State alias for dark mode tokens (Tasty export). Defaults to a media query so tokens react to the OS preference without registering custom states. |
1320
+ | `states.highContrast` | `'@media(prefers-contrast: more)'` | State alias for HC tokens (Tasty export). |
1321
1321
  | `modes.dark` | `true` | Include dark variants in exports. |
1322
1322
  | `modes.highContrast` | `false` | Include HC variants. |
1323
1323
  | `shadowTuning` | `undefined` | Default tuning for all shadow colors. Per-color tuning merges field-by-field. |
package/docs/migration.md CHANGED
@@ -106,7 +106,7 @@ Glaze emits the same resolved colors in six shapes. Pick one based on your rende
106
106
 
107
107
  | Method | Output shape | Use it for |
108
108
  |---|---|---|
109
- | `palette.tasty(options?)` | `{ '#name': { '': value, '@dark': value, '@hc': value } }` | The [Tasty](https://tasty.style/docs) style system. Single object, state aliases keyed inside each token. |
109
+ | `palette.tasty(options?)` | `{ '#name': { '': value, '@media(prefers-color-scheme: dark)': value, '@media(prefers-contrast: more)': value } }` | The [Tasty](https://tasty.style/docs) style system. Single object, state aliases keyed inside each token. |
110
110
  | `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. |
111
111
  | `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. |
112
112
  | `palette.json(options?)` | `{ themeName: { name: { light, dark, ... } } }` | Tooling, JSON pipelines. |
@@ -136,11 +136,14 @@ useGlobalStyles('body', PALETTE_TOKENS);
136
136
  tastyStatic('body', PALETTE_TOKENS);
137
137
  ```
138
138
 
139
- For the `@dark` / `@hc` state aliases to do anything, your app needs to register what those states *mean*:
139
+ 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 setup.
140
+
141
+ 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
142
 
141
143
  ```ts
142
144
  import { setGlobalPredefinedStates } from '@tenphi/tasty';
143
145
 
146
+ // glaze.configure({ states: { dark: '@dark', highContrast: '@hc' } });
144
147
  setGlobalPredefinedStates({
145
148
  '@dark':
146
149
  '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/glaze",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "OKHST-based color theme generator with WCAG contrast solving for light, dark, and high-contrast schemes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",