@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/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Palette Kit v0.4 Documentation
|
|
2
|
+
|
|
3
|
+
This directory documents the current v0.4 branch implementation.
|
|
4
|
+
|
|
5
|
+
The public runtime surface is intentionally small:
|
|
6
|
+
|
|
7
|
+
- `createPaletteKit`
|
|
8
|
+
- `palette.resolve`
|
|
9
|
+
- official resolver preset configs
|
|
10
|
+
|
|
11
|
+
The package root also reexports public TypeScript types. Internal modules,
|
|
12
|
+
serializers, registries, validators, and resolver helpers are not public API.
|
|
13
|
+
|
|
14
|
+
## Start Here
|
|
15
|
+
|
|
16
|
+
- [API](./API.md)
|
|
17
|
+
- [Configuration](./Config.md)
|
|
18
|
+
- [Concepts](./Concepts.md)
|
|
19
|
+
- [Architecture](./Architecture.md)
|
|
20
|
+
- [Validation](./Validation.md)
|
|
21
|
+
- [FAQ](./FAQ.md)
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
- [Usage: Web](./Usage-Web.md)
|
|
26
|
+
- [Usage: React Native](./Usage-ReactNative.md)
|
|
27
|
+
- [Usage: JSON](./Usage-JSON.md)
|
|
28
|
+
|
|
29
|
+
## Status References
|
|
30
|
+
|
|
31
|
+
- [CLI](./CLI.md)
|
|
32
|
+
- [Exporters](./Exporters.md)
|
|
33
|
+
- [Tokens](./Tokens.md)
|
|
34
|
+
- [Diagnostics](./Diagnostics.md)
|
|
35
|
+
- [Alpha](./Alpha.md)
|
|
36
|
+
- [Overlays](./Overlays.md)
|
|
37
|
+
- [Text](./Text.md)
|
|
38
|
+
- [Why](./Why.md)
|
|
39
|
+
|
|
40
|
+
## v0.4 Planning References
|
|
41
|
+
|
|
42
|
+
- [v0.4 SPEC](../planning/v0.4/v0.4-palette-kit-spec.md)
|
|
43
|
+
- [Resolver Reference](../planning/v0.4/v0.4-resolver-reference.md)
|
|
44
|
+
- [Output Serialization Contract](../planning/v0.4/v0.4-output-serialization-contract.md)
|
|
45
|
+
- [Testing Strategy and Golden Cases](../planning/v0.4/v0.4-testing-strategy-golden-cases.md)
|
|
46
|
+
|
|
47
|
+
## Diagrams
|
|
48
|
+
|
|
49
|
+
- [Axes](../planning/v0.4/diagrams/axes.md)
|
|
50
|
+
- [Context](../planning/v0.4/diagrams/context.md)
|
|
51
|
+
- [Relations](../planning/v0.4/diagrams/relations.md)
|
|
52
|
+
- [Resolver Pipeline](../planning/v0.4/diagrams/resolver-pipeline.md)
|
|
53
|
+
- [What Never Happens](../planning/v0.4/diagrams/what-never-happens.md)
|
|
54
|
+
|
|
55
|
+
## Historical Documents
|
|
56
|
+
|
|
57
|
+
- [Legacy spec](./spec-legacy.md)
|
|
58
|
+
|
|
59
|
+
The legacy spec and manifesto files are historical context. They do not define
|
|
60
|
+
the current v0.4 public API.
|
package/docs/Text.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Text and Visual Vocabulary
|
|
2
|
+
|
|
3
|
+
Text, icons, and similar foreground elements use:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
usage: "visualVocabulary"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Rules
|
|
10
|
+
|
|
11
|
+
`visualVocabulary`:
|
|
12
|
+
|
|
13
|
+
- requires `on`;
|
|
14
|
+
- forbids `level`;
|
|
15
|
+
- resolves from the selected intent and relation target.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
const surface = palette.resolve({
|
|
19
|
+
usage: "fill",
|
|
20
|
+
intent: "neutral",
|
|
21
|
+
level: 2,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const text = palette.resolve({
|
|
25
|
+
usage: "visualVocabulary",
|
|
26
|
+
intent: "brand",
|
|
27
|
+
on: surface,
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Current Behavior
|
|
32
|
+
|
|
33
|
+
`on` enforces APCA contrast. The default target is Lc 60. APCA is the primary
|
|
34
|
+
metric; WCAG contrast is available as a fallback diagnostic when APCA does not
|
|
35
|
+
produce a usable numeric value.
|
|
36
|
+
|
|
37
|
+
The resolver first adjusts OKLCH lightness while preserving hue. If luminance
|
|
38
|
+
alone is insufficient, it may reduce chroma within the configured limits. If the
|
|
39
|
+
target still cannot be reached, resolution throws.
|
|
40
|
+
|
|
41
|
+
The contrast solver never changes alpha for `visualVocabulary`.
|
package/docs/Tokens.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Tokens
|
|
2
|
+
|
|
3
|
+
Palette Kit v0.4 does not expose a public token registry or token exporter.
|
|
4
|
+
|
|
5
|
+
The current model resolves colors from axes. Applications may store the resolved
|
|
6
|
+
values as tokens if they need build artifacts.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
const tokens = {
|
|
10
|
+
"surface.default": palette.resolve({
|
|
11
|
+
usage: "fill",
|
|
12
|
+
intent: "neutral",
|
|
13
|
+
level: 2,
|
|
14
|
+
output: "hex",
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Important Constraint
|
|
20
|
+
|
|
21
|
+
Palette Kit rejects intent names that encode usage, state, relation, level, or
|
|
22
|
+
visual implementation details. Keep those dimensions in resolver options.
|
|
23
|
+
|
|
24
|
+
Prefer:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
palette.resolve({
|
|
28
|
+
usage: "fill",
|
|
29
|
+
intent: "brand",
|
|
30
|
+
level: 4,
|
|
31
|
+
state: "hover",
|
|
32
|
+
stateDirection: "increase",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Avoid designing intent names such as:
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
brandFillHoverOnDark
|
|
40
|
+
dangerStrong
|
|
41
|
+
successText
|
|
42
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Usage: JSON
|
|
2
|
+
|
|
3
|
+
Palette Kit v0.4 does not expose a public JSON exporter. Build JSON manually
|
|
4
|
+
from `palette.resolve` outputs.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
8
|
+
|
|
9
|
+
const palette = createPaletteKit({
|
|
10
|
+
context: "light",
|
|
11
|
+
intents: {
|
|
12
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
13
|
+
neutral: { hue: 0, chroma: 0 },
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const tokens = {
|
|
18
|
+
"surface.default": palette.resolve({
|
|
19
|
+
usage: "fill",
|
|
20
|
+
intent: "neutral",
|
|
21
|
+
level: 2,
|
|
22
|
+
output: "hex",
|
|
23
|
+
}),
|
|
24
|
+
"brand.default": palette.resolve({
|
|
25
|
+
usage: "fill",
|
|
26
|
+
intent: "brand",
|
|
27
|
+
level: 4,
|
|
28
|
+
output: "hex",
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const json = JSON.stringify(tokens, null, 2);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Notes
|
|
36
|
+
|
|
37
|
+
- There is no public exporter subpath in v0.4.
|
|
38
|
+
- `hex` and `rgba` are supported runtime outputs.
|
|
39
|
+
- `oklch`, `oklab`, `srgb`, and `p3` are also supported runtime outputs.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Usage: React Native
|
|
2
|
+
|
|
3
|
+
React Native needs platform-compatible color values. In v0.4, use
|
|
4
|
+
`output: "rgba"` for public runtime output.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
8
|
+
|
|
9
|
+
const palette = createPaletteKit({
|
|
10
|
+
context: "light",
|
|
11
|
+
output: "rgba",
|
|
12
|
+
intents: {
|
|
13
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
14
|
+
neutral: { hue: 0, chroma: 0 },
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Resolve RGBA
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const background = palette.resolve({
|
|
23
|
+
usage: "fill",
|
|
24
|
+
intent: "brand",
|
|
25
|
+
level: 4,
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`background` has this shape:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
type RgbaColor = {
|
|
33
|
+
r: number;
|
|
34
|
+
g: number;
|
|
35
|
+
b: number;
|
|
36
|
+
a: number;
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Convert it to a React Native string if needed:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const rnColor = `rgba(${background.r}, ${background.g}, ${background.b}, ${background.a})`;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Resolver Override
|
|
47
|
+
|
|
48
|
+
You can override output per call:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const hex = palette.resolve({
|
|
52
|
+
usage: "fill",
|
|
53
|
+
intent: "brand",
|
|
54
|
+
level: 4,
|
|
55
|
+
output: "hex",
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Notes
|
|
60
|
+
|
|
61
|
+
- Palette Kit does not inspect platform color scheme automatically.
|
|
62
|
+
- Provide `context` or `systemDefaultContext` explicitly.
|
|
63
|
+
- `rgba` is usually the most direct React Native output.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Usage: Web
|
|
2
|
+
|
|
3
|
+
Use `createPaletteKit` from the package root.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createPaletteKit } from "@clhaas/palette-kit";
|
|
7
|
+
|
|
8
|
+
const palette = createPaletteKit({
|
|
9
|
+
context: "light",
|
|
10
|
+
intents: {
|
|
11
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
12
|
+
neutral: { hue: 0, chroma: 0 },
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Resolve OKLCH
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const surface = palette.resolve({
|
|
21
|
+
usage: "fill",
|
|
22
|
+
intent: "neutral",
|
|
23
|
+
level: 2,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The default output is a normalized OKLCH object.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
surface.space; // "oklch"
|
|
31
|
+
surface.l; // number in 0..100
|
|
32
|
+
surface.c; // number >= 0
|
|
33
|
+
surface.h; // number in [0, 360)
|
|
34
|
+
surface.alpha; // number in 0..1
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Resolve Hex
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const background = palette.resolve({
|
|
41
|
+
usage: "fill",
|
|
42
|
+
intent: "brand",
|
|
43
|
+
level: 4,
|
|
44
|
+
output: "hex",
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
document.documentElement.style.setProperty("--brand-bg", background);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Resolve Related Text
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const text = palette.resolve({
|
|
54
|
+
usage: "visualVocabulary",
|
|
55
|
+
intent: "brand",
|
|
56
|
+
on: surface,
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`visualVocabulary` requires `on` and forbids `level`.
|
|
61
|
+
|
|
62
|
+
## Notes
|
|
63
|
+
|
|
64
|
+
- `fill`, `lines`, and `overlays` require `level`.
|
|
65
|
+
- `state !== "default"` requires `stateDirection`.
|
|
66
|
+
- `hex`, `rgba`, `srgb`, and `p3` are available for platform delivery.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Validation
|
|
2
|
+
|
|
3
|
+
This document lists observable validation behavior in the current v0.4 branch.
|
|
4
|
+
|
|
5
|
+
## Intent Registry
|
|
6
|
+
|
|
7
|
+
Intent names must be flat strings:
|
|
8
|
+
|
|
9
|
+
- not empty
|
|
10
|
+
- no whitespace
|
|
11
|
+
- no `.`
|
|
12
|
+
- no encoded usage, state, relation, level, or visual implementation tokens
|
|
13
|
+
|
|
14
|
+
Intent values must include finite numeric `hue` and `chroma`. Chroma must be
|
|
15
|
+
greater than or equal to `0`.
|
|
16
|
+
|
|
17
|
+
Examples of rejected names include `textIncome`, `incomeHover`,
|
|
18
|
+
`incomeOverlay`, `incomeStrong`, and `redAlert`.
|
|
19
|
+
|
|
20
|
+
Unknown intents throw:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
Unknown intent "<name>". Did you forget to register it in the Intent Registry?
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Valid usages:
|
|
29
|
+
|
|
30
|
+
- `fill`
|
|
31
|
+
- `visualVocabulary`
|
|
32
|
+
- `lines`
|
|
33
|
+
- `overlays`
|
|
34
|
+
|
|
35
|
+
Unknown usages throw a message listing the valid usages.
|
|
36
|
+
|
|
37
|
+
## Level
|
|
38
|
+
|
|
39
|
+
Valid levels are integers from `1` to `9`.
|
|
40
|
+
|
|
41
|
+
Level rules:
|
|
42
|
+
|
|
43
|
+
- `fill`, `lines`, and `overlays` require `level`.
|
|
44
|
+
- `visualVocabulary` forbids `level`.
|
|
45
|
+
|
|
46
|
+
## Relations
|
|
47
|
+
|
|
48
|
+
Only one relation may be provided per resolve call.
|
|
49
|
+
|
|
50
|
+
Relation rules:
|
|
51
|
+
|
|
52
|
+
- `visualVocabulary` requires `on`.
|
|
53
|
+
- `overlays` forbids `on`.
|
|
54
|
+
- `fill` and `lines` allow `on`.
|
|
55
|
+
|
|
56
|
+
Relation targets must be normalized OKLCH colors.
|
|
57
|
+
|
|
58
|
+
## State
|
|
59
|
+
|
|
60
|
+
Valid states:
|
|
61
|
+
|
|
62
|
+
- `default`
|
|
63
|
+
- `hover`
|
|
64
|
+
- `active`
|
|
65
|
+
- `focus`
|
|
66
|
+
- `selected`
|
|
67
|
+
- `disabled`
|
|
68
|
+
|
|
69
|
+
When `state` is not `default`, `stateDirection` is required.
|
|
70
|
+
|
|
71
|
+
## Context
|
|
72
|
+
|
|
73
|
+
Valid contexts:
|
|
74
|
+
|
|
75
|
+
- `light`
|
|
76
|
+
- `dark`
|
|
77
|
+
|
|
78
|
+
If resolver context, palette context, and system default context are all absent,
|
|
79
|
+
resolution throws:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
Context could not be resolved. Provide resolverContext, paletteContext, or systemDefaultContext.
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Output
|
|
86
|
+
|
|
87
|
+
Valid output names:
|
|
88
|
+
|
|
89
|
+
- `oklch`
|
|
90
|
+
- `oklab`
|
|
91
|
+
- `srgb`
|
|
92
|
+
- `p3`
|
|
93
|
+
- `hex`
|
|
94
|
+
- `rgba`
|
|
95
|
+
|
|
96
|
+
Runtime serialization supports all valid output names. RGB-like outputs use
|
|
97
|
+
explicit clip gamut handling.
|
package/docs/Why.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Why
|
|
2
|
+
|
|
3
|
+
Palette Kit exists to make semantic color resolution deterministic without
|
|
4
|
+
forcing applications to maintain large sets of precomposed color tokens.
|
|
5
|
+
|
|
6
|
+
## Design Direction
|
|
7
|
+
|
|
8
|
+
Instead of names like `brandHoverTextOnDark`, v0.4 separates decisions into
|
|
9
|
+
axes:
|
|
10
|
+
|
|
11
|
+
- intent
|
|
12
|
+
- usage
|
|
13
|
+
- level
|
|
14
|
+
- relation
|
|
15
|
+
- state
|
|
16
|
+
- context
|
|
17
|
+
- output
|
|
18
|
+
|
|
19
|
+
This keeps meaning separate from presentation and environment.
|
|
20
|
+
|
|
21
|
+
## Current v0.4 Constraints
|
|
22
|
+
|
|
23
|
+
- Public runtime API is `createPaletteKit`.
|
|
24
|
+
- Resolution is internal OKLCH.
|
|
25
|
+
- Context is explicit and never inferred.
|
|
26
|
+
- Level is explicit and never inferred.
|
|
27
|
+
- Output is applied after resolution.
|
|
28
|
+
- `on` enforces APCA contrast explicitly.
|
|
29
|
+
- `hex`, `rgba`, `oklab`, `srgb`, and `p3` are supported delivery formats.
|
|
30
|
+
- Presets and resolver config are explicit public configuration.
|
|
31
|
+
- CLI and exporters are not public.
|
|
32
|
+
|
|
33
|
+
## Trade-Off
|
|
34
|
+
|
|
35
|
+
The current v0.4 branch favors an auditable API over broad convenience tooling.
|
|
36
|
+
CLI commands, token exporters, and codegen can be added later without changing
|
|
37
|
+
the resolver model.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# API Surface Report
|
|
2
|
+
|
|
3
|
+
This report reflects the current v0.4 branch package root.
|
|
4
|
+
|
|
5
|
+
## Runtime Exports
|
|
6
|
+
|
|
7
|
+
- `createPaletteKit`
|
|
8
|
+
- `defaultResolverConfig`
|
|
9
|
+
- `neutralResolverConfig`
|
|
10
|
+
- `softResolverConfig`
|
|
11
|
+
- `strongResolverConfig`
|
|
12
|
+
|
|
13
|
+
## Type Exports
|
|
14
|
+
|
|
15
|
+
- `PaletteKitConfig`
|
|
16
|
+
- `PaletteKit`
|
|
17
|
+
- `PaletteResolveOptions`
|
|
18
|
+
- `PaletteResolveOutput`
|
|
19
|
+
- `Usage`
|
|
20
|
+
- `Level`
|
|
21
|
+
- `State`
|
|
22
|
+
- `StateDeltaDirection`
|
|
23
|
+
- `Context`
|
|
24
|
+
- `ColorOutput`
|
|
25
|
+
- `OklchColor`
|
|
26
|
+
- `RgbColor`
|
|
27
|
+
- `RgbaColor`
|
|
28
|
+
- `IntentDefinition`
|
|
29
|
+
- `ResolverPresetName`
|
|
30
|
+
- `ResolverConfig`
|
|
31
|
+
- `RelationParamsConfig`
|
|
32
|
+
- `ChromaConfig`
|
|
33
|
+
|
|
34
|
+
## Public Package Exports
|
|
35
|
+
|
|
36
|
+
Only the root export is public:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Not Exported
|
|
48
|
+
|
|
49
|
+
- CLI
|
|
50
|
+
- exporter subpaths
|
|
51
|
+
- intent registry helpers
|
|
52
|
+
- internal resolver helpers
|
|
53
|
+
- serializer functions
|
package/docs/spec.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Palette Kit v0.4 Current Implementation Spec
|
|
2
|
+
|
|
3
|
+
This document summarizes the current v0.4 branch implementation. The complete
|
|
4
|
+
planning specification lives in
|
|
5
|
+
[planning/v0.4/v0.4-palette-kit-spec.md](../planning/v0.4/v0.4-palette-kit-spec.md).
|
|
6
|
+
|
|
7
|
+
## Public Scope
|
|
8
|
+
|
|
9
|
+
The package root exposes:
|
|
10
|
+
|
|
11
|
+
- `createPaletteKit`
|
|
12
|
+
- `softResolverConfig`
|
|
13
|
+
- `neutralResolverConfig`
|
|
14
|
+
- `strongResolverConfig`
|
|
15
|
+
- `defaultResolverConfig`
|
|
16
|
+
- public TypeScript types
|
|
17
|
+
|
|
18
|
+
The package root does not expose CLI commands, subpath exporters, serializer
|
|
19
|
+
functions, validators, or internal resolver helpers.
|
|
20
|
+
|
|
21
|
+
## Public Configuration
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
createPaletteKit({
|
|
25
|
+
context: "light",
|
|
26
|
+
output: "oklch",
|
|
27
|
+
intents: {
|
|
28
|
+
brand: { hue: 260, chroma: 0.14 },
|
|
29
|
+
neutral: { hue: 0, chroma: 0 },
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The public config supports:
|
|
35
|
+
|
|
36
|
+
- `intents`
|
|
37
|
+
- `context`
|
|
38
|
+
- `systemDefaultContext`
|
|
39
|
+
- `output`
|
|
40
|
+
- `systemDefaultOutput`
|
|
41
|
+
- `preset`
|
|
42
|
+
- `resolverConfig`
|
|
43
|
+
|
|
44
|
+
## Resolver Axes
|
|
45
|
+
|
|
46
|
+
`palette.resolve` accepts:
|
|
47
|
+
|
|
48
|
+
- `usage`
|
|
49
|
+
- `intent`
|
|
50
|
+
- `level`
|
|
51
|
+
- `on`
|
|
52
|
+
- `over`
|
|
53
|
+
- `under`
|
|
54
|
+
- `state`
|
|
55
|
+
- `stateDirection`
|
|
56
|
+
- `context`
|
|
57
|
+
- `output`
|
|
58
|
+
|
|
59
|
+
The resolver is deterministic and resolves internally in OKLCH.
|
|
60
|
+
|
|
61
|
+
## Implemented Outputs
|
|
62
|
+
|
|
63
|
+
- `oklch`
|
|
64
|
+
- `oklab`
|
|
65
|
+
- `srgb`
|
|
66
|
+
- `p3`
|
|
67
|
+
- `hex`
|
|
68
|
+
- `rgba`
|
|
69
|
+
|
|
70
|
+
RGB-like outputs use clipped 8-bit channels. `p3` uses Display-P3 conversion
|
|
71
|
+
and the current explicit clip gamut strategy.
|
|
72
|
+
|
|
73
|
+
## Implemented Guarantees
|
|
74
|
+
|
|
75
|
+
- Same input produces the same output.
|
|
76
|
+
- Output format does not change internal OKLCH resolution.
|
|
77
|
+
- Context is explicit and never inferred.
|
|
78
|
+
- Context affects structural level curves while preserving semantic intent.
|
|
79
|
+
- Level is explicit and never inferred.
|
|
80
|
+
- Non-default state requires `stateDirection`.
|
|
81
|
+
- Forbidden axis combinations throw.
|
|
82
|
+
- `on` enforces APCA contrast with a default Lc 60 target and exposes WCAG as a
|
|
83
|
+
fallback diagnostic.
|
|
84
|
+
- `over` applies configured alpha by level.
|
|
85
|
+
- `under` applies configured alpha and luminance reduction by level.
|
|
86
|
+
- State alpha deltas apply only where alpha is allowed, currently `overlays`.
|
|
87
|
+
- Intent names are semantic-only and cannot encode usage, state, relation,
|
|
88
|
+
level, or visual implementation details.
|
|
89
|
+
|
|
90
|
+
## Current Limitations
|
|
91
|
+
|
|
92
|
+
- CLI and exporters are not public in v0.4.
|
|
93
|
+
|
|
94
|
+
## References
|
|
95
|
+
|
|
96
|
+
- [Resolver Reference](../planning/v0.4/v0.4-resolver-reference.md)
|
|
97
|
+
- [Output Serialization Contract](../planning/v0.4/v0.4-output-serialization-contract.md)
|
|
98
|
+
- [Testing Strategy](../planning/v0.4/v0.4-testing-strategy-golden-cases.md)
|