@animus-ui/theming 0.1.0-next.23 → 0.1.0-next.31
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/CLAUDE.md +20 -20
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @animus-ui/theming — Legacy Theme Builder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Status: Legacy.** Consumers use `createTheme` and `ThemeBuilder` from `@animus-ui/system`, which re-exports them. Do not add new API surface here — extend system instead.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- `src/utils/serializeTokens.ts` — Token→CSS variable generation
|
|
7
|
-
- `src/utils/flattenScale.ts` — Nested object flattening with `-` separator
|
|
5
|
+
## What This Package Is
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
ThemeBuilder fluent API for defining design tokens and their CSS variable bindings. System re-exports `createTheme`, `ThemeBuilder`, `flattenScale`, and `serializeTokens`.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
createTheme(base)
|
|
13
|
-
.addColors({...}) → flat colors + CSS vars
|
|
14
|
-
.addColorModes('dark', {}) → semantic aliases per mode
|
|
15
|
-
.addScale('shadows', fn) → custom scales (can reference colors)
|
|
16
|
-
.createScaleVariables(key) → convert scale to CSS vars
|
|
17
|
-
.build() → final theme object
|
|
18
|
-
```
|
|
9
|
+
## Emission Tracking
|
|
19
10
|
|
|
20
|
-
|
|
11
|
+
Not all scales produce CSS variables. The distinction matters for extraction:
|
|
21
12
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
13
|
+
- `addColors({...})` — always emits CSS variables (`--color-primary`, etc.)
|
|
14
|
+
- `addScale({ name, values, emit: true })` — opts into CSS variable emission
|
|
15
|
+
- `addScale({ name, values })` — raw values only, no CSS variables
|
|
25
16
|
|
|
26
|
-
|
|
17
|
+
The `Emitted` generic parameter accumulates through the builder chain, tracking which scales have CSS variables. This powers `EmittedScales<T>` and `EmittedTokenPaths<T>` — used to validate `{scale.key}` token references at the type level.
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
## serialize() Output
|
|
20
|
+
|
|
21
|
+
`tokens.serialize()` produces the `SerializedTheme` consumed by the extraction pipeline:
|
|
22
|
+
|
|
23
|
+
| Field | Content | Consumer |
|
|
24
|
+
|-------|---------|----------|
|
|
25
|
+
| `scalesJson` | Flattened `"scale.key" → "value"` | Rust theme_resolver |
|
|
26
|
+
| `variableMapJson` | `"colors.primary" → "--color-primary"` | Rust token alias resolution |
|
|
27
|
+
| `variableCss` | `:root { --color-*: ... }` declarations | Vite plugin virtual module |
|
|
28
|
+
| `contextualVarsJson` | Per-scale contextual var names | Rust contextual resolution |
|