@tenphi/cookbook 0.13.0 → 0.16.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.
Files changed (51) hide show
  1. package/README.md +22 -1
  2. package/dist/cli.js +103 -61
  3. package/dist/cli.js.map +1 -1
  4. package/dist/components.d.ts +3 -2
  5. package/dist/components.js +2 -2
  6. package/dist/config.d.ts +3 -0
  7. package/dist/config.js +3 -0
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +2 -2
  10. package/docs/architecture.md +91 -0
  11. package/docs/authoring.mdx +86 -0
  12. package/docs/cli.md +88 -0
  13. package/docs/configuration.md +518 -0
  14. package/docs/content-sources.md +150 -0
  15. package/docs/customization-rules.md +153 -0
  16. package/docs/deployment.md +78 -0
  17. package/docs/examples.md +95 -0
  18. package/docs/getting-started.md +124 -0
  19. package/docs/index.md +74 -0
  20. package/docs/migration.md +36 -0
  21. package/docs/starlight-comparison.md +124 -0
  22. package/docs/theme-and-components.md +668 -0
  23. package/docs/upstream/glaze/LICENSE +21 -0
  24. package/docs/upstream/glaze/README.md +156 -0
  25. package/docs/upstream/glaze/docs/api.md +2021 -0
  26. package/docs/upstream/glaze/docs/methodology.md +686 -0
  27. package/docs/upstream/glaze/docs/migration.md +351 -0
  28. package/docs/upstream/glaze/docs/okhst.md +207 -0
  29. package/docs/upstream/manifest.json +18 -0
  30. package/docs/upstream/tasty/LICENSE +21 -0
  31. package/docs/upstream/tasty/README.md +685 -0
  32. package/docs/upstream/tasty/docs/README.md +39 -0
  33. package/docs/upstream/tasty/docs/adoption.md +323 -0
  34. package/docs/upstream/tasty/docs/ai-agents.md +229 -0
  35. package/docs/upstream/tasty/docs/comparison.md +448 -0
  36. package/docs/upstream/tasty/docs/configuration.md +823 -0
  37. package/docs/upstream/tasty/docs/debug.md +335 -0
  38. package/docs/upstream/tasty/docs/design-system.md +455 -0
  39. package/docs/upstream/tasty/docs/dsl.md +1021 -0
  40. package/docs/upstream/tasty/docs/getting-started.md +238 -0
  41. package/docs/upstream/tasty/docs/injector.md +634 -0
  42. package/docs/upstream/tasty/docs/methodology.md +648 -0
  43. package/docs/upstream/tasty/docs/migration-v3.md +285 -0
  44. package/docs/upstream/tasty/docs/pipeline.md +749 -0
  45. package/docs/upstream/tasty/docs/plugins.md +353 -0
  46. package/docs/upstream/tasty/docs/react-api.md +681 -0
  47. package/docs/upstream/tasty/docs/runtime-benchmarks.md +351 -0
  48. package/docs/upstream/tasty/docs/ssr.md +610 -0
  49. package/docs/upstream/tasty/docs/styles.md +677 -0
  50. package/docs/upstream/tasty/docs/tasty-static.md +582 -0
  51. package/package.json +17 -9
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrey Yamanov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/tenphi/glaze/v2.0.0/assets/glaze.svg" width="128" height="128" alt="Glaze logo">
3
+ </p>
4
+
5
+ <h1 align="center">Glaze</h1>
6
+
7
+ <p align="center">
8
+ OKHST-based color theme generator with WCAG and APCA contrast solving
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@tenphi/glaze"><img src="https://img.shields.io/npm/v/@tenphi/glaze.svg" alt="npm version"></a>
13
+ <a href="https://github.com/tenphi/glaze/actions/workflows/ci.yml"><img src="https://github.com/tenphi/glaze/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
14
+ <a href="https://github.com/tenphi/glaze/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@tenphi/glaze.svg" alt="license"></a>
15
+ </p>
16
+
17
+ ***
18
+
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.
23
+
24
+ ## Features
25
+
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).
30
+ * **WCAG 2 + APCA contrast solving** — automatic tone adjustment to meet a WCAG ratio or APCA Lc floor
31
+ * **Unified dark mode** — one tone space for light, dark, and high-contrast; dark is a single `100 − t` inversion, no fitted curve
32
+ * **Mix colors** — blend two colors with OKHSL or sRGB interpolation, opaque or transparent, with optional contrast solving
33
+ * **Shadow colors** — OKHSL-native shadow computation with automatic alpha, fg/bg tinting, and per-scheme adaptation
34
+ * **Light + Dark + High-Contrast** — all schemes from one definition
35
+ * **Manual contrast level** — put your normal palette on a `0–100` slider between itself and the high-contrast one; every level in between is solved, not approximated, and the high-contrast tier stays available on top
36
+ * **Per-color hue override** — absolute or relative hue shifts within a theme
37
+ * **Multi-format output** — native `rgb`, `hsl`, and `oklch`, plus
38
+ [Tasty](../tasty/README.md)-compatible `okhsl` and `okhst`
39
+ * **CSS custom properties export** — ready-to-use `--var: value;` declarations per scheme
40
+ * **W3C DTCG export** — spec-conformant `.tokens.json` (2025.10) for Figma, Tokens Studio, Style Dictionary, and every DTCG tool
41
+ * **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
42
+ * **Tailwind CSS v4 export** — `@theme` block + dark / high-contrast overrides
43
+ * **Import/Export** — serialize and restore themes, color tokens, and entire palettes as JSON
44
+ * **Create from hex/RGB** — start from an existing brand color
45
+ * **Zero dependencies** — pure math, runs anywhere (Node.js, browser, edge)
46
+ * **Tree-shakeable ESM + CJS** — dual-format package
47
+ * **TypeScript-first** — full type definitions included
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ pnpm add @tenphi/glaze
53
+ ```
54
+
55
+ ```bash
56
+ npm install @tenphi/glaze
57
+ ```
58
+
59
+ ```bash
60
+ yarn add @tenphi/glaze
61
+ ```
62
+
63
+ ## Quick Start
64
+
65
+ ```ts
66
+ import { glaze } from '@tenphi/glaze';
67
+
68
+ glaze.configure({
69
+ modes: { dark: true, highContrast: true },
70
+ });
71
+
72
+ const defaultTheme = glaze(280, 80);
73
+
74
+ defaultTheme.colors({
75
+ surface: { tone: 97, saturation: 0.15 },
76
+ 'surface-text': {
77
+ base: 'surface',
78
+ tone: '-1',
79
+ contrast: { apca: ['content', 'body'] },
80
+ },
81
+ border: {
82
+ base: 'surface',
83
+ tone: ['-8', '-16'],
84
+ inherit: false,
85
+ },
86
+ 'accent-surface': { tone: 52, mode: 'fixed' },
87
+ 'accent-surface-text': {
88
+ base: 'accent-surface',
89
+ tone: '+1',
90
+ contrast: 'AA',
91
+ mode: 'fixed',
92
+ },
93
+ });
94
+
95
+ const dangerTheme = defaultTheme.extend({ hue: 23 });
96
+ const palette = glaze.palette({ default: defaultTheme, danger: dangerTheme });
97
+
98
+ const tokens = palette.tokens({
99
+ prefix: { default: '', danger: 'danger-' },
100
+ });
101
+ // → {
102
+ // light: { surface: 'oklch(...)', 'danger-surface': 'oklch(...)', ... },
103
+ // dark: { surface: 'oklch(...)', 'danger-surface': 'oklch(...)', ... },
104
+ // lightContrast: { ... },
105
+ // darkContrast: { ... },
106
+ // }
107
+ ```
108
+
109
+ ## Concepts at a glance
110
+
111
+ 1. **A theme has one hue/saturation seed.** Create status themes with
112
+ `extend()` so they inherit the same relationships while changing hue.
113
+ 2. **A color is a root or a dependency.** Roots use an absolute `tone` or
114
+ `'max'`/`'min'`. Dependent colors name a `base` and may use a signed
115
+ **tone delta** such as `'-8'` plus a `contrast` floor.
116
+ 3. **Tone is an authoring axis, not a contrast guarantee.** Equal tone deltas
117
+ are exact WCAG steps for neutrals. Chromatic colors can drift in rendered
118
+ luminance, so Glaze measures contrast floors against the resolved colors.
119
+ 4. **`contrast` is a floor.** A bare number or preset means WCAG;
120
+ `{ wcag }` and `{ apca }` select the metric explicitly. The solver preserves
121
+ the requested tone whenever it already passes.
122
+ 5. **Each color chooses its dark adaptation.** `mode: 'auto'` uses dark tone
123
+ inversion (`100 - t`), `fixed` keeps the authored side of the tone scale,
124
+ and `static` skips scheme adaptation.
125
+ 6. **Tone windows bound ordinary schemes.** `lightTone` and `darkTone`
126
+ configure the light/dark render ranges. High-contrast variants use the full
127
+ range. Values that accept `[normal, highContrast]` pairs can tighten
128
+ deliberately in HC.
129
+
130
+ In Glaze, a **scheme variant** is one of `light`, `dark`, `lightContrast`, or
131
+ `darkContrast`. Export `modes` choose which variants are included; [Tasty](../tasty/README.md)
132
+ `states` choose how those variants are activated in an application.
133
+
134
+ ## Choosing an output
135
+
136
+ * `tasty()` returns [Tasty](../tasty/README.md) `#token` bindings, including its custom `okhsl()` or
137
+ `okhst()` serialization.
138
+ * `tokens()` and `json()` return JavaScript data and default to native
139
+ `oklch()` values.
140
+ * `css()` returns custom-property declarations.
141
+ * `dtcg()` / `dtcgResolver()` target design-token tooling.
142
+ * `tailwind()` emits a Tailwind CSS v4 theme.
143
+
144
+ ## Documentation
145
+
146
+ * Start with [the methodology](docs/methodology.md) to design a palette.
147
+ * Use [migration and integration](docs/migration.md) to wire it into an
148
+ application or replace an existing color system.
149
+ * Keep the [API reference](docs/api.md) nearby for every method and option.
150
+ * Read [OKHST in Glaze](docs/okhst.md) for the product-level color model, or
151
+ the [full OKHST specification](https://github.com/tenphi/okhst) for its math.
152
+ * [`AGENTS.md`](https://github.com/tenphi/glaze/blob/v2.0.0/AGENTS.md) — source-tree orientation for contributors.
153
+
154
+ ## License
155
+
156
+ [MIT](LICENSE)