@kolamui/tokens 0.0.0-canary-32a322e
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 +35 -0
- package/dist/index.d.ts +191 -0
- package/dist/index.js +2433 -0
- package/dist/tokens.css +611 -0
- package/dist/tokens.json +2256 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kolam contributors
|
|
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,35 @@
|
|
|
1
|
+
# @kolamui/tokens
|
|
2
|
+
|
|
3
|
+
Kolam's design tokens and the CSS variables built from them: colour primitives, light and dark modes, the high-contrast theme, spacing, radius, sizes, density, motion, z-index, opacity and typography.
|
|
4
|
+
|
|
5
|
+
> Kolam is in private alpha. Nothing is released yet; only canary builds are published.
|
|
6
|
+
|
|
7
|
+
## Use the CSS
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import "@kolamui/tokens/tokens.css";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then use the tokens by name, for example `var(--primary)` or `var(--radius-md)`.
|
|
14
|
+
|
|
15
|
+
- `data-mode="light"` or `data-mode="dark"` on any element switches the colour mode for that subtree. Without it, the page follows the OS colour scheme.
|
|
16
|
+
- `data-theme="high-contrast"` selects the high-contrast theme (light only). In light mode, `prefers-contrast: more` applies the same contrast overrides.
|
|
17
|
+
- `data-density="compact" | "default" | "comfortable"` sets control heights and paddings.
|
|
18
|
+
- `data-radius="none" | "sm" | "lg" | "full"` previews another corner radius setting.
|
|
19
|
+
- Typography classes: `.display-xl`, `.h1` to `.h4`, `.body`, `.ui`, `.caption`, `.code` and more.
|
|
20
|
+
|
|
21
|
+
## Use the tokens in code
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { generateCss, tokens } from "@kolamui/tokens";
|
|
25
|
+
|
|
26
|
+
tokens.color.tokens.find((t) => t.name === "accent")?.value.light; // "#E0502A"
|
|
27
|
+
|
|
28
|
+
const css = generateCss(tokens); // the same CSS as tokens.css
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`tokens` is typed (`Tokens`), and the raw file ships as `@kolamui/tokens/tokens.json`.
|
|
32
|
+
|
|
33
|
+
## Licence
|
|
34
|
+
|
|
35
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/** A value per colour mode. Tokens without a `contrast` value keep their light value in high contrast. */
|
|
2
|
+
interface ModeValues {
|
|
3
|
+
light: string;
|
|
4
|
+
dark: string;
|
|
5
|
+
contrast?: string;
|
|
6
|
+
}
|
|
7
|
+
/** A colour primitive reference such as `stone.900` or `vermilion.500`, per mode. */
|
|
8
|
+
type ModeRefs = ModeValues;
|
|
9
|
+
interface ContrastCheck {
|
|
10
|
+
grounds: string[];
|
|
11
|
+
/** Minimum contrast ratio per mode; a mode without a minimum is not checked. */
|
|
12
|
+
min: Partial<Record<keyof ModeValues, number>>;
|
|
13
|
+
}
|
|
14
|
+
interface ColorToken {
|
|
15
|
+
name: string;
|
|
16
|
+
/** Resolved hex (or rgba) values, kept for reading. */
|
|
17
|
+
value: ModeValues;
|
|
18
|
+
/** Primitive each mode points at. Tokens without a ref are written with their literal value. */
|
|
19
|
+
ref?: ModeRefs;
|
|
20
|
+
role: string;
|
|
21
|
+
check?: ContrastCheck;
|
|
22
|
+
usage: string;
|
|
23
|
+
}
|
|
24
|
+
interface ColorMode {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
note?: string;
|
|
28
|
+
}
|
|
29
|
+
interface ColorTokens {
|
|
30
|
+
note: string;
|
|
31
|
+
tokens: ColorToken[];
|
|
32
|
+
primitives: {
|
|
33
|
+
note: string;
|
|
34
|
+
/** family -> step -> hex */
|
|
35
|
+
families: Record<string, Record<string, string>>;
|
|
36
|
+
};
|
|
37
|
+
modes: ColorMode[];
|
|
38
|
+
}
|
|
39
|
+
interface ThemeSeed {
|
|
40
|
+
accent: string;
|
|
41
|
+
neutral: string;
|
|
42
|
+
primary: string;
|
|
43
|
+
radius: string;
|
|
44
|
+
font: {
|
|
45
|
+
sans: string;
|
|
46
|
+
mono: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
interface BuiltInTheme {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
tier: string;
|
|
53
|
+
modes: string;
|
|
54
|
+
seed: ThemeSeed;
|
|
55
|
+
description: string;
|
|
56
|
+
values?: string;
|
|
57
|
+
}
|
|
58
|
+
interface Themes {
|
|
59
|
+
note: string;
|
|
60
|
+
rule: string[];
|
|
61
|
+
builtIn: BuiltInTheme[];
|
|
62
|
+
}
|
|
63
|
+
interface TypeStyle {
|
|
64
|
+
name: string;
|
|
65
|
+
fontSize: string;
|
|
66
|
+
lineHeight: number | string;
|
|
67
|
+
fontWeight: number;
|
|
68
|
+
letterSpacing?: string;
|
|
69
|
+
usage: string;
|
|
70
|
+
sample: string;
|
|
71
|
+
}
|
|
72
|
+
interface TypeGroup {
|
|
73
|
+
name: string;
|
|
74
|
+
/** Key of `type.families`. */
|
|
75
|
+
family: string;
|
|
76
|
+
styles: TypeStyle[];
|
|
77
|
+
}
|
|
78
|
+
interface Typography {
|
|
79
|
+
fonts: unknown[];
|
|
80
|
+
families: Record<string, string>;
|
|
81
|
+
groups: TypeGroup[];
|
|
82
|
+
}
|
|
83
|
+
/** A token with one value for every mode. */
|
|
84
|
+
interface StaticToken {
|
|
85
|
+
name: string;
|
|
86
|
+
value: string;
|
|
87
|
+
usage: string;
|
|
88
|
+
options?: string[];
|
|
89
|
+
}
|
|
90
|
+
/** A token whose value may differ per colour mode. */
|
|
91
|
+
interface ModedToken {
|
|
92
|
+
name: string;
|
|
93
|
+
value: string | ModeValues;
|
|
94
|
+
usage: string;
|
|
95
|
+
}
|
|
96
|
+
interface SpringToken {
|
|
97
|
+
name: string;
|
|
98
|
+
value: {
|
|
99
|
+
stiffness: number;
|
|
100
|
+
damping: number;
|
|
101
|
+
};
|
|
102
|
+
usage: string;
|
|
103
|
+
}
|
|
104
|
+
interface StaggerToken {
|
|
105
|
+
name: string;
|
|
106
|
+
/** A number is read by JavaScript only and is not written as a CSS variable. */
|
|
107
|
+
value: string | number;
|
|
108
|
+
usage: string;
|
|
109
|
+
}
|
|
110
|
+
/** Radius scale for one radius setting: token name -> length. */
|
|
111
|
+
type RadiusScale = Record<string, string>;
|
|
112
|
+
type RadiusSettings = {
|
|
113
|
+
rule: string;
|
|
114
|
+
none: RadiusScale;
|
|
115
|
+
sm: RadiusScale;
|
|
116
|
+
md: RadiusScale;
|
|
117
|
+
lg: RadiusScale;
|
|
118
|
+
full: RadiusScale;
|
|
119
|
+
};
|
|
120
|
+
interface AliasToken {
|
|
121
|
+
name: string;
|
|
122
|
+
to: string;
|
|
123
|
+
}
|
|
124
|
+
interface Tokens {
|
|
125
|
+
name: string;
|
|
126
|
+
version: number;
|
|
127
|
+
color: ColorTokens;
|
|
128
|
+
themes: Themes;
|
|
129
|
+
type: Typography;
|
|
130
|
+
spacing: {
|
|
131
|
+
tokens: StaticToken[];
|
|
132
|
+
};
|
|
133
|
+
radius: {
|
|
134
|
+
tokens: StaticToken[];
|
|
135
|
+
note: string;
|
|
136
|
+
settings: RadiusSettings;
|
|
137
|
+
};
|
|
138
|
+
shadow: {
|
|
139
|
+
note: string;
|
|
140
|
+
tokens: ModedToken[];
|
|
141
|
+
};
|
|
142
|
+
focus: {
|
|
143
|
+
tokens: ModedToken[];
|
|
144
|
+
};
|
|
145
|
+
size: {
|
|
146
|
+
note: string;
|
|
147
|
+
tokens: StaticToken[];
|
|
148
|
+
};
|
|
149
|
+
density: {
|
|
150
|
+
note: string;
|
|
151
|
+
default: string;
|
|
152
|
+
modes: Record<string, Record<string, string>>;
|
|
153
|
+
touchMin: string;
|
|
154
|
+
};
|
|
155
|
+
layout: {
|
|
156
|
+
tokens: StaticToken[];
|
|
157
|
+
};
|
|
158
|
+
motion: {
|
|
159
|
+
note: string;
|
|
160
|
+
duration: StaticToken[];
|
|
161
|
+
easing: StaticToken[];
|
|
162
|
+
spring: SpringToken[];
|
|
163
|
+
stagger: StaggerToken[];
|
|
164
|
+
};
|
|
165
|
+
chart: {
|
|
166
|
+
tokens: StaticToken[];
|
|
167
|
+
};
|
|
168
|
+
zIndex: {
|
|
169
|
+
tokens: StaticToken[];
|
|
170
|
+
};
|
|
171
|
+
opacity: {
|
|
172
|
+
tokens: ModedToken[];
|
|
173
|
+
};
|
|
174
|
+
aliases: {
|
|
175
|
+
note: string;
|
|
176
|
+
tokens: AliasToken[];
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** Theme id of the light-only high-contrast theme: the kolam light values with the contrast set applied. */
|
|
180
|
+
export declare const HIGH_CONTRAST_THEME = "high-contrast";
|
|
181
|
+
/** A CSS custom property name. Dots (as in `space-1.5`) are escaped. */
|
|
182
|
+
export declare function cssVar(name: string): string;
|
|
183
|
+
/**
|
|
184
|
+
* Generates the CSS variables for a token set: primitives, light and dark modes (by attribute and
|
|
185
|
+
* by OS colour scheme), the high-contrast theme and prefers-contrast overrides, the mode-independent
|
|
186
|
+
* tokens, density and radius settings, and the typography classes.
|
|
187
|
+
*/
|
|
188
|
+
export declare function generateCss(tokens: Tokens): string;
|
|
189
|
+
/** Kolam's design tokens (the kolam theme), as published in `@kolamui/tokens/tokens.json`. */
|
|
190
|
+
export declare const tokens: Tokens;
|
|
191
|
+
export type { AliasToken, BuiltInTheme, ColorMode, ColorToken, ColorTokens, ContrastCheck, ModeRefs, ModeValues, ModedToken, RadiusScale, RadiusSettings, SpringToken, StaggerToken, StaticToken, ThemeSeed, Themes, Tokens, TypeGroup, TypeStyle, Typography };
|