@tenphi/glaze 0.0.0-snapshot.02f3ca5
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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/index.cjs +2564 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +916 -0
- package/dist/index.d.mts +916 -0
- package/dist/index.mjs +2544 -0
- package/dist/index.mjs.map +1 -0
- package/docs/api.md +1080 -0
- package/docs/methodology.md +336 -0
- package/docs/migration.md +237 -0
- package/package.json +78 -0
package/LICENSE
ADDED
|
@@ -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.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="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
|
+
OKHSL-based color theme generator with WCAG 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 robust **light**, **dark**, and **high-contrast** color schemes from a single hue/saturation seed. WCAG contrast is preserved via explicit dependency declarations — no hidden role math, no magic multipliers.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **OKHSL color space** — perceptually uniform hue and saturation
|
|
24
|
+
- **WCAG 2 contrast solving** — automatic lightness adjustment to meet AA/AAA targets
|
|
25
|
+
- **Mix colors** — blend two colors with OKHSL or sRGB interpolation, opaque or transparent, with optional contrast solving
|
|
26
|
+
- **Shadow colors** — OKHSL-native shadow computation with automatic alpha, fg/bg tinting, and per-scheme adaptation
|
|
27
|
+
- **Light + Dark + High-Contrast** — all schemes from one definition
|
|
28
|
+
- **Per-color hue override** — absolute or relative hue shifts within a theme
|
|
29
|
+
- **Multi-format output** — `okhsl`, `rgb`, `hsl`, `oklch` with modern CSS space syntax
|
|
30
|
+
- **CSS custom properties export** — ready-to-use `--var: value;` declarations per scheme
|
|
31
|
+
- **Import/Export** — serialize and restore theme configurations
|
|
32
|
+
- **Create from hex/RGB** — start from an existing brand color
|
|
33
|
+
- **Zero dependencies** — pure math, runs anywhere (Node.js, browser, edge)
|
|
34
|
+
- **Tree-shakeable ESM + CJS** — dual-format package
|
|
35
|
+
- **TypeScript-first** — full type definitions included
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pnpm add @tenphi/glaze
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install @tenphi/glaze
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
yarn add @tenphi/glaze
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { glaze } from '@tenphi/glaze';
|
|
55
|
+
|
|
56
|
+
const primary = glaze(280, 80);
|
|
57
|
+
|
|
58
|
+
primary.colors({
|
|
59
|
+
surface: { lightness: 97, saturation: 0.75 },
|
|
60
|
+
text: { base: 'surface', lightness: '-52', contrast: 'AAA' },
|
|
61
|
+
border: { base: 'surface', lightness: ['-7', '-20'], contrast: 'AA-large' },
|
|
62
|
+
'accent-fill': { lightness: 52, mode: 'fixed' },
|
|
63
|
+
'accent-text': { base: 'accent-fill', lightness: '+48', contrast: 'AA', mode: 'fixed' },
|
|
64
|
+
'shadow-md': { type: 'shadow', bg: 'surface', fg: 'text', intensity: 10 },
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const danger = primary.extend({ hue: 23 });
|
|
68
|
+
const success = primary.extend({ hue: 157 });
|
|
69
|
+
|
|
70
|
+
const palette = glaze.palette(
|
|
71
|
+
{ primary, danger, success },
|
|
72
|
+
{ primary: 'primary' },
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const tokens = palette.tokens();
|
|
76
|
+
// → { light: { 'primary-surface': 'okhsl(...)', 'surface': 'okhsl(...)', ... },
|
|
77
|
+
// dark: { 'primary-surface': 'okhsl(...)', 'surface': 'okhsl(...)', ... } }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Concepts at a glance
|
|
81
|
+
|
|
82
|
+
1. **Theme = one hue/saturation seed.** Status themes are siblings created via `extend()` — they inherit every color definition and only swap the seed.
|
|
83
|
+
2. **Every color is explicit.** A color is either a *root* (absolute `lightness`) or *dependent* (`base` + relative offset and/or `contrast`). No implicit roles.
|
|
84
|
+
3. **WCAG `contrast` is a floor, not a target.** The solver only widens a color's lightness when the requested position fails the requested ratio.
|
|
85
|
+
4. **Light, dark, and high-contrast come from one definition.** `mode` (`auto` / `fixed` / `static`) picks how each color adapts; `lightness` / `contrast` / `intensity` / `value` accept an optional `[normal, hc]` pair for explicit high-contrast tuning.
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
- [`docs/api.md`](docs/api.md) — full API reference (every method, every option).
|
|
90
|
+
- [`docs/methodology.md`](docs/methodology.md) — palette design methodology for building from scratch.
|
|
91
|
+
- [`docs/migration.md`](docs/migration.md) — wiring tokens into your app and migrating off a legacy color system.
|
|
92
|
+
- [`AGENTS.md`](AGENTS.md) — source-tree orientation for contributors.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
[MIT](LICENSE)
|