@zentrades-ui/tokens 0.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/README.md +192 -0
- package/package.json +16 -0
- package/src/constants.ts +758 -0
- package/src/default-tokens.ts +4 -0
- package/src/index.ts +65 -0
- package/src/schema.ts +65 -0
- package/tokens.json +1240 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @zentrades-ui/tokens
|
|
2
|
+
|
|
3
|
+
Design tokens for the Zen UI design system.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @zentrades-ui/tokens
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import the default tokens:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { defaultTokens } from "@zentrades-ui/tokens";
|
|
17
|
+
|
|
18
|
+
// Access token values
|
|
19
|
+
console.log(defaultTokens.color.themed.contentPrimary.light); // "#1a1a1a"
|
|
20
|
+
console.log(defaultTokens.spacing.units["8"]); // "8px"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Token Structure
|
|
24
|
+
|
|
25
|
+
### Colors
|
|
26
|
+
|
|
27
|
+
#### Primitive Palette
|
|
28
|
+
|
|
29
|
+
Raw color values organized by hue:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
defaultTokens.color.palette.brand // Brand colors (25-900)
|
|
33
|
+
defaultTokens.color.palette.grey // Grey scale
|
|
34
|
+
defaultTokens.color.palette.blue // Blue tones
|
|
35
|
+
defaultTokens.color.palette.red // Red tones
|
|
36
|
+
defaultTokens.color.palette.green // Green tones
|
|
37
|
+
// ... and more
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Themed Colors
|
|
41
|
+
|
|
42
|
+
Colors with light/dark mode variants:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// Content colors
|
|
46
|
+
defaultTokens.color.themed.contentPrimary // { light: "...", dark: "..." }
|
|
47
|
+
defaultTokens.color.themed.contentSecondary
|
|
48
|
+
defaultTokens.color.themed.contentTertiary
|
|
49
|
+
defaultTokens.color.themed.contentBrand
|
|
50
|
+
|
|
51
|
+
// Background colors
|
|
52
|
+
defaultTokens.color.themed.backgroundPrimary
|
|
53
|
+
defaultTokens.color.themed.backgroundSecondary
|
|
54
|
+
defaultTokens.color.themed.backgroundBrand
|
|
55
|
+
|
|
56
|
+
// Border colors
|
|
57
|
+
defaultTokens.color.themed.borderPrimary
|
|
58
|
+
defaultTokens.color.themed.borderSecondary
|
|
59
|
+
|
|
60
|
+
// Surface levels (L0-L6)
|
|
61
|
+
defaultTokens.color.themed.surfaceL0
|
|
62
|
+
defaultTokens.color.themed.surfaceL1
|
|
63
|
+
// ... up to surfaceL6
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Spacing
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
// Named tokens
|
|
70
|
+
defaultTokens.spacing.tokens.xs // 4px
|
|
71
|
+
defaultTokens.spacing.tokens.s // 8px
|
|
72
|
+
defaultTokens.spacing.tokens.m // 16px
|
|
73
|
+
defaultTokens.spacing.tokens.l // 24px
|
|
74
|
+
defaultTokens.spacing.tokens.xl // 32px
|
|
75
|
+
|
|
76
|
+
// Numeric scale
|
|
77
|
+
defaultTokens.spacing.units["1"] // 1px
|
|
78
|
+
defaultTokens.spacing.units["2"] // 2px
|
|
79
|
+
defaultTokens.spacing.units["4"] // 4px
|
|
80
|
+
defaultTokens.spacing.units["8"] // 8px
|
|
81
|
+
// ... and more
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Typography
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// Font families
|
|
88
|
+
defaultTokens.typography.fontFamilies.geist // "Geist, -apple-system, ..."
|
|
89
|
+
defaultTokens.typography.fontFamilies.mono // "Geist Mono, monospace, ..."
|
|
90
|
+
|
|
91
|
+
// Font sizes
|
|
92
|
+
defaultTokens.typography.fontSizes.xs // 0.625rem
|
|
93
|
+
defaultTokens.typography.fontSizes.s // 0.75rem
|
|
94
|
+
defaultTokens.typography.fontSizes.m // 0.875rem
|
|
95
|
+
defaultTokens.typography.fontSizes.l // 1rem
|
|
96
|
+
// ... up to 8xl
|
|
97
|
+
|
|
98
|
+
// Font weights
|
|
99
|
+
defaultTokens.typography.fontWeights.regular // 400
|
|
100
|
+
defaultTokens.typography.fontWeights.medium // 500
|
|
101
|
+
defaultTokens.typography.fontWeights.semibold // 600
|
|
102
|
+
defaultTokens.typography.fontWeights.bold // 700
|
|
103
|
+
|
|
104
|
+
// Line heights
|
|
105
|
+
defaultTokens.typography.lineHeights.xs // matching font sizes
|
|
106
|
+
defaultTokens.typography.lineHeights.s
|
|
107
|
+
// ...
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Border
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
// Border radius
|
|
114
|
+
defaultTokens.border.radius.xs // 0.25rem
|
|
115
|
+
defaultTokens.border.radius.sm // 0.375rem
|
|
116
|
+
defaultTokens.border.radius.md // 0.5rem
|
|
117
|
+
defaultTokens.border.radius.lg // 0.75rem
|
|
118
|
+
defaultTokens.border.radius.xl // 1rem
|
|
119
|
+
defaultTokens.border.radius.pill // 62.4375rem
|
|
120
|
+
defaultTokens.border.radius.circle // 50%
|
|
121
|
+
|
|
122
|
+
// Border width
|
|
123
|
+
defaultTokens.border.width.none // 0rem
|
|
124
|
+
defaultTokens.border.width.xs // 0.0625rem (1px)
|
|
125
|
+
defaultTokens.border.width.s // 0.09375rem (1.5px)
|
|
126
|
+
defaultTokens.border.width.m // 0.125rem (2px)
|
|
127
|
+
defaultTokens.border.width.l // 0.1875rem (3px)
|
|
128
|
+
defaultTokens.border.width.xl // 0.25rem (4px)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Shadows
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
defaultTokens.shadow.layers.L0 // No shadow
|
|
135
|
+
defaultTokens.shadow.layers.L1 // Subtle elevation
|
|
136
|
+
defaultTokens.shadow.layers.L2 // Light elevation
|
|
137
|
+
// ... up to L7
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## TypeScript Types
|
|
141
|
+
|
|
142
|
+
Import types for type-safe token access:
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import type { Tokens, ThemedColorVar, TokenScale } from "@zentrades-ui/tokens";
|
|
146
|
+
|
|
147
|
+
// Tokens is the full token object type
|
|
148
|
+
const myTokens: Tokens = { ... };
|
|
149
|
+
|
|
150
|
+
// ThemedColorVar is for light/dark color pairs
|
|
151
|
+
const color: ThemedColorVar = { light: "#fff", dark: "#000" };
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Using with @zentrades-ui/theme
|
|
155
|
+
|
|
156
|
+
Pass tokens to the ThemeProvider to generate CSS variables:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import { ThemeProvider } from "@zentrades-ui/theme";
|
|
160
|
+
import { defaultTokens } from "@zentrades-ui/tokens";
|
|
161
|
+
|
|
162
|
+
<ThemeProvider mode="light" tokens={defaultTokens}>
|
|
163
|
+
<App />
|
|
164
|
+
</ThemeProvider>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The theme provider converts tokens to CSS variables:
|
|
168
|
+
- `contentPrimary` → `--zen-color-contentprimary`
|
|
169
|
+
- `backgroundBrand` → `--zen-color-backgroundbrand`
|
|
170
|
+
- spacing `8` → `--zen-space-8`
|
|
171
|
+
|
|
172
|
+
## Custom Tokens
|
|
173
|
+
|
|
174
|
+
Create custom tokens by extending or overriding defaults:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { defaultTokens, Tokens } from "@zentrades-ui/tokens";
|
|
178
|
+
|
|
179
|
+
const customTokens: Tokens = {
|
|
180
|
+
...defaultTokens,
|
|
181
|
+
color: {
|
|
182
|
+
...defaultTokens.color,
|
|
183
|
+
themed: {
|
|
184
|
+
...defaultTokens.color.themed,
|
|
185
|
+
contentBrand: {
|
|
186
|
+
light: "#0066ff",
|
|
187
|
+
dark: "#3399ff",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zentrades-ui/tokens",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Design tokens for the Zen UI kit.",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"tokens.json"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false
|
|
16
|
+
}
|