@clhaas/palette-kit 0.1.8 → 0.4.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/CHANGELOG.md +59 -0
- package/README.md +80 -177
- package/dist/contrast/contrast.d.ts +16 -0
- package/dist/contrast/contrast.js +102 -0
- package/dist/core/intent-registry.d.ts +11 -0
- package/dist/core/intent-registry.js +70 -0
- package/dist/core/oklch.d.ts +16 -0
- package/dist/core/oklch.js +56 -0
- package/dist/create-palette-kit.d.ts +9 -0
- package/dist/create-palette-kit.js +67 -0
- package/dist/engine/context/context.d.ts +13 -0
- package/dist/engine/context/context.js +37 -0
- package/dist/engine/level/curves.d.ts +17 -0
- package/dist/engine/level/curves.js +49 -0
- package/dist/engine/level/level.d.ts +4 -0
- package/dist/engine/level/level.js +13 -0
- package/dist/engine/relation/relation.d.ts +105 -0
- package/dist/engine/relation/relation.js +137 -0
- package/dist/engine/resolve/resolve.d.ts +36 -0
- package/dist/engine/resolve/resolve.js +116 -0
- package/dist/engine/state/state.d.ts +46 -0
- package/dist/engine/state/state.js +68 -0
- package/dist/engine/usage/fill.d.ts +9 -0
- package/dist/engine/usage/fill.js +9 -0
- package/dist/engine/usage/lines.d.ts +9 -0
- package/dist/engine/usage/lines.js +9 -0
- package/dist/engine/usage/overlays.d.ts +9 -0
- package/dist/engine/usage/overlays.js +9 -0
- package/dist/engine/usage/strategy.d.ts +56 -0
- package/dist/engine/usage/strategy.js +30 -0
- package/dist/engine/usage/visualVocabulary.d.ts +9 -0
- package/dist/engine/usage/visualVocabulary.js +9 -0
- package/dist/export/serialize.d.ts +14 -0
- package/dist/export/serialize.js +89 -0
- package/dist/export/types.d.ts +37 -0
- package/dist/export/types.js +31 -0
- package/dist/index.d.ts +3 -22
- package/dist/index.js +2 -18
- package/dist/operators/convert.d.ts +32 -0
- package/dist/operators/convert.js +80 -0
- package/dist/presets/presets.d.ts +95 -0
- package/dist/presets/presets.js +308 -0
- package/dist/types/index.d.ts +111 -0
- package/dist/utils/errors/errors.d.ts +17 -0
- package/dist/utils/errors/errors.js +22 -0
- package/docs/API.md +167 -0
- package/docs/Alpha.md +14 -0
- package/docs/Architecture.md +56 -0
- package/docs/CLI.md +22 -0
- package/docs/Concepts.md +73 -0
- package/docs/Config.md +144 -0
- package/docs/Diagnostics.md +22 -0
- package/docs/Exporters.md +33 -0
- package/docs/FAQ.md +59 -0
- package/docs/Migration.md +61 -0
- package/docs/Overlays.md +33 -0
- package/docs/README.md +60 -0
- package/docs/Text.md +41 -0
- package/docs/Tokens.md +42 -0
- package/docs/Usage-JSON.md +39 -0
- package/docs/Usage-ReactNative.md +63 -0
- package/docs/Usage-Web.md +66 -0
- package/docs/Validation.md +97 -0
- package/docs/Why.md +37 -0
- package/docs/_api-surface.md +53 -0
- package/docs/snippets/serialize-oklch.md +9 -0
- package/docs/spec.md +98 -0
- package/package.json +74 -52
- package/dist/alpha/generateAlphaScale.d.ts +0 -5
- package/dist/alpha/generateAlphaScale.js +0 -34
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -150
- package/dist/contrast/apca.d.ts +0 -2
- package/dist/contrast/apca.js +0 -5
- package/dist/contrast/onSolid.d.ts +0 -6
- package/dist/contrast/onSolid.js +0 -28
- package/dist/contrast/solveText.d.ts +0 -2
- package/dist/contrast/solveText.js +0 -31
- package/dist/createTheme.d.ts +0 -38
- package/dist/createTheme.js +0 -148
- package/dist/data/radixSeeds.d.ts +0 -3
- package/dist/data/radixSeeds.js +0 -34
- package/dist/diagnostics/analyzeScale.d.ts +0 -2
- package/dist/diagnostics/analyzeScale.js +0 -7
- package/dist/diagnostics/analyzeTheme.d.ts +0 -2
- package/dist/diagnostics/analyzeTheme.js +0 -35
- package/dist/diagnostics/warnings.d.ts +0 -2
- package/dist/diagnostics/warnings.js +0 -20
- package/dist/engine/curves.d.ts +0 -9
- package/dist/engine/curves.js +0 -48
- package/dist/engine/oklch.d.ts +0 -8
- package/dist/engine/oklch.js +0 -40
- package/dist/engine/templates.d.ts +0 -14
- package/dist/engine/templates.js +0 -45
- package/dist/exporters/selectColorMode.d.ts +0 -2
- package/dist/exporters/selectColorMode.js +0 -19
- package/dist/exporters/toCssVars.d.ts +0 -13
- package/dist/exporters/toCssVars.js +0 -108
- package/dist/exporters/toJson.d.ts +0 -3
- package/dist/exporters/toJson.js +0 -25
- package/dist/exporters/toReactNative.d.ts +0 -54
- package/dist/exporters/toReactNative.js +0 -33
- package/dist/exporters/toTailwind.d.ts +0 -17
- package/dist/exporters/toTailwind.js +0 -111
- package/dist/exporters/toTs.d.ts +0 -3
- package/dist/exporters/toTs.js +0 -43
- package/dist/generateScale.d.ts +0 -48
- package/dist/generateScale.js +0 -274
- package/dist/overlays/generateOverlayScale.d.ts +0 -2
- package/dist/overlays/generateOverlayScale.js +0 -34
- package/dist/text/generateTextScale.d.ts +0 -8
- package/dist/text/generateTextScale.js +0 -18
- package/dist/text/resolveOnBgText.d.ts +0 -9
- package/dist/text/resolveOnBgText.js +0 -28
- package/dist/tokens/presetRadixLikeUi.d.ts +0 -5
- package/dist/tokens/presetRadixLikeUi.js +0 -55
- package/dist/types.d.ts +0 -69
- /package/dist/{types.js → types/index.js} +0 -0
package/docs/API.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
This document describes the public API exposed by the package root in the v0.4
|
|
4
|
+
branch.
|
|
5
|
+
|
|
6
|
+
## Public Entry Point
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The package root exports `createPaletteKit` and the official resolver preset
|
|
13
|
+
configs. Public TypeScript types are also reexported from the package root.
|
|
14
|
+
|
|
15
|
+
## createPaletteKit
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
function createPaletteKit(config: PaletteKitConfig): PaletteKit;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`createPaletteKit` creates an immutable palette resolver. It normalizes the
|
|
22
|
+
intent registry once and keeps context and output defaults explicit.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const palette = createPaletteKit({
|
|
26
|
+
context: "light",
|
|
27
|
+
output: "oklch",
|
|
28
|
+
preset: "neutral",
|
|
29
|
+
intents: {
|
|
30
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
31
|
+
neutral: { hue: 0, chroma: 0 },
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## palette.resolve
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
palette.resolve({
|
|
40
|
+
usage,
|
|
41
|
+
intent,
|
|
42
|
+
level,
|
|
43
|
+
on,
|
|
44
|
+
over,
|
|
45
|
+
under,
|
|
46
|
+
state,
|
|
47
|
+
stateDirection,
|
|
48
|
+
context,
|
|
49
|
+
output,
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Resolution always happens in OKLCH first. The selected `output` is applied only
|
|
54
|
+
after resolution.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
const surface = palette.resolve({
|
|
58
|
+
usage: "fill",
|
|
59
|
+
intent: "neutral",
|
|
60
|
+
level: 2,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const text = palette.resolve({
|
|
64
|
+
usage: "visualVocabulary",
|
|
65
|
+
intent: "brand",
|
|
66
|
+
on: surface,
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage Rules
|
|
71
|
+
|
|
72
|
+
| Usage | Level | Relations |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| `fill` | Required | `on` optional |
|
|
75
|
+
| `visualVocabulary` | Forbidden | `on` required |
|
|
76
|
+
| `lines` | Required | `on` optional |
|
|
77
|
+
| `overlays` | Required | `over` or `under` optional |
|
|
78
|
+
|
|
79
|
+
`on` enforces APCA contrast. The default target is Lc 60. If the resolver cannot
|
|
80
|
+
meet the target after the configured luminance shift and chroma reduction, it
|
|
81
|
+
throws.
|
|
82
|
+
|
|
83
|
+
## State Rules
|
|
84
|
+
|
|
85
|
+
`state` defaults to `"default"`.
|
|
86
|
+
|
|
87
|
+
When `state` is not `"default"`, `stateDirection` is required. Palette Kit never
|
|
88
|
+
infers whether a state should increase or decrease lightness.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
palette.resolve({
|
|
92
|
+
usage: "fill",
|
|
93
|
+
intent: "brand",
|
|
94
|
+
level: 4,
|
|
95
|
+
state: "hover",
|
|
96
|
+
stateDirection: "increase",
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Context Rules
|
|
101
|
+
|
|
102
|
+
Context is never inferred from the system or DOM.
|
|
103
|
+
|
|
104
|
+
Precedence:
|
|
105
|
+
|
|
106
|
+
1. Resolver-level `context`
|
|
107
|
+
2. Palette-level `context`
|
|
108
|
+
3. `systemDefaultContext`
|
|
109
|
+
|
|
110
|
+
If none is available, resolution throws.
|
|
111
|
+
|
|
112
|
+
Context affects default level curves. In dark context, the default fill and
|
|
113
|
+
lines curves use the inverted structural lightness scale while preserving
|
|
114
|
+
intent hue and chroma.
|
|
115
|
+
|
|
116
|
+
## Output Rules
|
|
117
|
+
|
|
118
|
+
| Output | Runtime status |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `oklch` | Returns normalized OKLCH object |
|
|
121
|
+
| `oklab` | Returns OKLab object |
|
|
122
|
+
| `srgb` | Returns `{ r, g, b, alpha }` |
|
|
123
|
+
| `p3` | Returns Display-P3 `{ r, g, b, alpha }` |
|
|
124
|
+
| `hex` | Serialized to `#rrggbb` |
|
|
125
|
+
| `rgba` | Serialized to `{ r, g, b, a }` |
|
|
126
|
+
|
|
127
|
+
RGB-like outputs use clipped 8-bit channels.
|
|
128
|
+
|
|
129
|
+
Output precedence:
|
|
130
|
+
|
|
131
|
+
1. Resolver-level `output`
|
|
132
|
+
2. Palette-level `output`
|
|
133
|
+
3. `systemDefaultOutput`
|
|
134
|
+
4. Explicit `oklch` default
|
|
135
|
+
|
|
136
|
+
## Public Types
|
|
137
|
+
|
|
138
|
+
The package root reexports:
|
|
139
|
+
|
|
140
|
+
- `PaletteKitConfig`
|
|
141
|
+
- `PaletteKit`
|
|
142
|
+
- `PaletteResolveOptions`
|
|
143
|
+
- `PaletteResolveOutput`
|
|
144
|
+
- `Usage`
|
|
145
|
+
- `Level`
|
|
146
|
+
- `State`
|
|
147
|
+
- `StateDeltaDirection`
|
|
148
|
+
- `Context`
|
|
149
|
+
- `ColorOutput`
|
|
150
|
+
- `OklchColor`
|
|
151
|
+
- `RgbColor`
|
|
152
|
+
- `RgbaColor`
|
|
153
|
+
- `IntentDefinition`
|
|
154
|
+
- `ResolverPresetName`
|
|
155
|
+
- `ResolverConfig`
|
|
156
|
+
- `ResolverConfigOverrides`
|
|
157
|
+
- `RelationParamsConfig`
|
|
158
|
+
- `ChromaConfig`
|
|
159
|
+
|
|
160
|
+
## Not Public in v0.4
|
|
161
|
+
|
|
162
|
+
- Intent registry helpers
|
|
163
|
+
- Validators
|
|
164
|
+
- Internal resolver helpers
|
|
165
|
+
- Serializer functions
|
|
166
|
+
- CLI
|
|
167
|
+
- Subpath exporters
|
package/docs/Alpha.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Alpha
|
|
2
|
+
|
|
3
|
+
Alpha is present in the normalized OKLCH model as `alpha`.
|
|
4
|
+
|
|
5
|
+
In the current v0.4 implementation:
|
|
6
|
+
|
|
7
|
+
- base resolved OKLCH colors use `alpha: 1`;
|
|
8
|
+
- `rgba` output maps alpha to `a`;
|
|
9
|
+
- `over` and `under` relations apply configured alpha by level;
|
|
10
|
+
- state alpha deltas from `resolverConfig` apply only to `overlays`;
|
|
11
|
+
- non-overlay usages preserve resolved alpha and never use alpha to satisfy
|
|
12
|
+
contrast.
|
|
13
|
+
|
|
14
|
+
Alpha behavior is explicit and deterministic.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
This document reflects the current v0.4 branch implementation.
|
|
4
|
+
|
|
5
|
+
## Public Flow
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
createPaletteKit(config) -> palette.resolve(options) -> output
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Resolution is deterministic and side-effect free.
|
|
12
|
+
|
|
13
|
+
## Main Layers
|
|
14
|
+
|
|
15
|
+
- `core`: OKLCH model and intent registry.
|
|
16
|
+
- `engine`: usage, level, state, relation, context, and resolver pipeline.
|
|
17
|
+
- `export`: output typing and serializers.
|
|
18
|
+
- `presets`: official resolver presets and config merge helpers.
|
|
19
|
+
- `types`: public type contracts reexported by the package root.
|
|
20
|
+
- `utils`: structured internal errors.
|
|
21
|
+
|
|
22
|
+
## Resolver Pipeline
|
|
23
|
+
|
|
24
|
+
The internal resolver:
|
|
25
|
+
|
|
26
|
+
1. validates usage, state, context, level, and relations;
|
|
27
|
+
2. looks up the registered intent;
|
|
28
|
+
3. selects the usage strategy;
|
|
29
|
+
4. applies context-aware level curves for level-driven usages;
|
|
30
|
+
5. applies relation validation and behavior;
|
|
31
|
+
6. applies explicit luminance state deltas and overlay alpha deltas;
|
|
32
|
+
7. applies structural context hooks;
|
|
33
|
+
8. returns normalized OKLCH.
|
|
34
|
+
|
|
35
|
+
Output serialization happens after resolution.
|
|
36
|
+
|
|
37
|
+
## Public Outputs
|
|
38
|
+
|
|
39
|
+
- `oklch`: normalized OKLCH object.
|
|
40
|
+
- `oklab`: OKLab object.
|
|
41
|
+
- `srgb`: clipped 8-bit sRGB object.
|
|
42
|
+
- `p3`: clipped 8-bit Display-P3 object.
|
|
43
|
+
- `hex`: serialized sRGB hex string.
|
|
44
|
+
- `rgba`: serialized sRGB object.
|
|
45
|
+
|
|
46
|
+
## Not Public in v0.4
|
|
47
|
+
|
|
48
|
+
- CLI
|
|
49
|
+
- subpath exporters
|
|
50
|
+
- serializer functions
|
|
51
|
+
- registry helpers
|
|
52
|
+
|
|
53
|
+
See also:
|
|
54
|
+
|
|
55
|
+
- [Resolver Pipeline Diagram](../planning/v0.4/diagrams/resolver-pipeline.md)
|
|
56
|
+
- [Axes Diagram](../planning/v0.4/diagrams/axes.md)
|
package/docs/CLI.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# CLI
|
|
2
|
+
|
|
3
|
+
Palette Kit v0.4 does not expose a public CLI.
|
|
4
|
+
|
|
5
|
+
There is no `bin` entry in the current package surface and no documented command
|
|
6
|
+
for generating tokens.
|
|
7
|
+
|
|
8
|
+
Use the runtime API directly:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
12
|
+
|
|
13
|
+
const palette = createPaletteKit({
|
|
14
|
+
context: "light",
|
|
15
|
+
intents: {
|
|
16
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
CLI support may be added in a future phase, but it is not part of v0.4 current
|
|
22
|
+
implementation.
|
package/docs/Concepts.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Concepts
|
|
2
|
+
|
|
3
|
+
Palette Kit v0.4 resolves colors from orthogonal axes instead of precomposed
|
|
4
|
+
tokens.
|
|
5
|
+
|
|
6
|
+
## Intent
|
|
7
|
+
|
|
8
|
+
An intent is a semantic hue and chroma anchor.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
intents: {
|
|
12
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
13
|
+
neutral: { hue: 0, chroma: 0 },
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Intent does not encode usage, level, state, relation, or context.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
`usage` describes how the color is used:
|
|
22
|
+
|
|
23
|
+
- `fill`
|
|
24
|
+
- `visualVocabulary`
|
|
25
|
+
- `lines`
|
|
26
|
+
- `overlays`
|
|
27
|
+
|
|
28
|
+
## Level
|
|
29
|
+
|
|
30
|
+
`level` is an explicit integer from `1` to `9`.
|
|
31
|
+
|
|
32
|
+
It is required for:
|
|
33
|
+
|
|
34
|
+
- `fill`
|
|
35
|
+
- `lines`
|
|
36
|
+
- `overlays`
|
|
37
|
+
|
|
38
|
+
It is forbidden for `visualVocabulary`.
|
|
39
|
+
|
|
40
|
+
## Relation
|
|
41
|
+
|
|
42
|
+
Relations connect one resolved color to another:
|
|
43
|
+
|
|
44
|
+
- `on`
|
|
45
|
+
- `over`
|
|
46
|
+
- `under`
|
|
47
|
+
|
|
48
|
+
`visualVocabulary` requires `on`.
|
|
49
|
+
|
|
50
|
+
## State
|
|
51
|
+
|
|
52
|
+
`state` defaults to `default`.
|
|
53
|
+
|
|
54
|
+
When state is not `default`, the caller must provide `stateDirection` as
|
|
55
|
+
`increase` or `decrease`.
|
|
56
|
+
|
|
57
|
+
## Context
|
|
58
|
+
|
|
59
|
+
Context is `light` or `dark`. It is never inferred automatically.
|
|
60
|
+
|
|
61
|
+
Precedence:
|
|
62
|
+
|
|
63
|
+
1. resolver-level context
|
|
64
|
+
2. palette-level context
|
|
65
|
+
3. system default context
|
|
66
|
+
|
|
67
|
+
## Output
|
|
68
|
+
|
|
69
|
+
Output is a delivery concern, not semantic input.
|
|
70
|
+
|
|
71
|
+
Changing output must not change internal OKLCH resolution.
|
|
72
|
+
|
|
73
|
+
See [What Never Happens](../planning/v0.4/diagrams/what-never-happens.md).
|
package/docs/Config.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
`createPaletteKit` accepts a small explicit configuration object.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
7
|
+
|
|
8
|
+
const palette = createPaletteKit({
|
|
9
|
+
context: "light",
|
|
10
|
+
output: "oklch",
|
|
11
|
+
intents: {
|
|
12
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
13
|
+
neutral: { hue: 0, chroma: 0 },
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## intents
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
Record<string, { hue: number; chroma: number }>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`intents` is required. Intent names must be flat strings:
|
|
25
|
+
|
|
26
|
+
- not empty
|
|
27
|
+
- no whitespace
|
|
28
|
+
- no `.`
|
|
29
|
+
|
|
30
|
+
`hue` must be finite and is normalized to `[0, 360)`. `chroma` must be finite
|
|
31
|
+
and greater than or equal to `0`.
|
|
32
|
+
|
|
33
|
+
Intent names must describe semantic meaning only. Names that encode usage,
|
|
34
|
+
state, relation, level, or visual implementation details are rejected. Keep
|
|
35
|
+
dimensions such as `fill`, `hover`, `on`, `strong`, `red`, and `dark` in
|
|
36
|
+
resolver options or configuration instead of intent names.
|
|
37
|
+
|
|
38
|
+
## context
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
"light" | "dark"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`context` is optional at palette creation. It becomes the default environment
|
|
45
|
+
for resolver calls.
|
|
46
|
+
|
|
47
|
+
Palette Kit never reads `prefers-color-scheme`, the DOM, or platform state.
|
|
48
|
+
|
|
49
|
+
Context affects default level curves. Dark context inverts the structural
|
|
50
|
+
lightness scale for `fill` and `lines` while preserving semantic hue and chroma.
|
|
51
|
+
|
|
52
|
+
## systemDefaultContext
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
"light" | "dark"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`systemDefaultContext` is an optional host-provided fallback.
|
|
59
|
+
|
|
60
|
+
Context precedence:
|
|
61
|
+
|
|
62
|
+
1. Resolver-level `context`
|
|
63
|
+
2. Palette-level `context`
|
|
64
|
+
3. `systemDefaultContext`
|
|
65
|
+
|
|
66
|
+
If no context can be resolved, `palette.resolve` throws.
|
|
67
|
+
|
|
68
|
+
## output
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
"oklch" | "oklab" | "srgb" | "p3" | "hex" | "rgba"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`output` is optional and defaults to `oklch`.
|
|
75
|
+
|
|
76
|
+
Runtime support in the current v0.4 implementation:
|
|
77
|
+
|
|
78
|
+
- `oklch`: supported
|
|
79
|
+
- `oklab`: supported
|
|
80
|
+
- `srgb`: supported
|
|
81
|
+
- `p3`: supported
|
|
82
|
+
- `hex`: supported
|
|
83
|
+
- `rgba`: supported
|
|
84
|
+
|
|
85
|
+
## systemDefaultOutput
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
"oklch" | "oklab" | "srgb" | "p3" | "hex" | "rgba"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`systemDefaultOutput` is an optional host-provided output fallback.
|
|
92
|
+
|
|
93
|
+
Output precedence:
|
|
94
|
+
|
|
95
|
+
1. Resolver-level `output`
|
|
96
|
+
2. Palette-level `output`
|
|
97
|
+
3. `systemDefaultOutput`
|
|
98
|
+
4. Explicit `oklch` default
|
|
99
|
+
|
|
100
|
+
## Presets and Resolver Config
|
|
101
|
+
|
|
102
|
+
`preset` is optional and defaults to `"neutral"`.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
createPaletteKit({
|
|
106
|
+
context: "light",
|
|
107
|
+
preset: "soft",
|
|
108
|
+
intents,
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Public presets:
|
|
113
|
+
|
|
114
|
+
- `soft`
|
|
115
|
+
- `neutral`
|
|
116
|
+
- `strong`
|
|
117
|
+
|
|
118
|
+
`resolverConfig` explicitly overrides the selected preset.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
createPaletteKit({
|
|
122
|
+
context: "light",
|
|
123
|
+
preset: "neutral",
|
|
124
|
+
intents,
|
|
125
|
+
resolverConfig: {
|
|
126
|
+
relationParams: {
|
|
127
|
+
on: { contrastTarget: 75 },
|
|
128
|
+
},
|
|
129
|
+
stateDeltas: {
|
|
130
|
+
luminance: { hover: 4 },
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Supported resolver config sections:
|
|
137
|
+
|
|
138
|
+
- `levelCurves`
|
|
139
|
+
- `stateDeltas`
|
|
140
|
+
- `relationParams`
|
|
141
|
+
- `chromaLimits`
|
|
142
|
+
|
|
143
|
+
The default `on` contrast target is APCA Lc 60. `over` and `under` alpha values
|
|
144
|
+
are configured per level.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Diagnostics
|
|
2
|
+
|
|
3
|
+
Palette Kit v0.4 does not expose a public diagnostics API.
|
|
4
|
+
|
|
5
|
+
Runtime misuse is reported through thrown errors. Core resolver/configuration
|
|
6
|
+
misuse uses structured internal `PaletteKitError` instances, but that class is
|
|
7
|
+
not part of the public API surface yet.
|
|
8
|
+
|
|
9
|
+
## Observable Error Areas
|
|
10
|
+
|
|
11
|
+
- unknown intent
|
|
12
|
+
- missing required level
|
|
13
|
+
- forbidden level on `visualVocabulary`
|
|
14
|
+
- missing `on` relation
|
|
15
|
+
- multiple relations
|
|
16
|
+
- unresolved context
|
|
17
|
+
- invalid or unsupported serialized output
|
|
18
|
+
|
|
19
|
+
## Current Recommendation
|
|
20
|
+
|
|
21
|
+
Catch errors at application boundaries and report the message. Do not depend on
|
|
22
|
+
internal error classes until they are explicitly exported.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Exporters
|
|
2
|
+
|
|
3
|
+
Palette Kit v0.4 does not expose public CSS or JSON exporters.
|
|
4
|
+
|
|
5
|
+
There is no public exporter subpath.
|
|
6
|
+
|
|
7
|
+
## Current Public Path
|
|
8
|
+
|
|
9
|
+
Build exported artifacts manually from `palette.resolve`.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const tokens = {
|
|
13
|
+
"brand.surface": palette.resolve({
|
|
14
|
+
usage: "fill",
|
|
15
|
+
intent: "brand",
|
|
16
|
+
level: 4,
|
|
17
|
+
output: "hex",
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Supported Runtime Outputs
|
|
23
|
+
|
|
24
|
+
- `oklch`
|
|
25
|
+
- `oklab`
|
|
26
|
+
- `srgb`
|
|
27
|
+
- `p3`
|
|
28
|
+
- `hex`
|
|
29
|
+
- `rgba`
|
|
30
|
+
|
|
31
|
+
## Future Work
|
|
32
|
+
|
|
33
|
+
Public exporters may be added after the minimal v0.4 resolver surface is stable.
|
package/docs/FAQ.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# FAQ
|
|
2
|
+
|
|
3
|
+
## What is the public API in v0.4?
|
|
4
|
+
|
|
5
|
+
The public runtime API is `createPaletteKit` from the package root.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The palette instance exposes `palette.resolve`.
|
|
12
|
+
|
|
13
|
+
## Does Palette Kit return CSS strings?
|
|
14
|
+
|
|
15
|
+
It depends on `output`.
|
|
16
|
+
|
|
17
|
+
- `output: "oklch"` returns a normalized OKLCH object.
|
|
18
|
+
- `output: "oklab"` returns an OKLab object.
|
|
19
|
+
- `output: "srgb"` returns `{ r, g, b, alpha }`.
|
|
20
|
+
- `output: "p3"` returns Display-P3 `{ r, g, b, alpha }`.
|
|
21
|
+
- `output: "hex"` returns a `#rrggbb` string.
|
|
22
|
+
- `output: "rgba"` returns `{ r, g, b, a }`.
|
|
23
|
+
|
|
24
|
+
## Are `oklab`, `srgb`, and `p3` supported?
|
|
25
|
+
|
|
26
|
+
Yes. `oklab` returns an OKLab object. `srgb` and `p3` return RGB-like objects
|
|
27
|
+
with `{ r, g, b, alpha }`.
|
|
28
|
+
|
|
29
|
+
## Is there a CLI?
|
|
30
|
+
|
|
31
|
+
No. There is no public CLI in the v0.4 branch.
|
|
32
|
+
|
|
33
|
+
## Can I export CSS variables or JSON tokens?
|
|
34
|
+
|
|
35
|
+
There is no public exporter subpath in v0.4. Build CSS, JSON, or token files
|
|
36
|
+
manually from `palette.resolve`.
|
|
37
|
+
|
|
38
|
+
## Are presets public?
|
|
39
|
+
|
|
40
|
+
Yes. `soft`, `neutral`, and `strong` are public resolver presets. The package
|
|
41
|
+
root also exports the preset config objects.
|
|
42
|
+
|
|
43
|
+
`createPaletteKit` accepts `preset` and explicit `resolverConfig` overrides.
|
|
44
|
+
|
|
45
|
+
## Does `on` enforce contrast?
|
|
46
|
+
|
|
47
|
+
Yes. `on` enforces APCA contrast with a default Lc 60 target and fails
|
|
48
|
+
explicitly if the target cannot be satisfied.
|
|
49
|
+
|
|
50
|
+
## Does Palette Kit detect dark mode?
|
|
51
|
+
|
|
52
|
+
No. Context is explicit. Provide `context`, resolver-level `context`, or
|
|
53
|
+
`systemDefaultContext`.
|
|
54
|
+
|
|
55
|
+
## Can output have a host default?
|
|
56
|
+
|
|
57
|
+
Yes. Use `systemDefaultOutput` when the host wants to inject a fallback. Resolver
|
|
58
|
+
output overrides palette output, palette output overrides `systemDefaultOutput`,
|
|
59
|
+
and `oklch` is used when none of those are provided.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Migration Notes for the v0.4 Branch
|
|
2
|
+
|
|
3
|
+
The v0.4 branch is a rebuild around `createPaletteKit` and orthogonal resolver
|
|
4
|
+
axes. It is not a continuation of the older theme factory API.
|
|
5
|
+
|
|
6
|
+
## Removed From the Public Surface
|
|
7
|
+
|
|
8
|
+
- legacy theme factory
|
|
9
|
+
- public exporter subpaths
|
|
10
|
+
- public serializer subpaths
|
|
11
|
+
- CLI commands
|
|
12
|
+
- seed-based theme config
|
|
13
|
+
- older public presets
|
|
14
|
+
|
|
15
|
+
## Current Public Surface
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
19
|
+
|
|
20
|
+
const palette = createPaletteKit({
|
|
21
|
+
context: "light",
|
|
22
|
+
intents: {
|
|
23
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
24
|
+
neutral: { hue: 0, chroma: 0 },
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Conceptual Migration
|
|
30
|
+
|
|
31
|
+
Older versions organized resolution around seeds, roles, surfaces, and theme
|
|
32
|
+
helpers. The v0.4 branch organizes resolution around explicit axes:
|
|
33
|
+
|
|
34
|
+
- `intent`
|
|
35
|
+
- `usage`
|
|
36
|
+
- `level`
|
|
37
|
+
- `relation`
|
|
38
|
+
- `state`
|
|
39
|
+
- `context`
|
|
40
|
+
- `output`
|
|
41
|
+
|
|
42
|
+
## Output Migration
|
|
43
|
+
|
|
44
|
+
Use resolver output directly:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const color = palette.resolve({
|
|
48
|
+
usage: "fill",
|
|
49
|
+
intent: "brand",
|
|
50
|
+
level: 4,
|
|
51
|
+
output: "hex",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
There is no public token exporter or CLI in the current v0.4 branch.
|
|
56
|
+
|
|
57
|
+
## References
|
|
58
|
+
|
|
59
|
+
- [API](./API.md)
|
|
60
|
+
- [Configuration](./Config.md)
|
|
61
|
+
- [v0.4 SPEC](../planning/v0.4/v0.4-palette-kit-spec.md)
|
package/docs/Overlays.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Overlays
|
|
2
|
+
|
|
3
|
+
`overlays` is a public usage value in v0.4.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const scrim = palette.resolve({
|
|
7
|
+
usage: "overlays",
|
|
8
|
+
intent: "neutral",
|
|
9
|
+
level: 1,
|
|
10
|
+
under: surface,
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- `level` is required.
|
|
17
|
+
- `on` is forbidden.
|
|
18
|
+
- `over` and `under` are optional relation targets.
|
|
19
|
+
|
|
20
|
+
## Current Behavior
|
|
21
|
+
|
|
22
|
+
The current v0.4 resolver applies configured relation behavior:
|
|
23
|
+
|
|
24
|
+
- base lightness is `50`;
|
|
25
|
+
- the overlay level curve can add a configured luminance delta;
|
|
26
|
+
- `over` applies alpha from `relationParams.over.baseAlphaByLevel`;
|
|
27
|
+
- `under` applies alpha from `relationParams.under.baseAlphaByLevel`;
|
|
28
|
+
- `under` also reduces lightness by
|
|
29
|
+
`relationParams.under.luminanceReduction`;
|
|
30
|
+
- non-default state can apply configured overlay alpha deltas when
|
|
31
|
+
`stateDirection` is provided;
|
|
32
|
+
|
|
33
|
+
`over` and `under` do not enforce contrast.
|