@x12i/tokens 0.0.0-stage → 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 x12i
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 CHANGED
@@ -1,3 +1,86 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @x12i/tokens
2
+
3
+ Design tokens for the Unified UI Kit. One W3C DTCG JSON source, compiled by
4
+ Style Dictionary into everything the kit needs.
5
+
6
+ | Output | Path | Use |
7
+ | --- | --- | --- |
8
+ | CSS custom properties, prefixed `--kit-` | `@x12i/tokens/css/*.css` | Runtime theming |
9
+ | Tailwind v4 `@theme` mapping | `@x12i/tokens/tailwind.css` | Utility classes that read the same variables |
10
+ | Typed TypeScript constants | `@x12i/tokens` | Charts and canvases that need raw values |
11
+ | `DESIGN.md` text | `@x12i/tokens/design-md` | Telling a coding agent what the kit looks like |
12
+ | Tokens Studio JSON | `@x12i/tokens/tokens-studio.json` | Syncing with Figma |
13
+ | DTCG source | `@x12i/tokens/dtcg/*` | Your own tooling |
14
+
15
+ Most apps want [`@x12i/themes`](../themes), which packages the CSS files with
16
+ system-preference defaults. Use this package directly for the TypeScript
17
+ constants or the Tailwind mapping.
18
+
19
+ ## Tiers
20
+
21
+ - **Primitive** (`src/dtcg/primitive`): raw values such as `color.neutral.9` and
22
+ `space.3`. Color primitives are never referenced by components.
23
+ - **Semantic** (`src/dtcg/semantic`): meaning by role, such as `color.bg.surface`
24
+ and `color.accent.default`. Themes (`themes/`) and densities (`density/`) each
25
+ define the same paths with different values.
26
+ - **Component** (`src/dtcg/component`): per-component values, only when no
27
+ semantic token fits, such as `button.height.md`.
28
+
29
+ ## Usage
30
+
31
+ ```ts
32
+ import { cssVar, themes } from "@x12i/tokens";
33
+
34
+ cssVar("color.bg.surface"); // "var(--kit-color-bg-surface)"
35
+ themes.dark.color.chart.categorical["1"]; // a hex string, for canvas code
36
+ ```
37
+
38
+ Tailwind v4:
39
+
40
+ ```css
41
+ @import "tailwindcss";
42
+ @import "@x12i/themes/themes.css";
43
+ @import "@x12i/tokens/tailwind.css";
44
+ ```
45
+
46
+ Utilities mirror token paths, for example `bg-bg-surface` and `text-text-secondary`.
47
+ The mapping uses `@theme inline`, so switching `data-theme` needs no rebuild.
48
+
49
+ ## DESIGN.md
50
+
51
+ A [DESIGN.md](https://github.com/google-labs-code/design.md) is the file a coding
52
+ agent reads to learn a project's visual identity: colors, type, spacing, shapes,
53
+ components and a few rules in prose. `createDesignMd` writes one for the kit from
54
+ the tokens in this package, so it cannot drift from the CSS.
55
+
56
+ ```ts
57
+ import { createDesignMd } from "@x12i/tokens/design-md";
58
+
59
+ const markdown = createDesignMd({ theme: "dark" }); // "light" (default), "dark" or "hc"
60
+ ```
61
+
62
+ Each theme gets its own file, with that theme's real color values. The prose names
63
+ the kit's CSS variables, covers motion, and ends with do's and don'ts, including
64
+ running `kit doctor` before finishing. `npx @x12i/kit-cli design` writes the file
65
+ into a project.
66
+
67
+ It lives in its own entry, so apps that only want the token constants do not load
68
+ the generator (about 15 KB). The tests lint every theme's file with
69
+ `@google/design.md` and fail on a broken reference or a contrast problem between
70
+ a component's text and its background.
71
+
72
+ ## Scripts
73
+
74
+ - `pnpm build:tokens` compiles the DTCG source. The TypeScript constants land in
75
+ `src/generated` (git-ignored) and are bundled by `pnpm build`.
76
+ - `pnpm generate:ramps` rewrites `src/dtcg/primitive/color.json` from the ramp
77
+ recipes in `scripts/generate-ramps.mjs`. The committed JSON is the source of
78
+ truth afterwards.
79
+ - `pnpm test` runs the contrast test, which computes the ratio of every semantic
80
+ text and background pair in every theme (4.5:1 for text, 3:1 for UI, and 7:1
81
+ and 4.5:1 for `hc`) and fails on a regression.
82
+
83
+ ## Status
84
+
85
+ Color values are placeholders until the visual target is signed off. The
86
+ categorical palette still needs a color-blindness check.