@calcifer-design/tokens 0.2.0 → 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.
@@ -0,0 +1,61 @@
1
+ import type { ColorName, SharedTokens, ThemeTokens } from './tokens.js';
2
+ type Leaf = string | number;
3
+ /** Every leaf widened to `string`: the shape of a resolved theme. */
4
+ export type TokenValues<Tree> = {
5
+ readonly [Key in keyof Tree]: Tree[Key] extends Leaf ? string : TokenValues<Tree[Key]>;
6
+ };
7
+ /** Every node optional, every leaf a string: what a brand may override. */
8
+ export type TokenOverrides<Tree> = {
9
+ readonly [Key in keyof Tree]?: Tree[Key] extends Leaf ? string : TokenOverrides<Tree[Key]>;
10
+ };
11
+ /** Maps any key the shape lacks to `never`, recursively through objects (not arrays), so a spread object fails too. */
12
+ export type NoExtraKeys<Candidate, Shape> = {
13
+ readonly [Key in keyof Candidate]: Key extends keyof Shape ? Candidate[Key] extends readonly unknown[] ? Candidate[Key] : Candidate[Key] extends object ? NoExtraKeys<Candidate[Key], NonNullable<Shape[Key]>> : Candidate[Key] : never;
14
+ };
15
+ export type ContrastPair = readonly [ColorName, ColorName];
16
+ /**
17
+ * Brand-only tokens the library never reads, emitted as `--<prefix>-<kebab(name)>` in every block
18
+ * of the scoped sheet. `Name` is inferred from `light` AND `dark`, so a key present on one side and
19
+ * missing on the other does not compile.
20
+ */
21
+ export interface CustomTokens<Name extends string> {
22
+ /** `/^[a-z][a-z0-9]*$/`: 'wbw' → `--wbw-…`. */
23
+ readonly prefix: string;
24
+ /** Mode-independent brand tokens (type steps, glows the modes share). */
25
+ readonly shared?: Readonly<Record<string, string>>;
26
+ readonly light: Readonly<Record<Name, string>>;
27
+ readonly dark: Readonly<Record<Name, string>>;
28
+ }
29
+ export interface ThemeDefinition<CustomName extends string = never> {
30
+ /** The scope class without the dot. `/^[a-z][a-z0-9-]*$/`, checked at runtime. */
31
+ readonly className: string;
32
+ readonly shared?: TokenOverrides<SharedTokens>;
33
+ readonly light?: TokenOverrides<ThemeTokens>;
34
+ readonly dark?: TokenOverrides<ThemeTokens>;
35
+ readonly custom?: CustomTokens<CustomName>;
36
+ /** Pairs from `textContrastPairs`/`uiContrastPairs`/`extraPairs` this brand keeps as drawn (Q2 b). */
37
+ readonly contrastExemptions?: ReadonlyArray<ContrastPair>;
38
+ }
39
+ export type CustomNameOf<Definition> = Definition extends {
40
+ readonly custom: CustomTokens<infer Name>;
41
+ } ? Name : never;
42
+ /** Exported (declaration emit needs it); `defineTheme` stamps it on every theme it returns. */
43
+ export declare const themeBrand: unique symbol;
44
+ /** The resolved theme: the complete token set with the brand's values laid over the defaults. */
45
+ export interface Theme<CustomName extends string = string> {
46
+ readonly className: string;
47
+ readonly shared: TokenValues<SharedTokens>;
48
+ readonly light: TokenValues<ThemeTokens>;
49
+ readonly dark: TokenValues<ThemeTokens>;
50
+ readonly custom: {
51
+ readonly prefix: string | null;
52
+ readonly shared: Readonly<Record<string, string>>;
53
+ readonly light: Readonly<Record<CustomName, string>>;
54
+ readonly dark: Readonly<Record<CustomName, string>>;
55
+ };
56
+ readonly contrastExemptions: ReadonlyArray<ContrastPair>;
57
+ /** Only `defineTheme` makes one: `ThemeScope` and `themeToCss` refuse a hand-written object. */
58
+ readonly [themeBrand]: true;
59
+ }
60
+ export declare function defineTheme<const Definition extends ThemeDefinition<string>>(definition: Definition & NoExtraKeys<Definition, ThemeDefinition<CustomNameOf<Definition>>>): Theme<CustomNameOf<Definition>>;
61
+ export {};
package/dist/tokens.css CHANGED
@@ -4,6 +4,17 @@
4
4
  color-scheme: light dark;
5
5
  --font-sans: "Geist Variable", "Geist", -apple-system, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
6
6
  --font-mono: "Geist Mono Variable", "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
7
+ --font-display: "Geist Variable", "Geist", -apple-system, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
8
+ --font-body: "Geist Variable", "Geist", -apple-system, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
9
+ --font-weight-body: 400;
10
+ --font-weight-label: 500;
11
+ --font-weight-button: 500;
12
+ --font-weight-heading: 600;
13
+ --font-weight-nav: 400;
14
+ --font-weight-nav-selected: 500;
15
+ --font-weight-display: 600;
16
+ --font-stretch-display: normal;
17
+ --text-transform-display: none;
7
18
  --text-2xs: 0.6875rem;
8
19
  --text-xs: 0.75rem;
9
20
  --text-sm: 0.875rem;
@@ -43,6 +54,12 @@
43
54
  --radius-lg: 0.75rem;
44
55
  --radius-xl: 1rem;
45
56
  --radius-full: 999px;
57
+ --radius-control: 0.625rem;
58
+ --radius-option: 0.5rem;
59
+ --radius-panel: 0.625rem;
60
+ --radius-popup: 0.75rem;
61
+ --radius-card: 1rem;
62
+ --radius-dialog: 1rem;
46
63
  --border-width-emphasis: 2px;
47
64
  --border-width-strong: 3px;
48
65
  --motion-duration-1: 120ms;
@@ -59,6 +76,10 @@
59
76
  --size-header-wide: 4.5rem;
60
77
  --size-page-max: 75rem;
61
78
  --size-page-max-wide: min(112.5rem, 90vw);
79
+ --size-drawer: 28rem;
80
+ --size-control: 44px;
81
+ --size-control-sm: 2.5rem;
82
+ --size-close: 2.25rem;
62
83
  --material-glass-blur: blur(20px) saturate(1.4);
63
84
  --measure: 65ch;
64
85
  --focus-ring-width: 2px;
@@ -81,6 +102,7 @@
81
102
  --color-accent-wash: rgba(59, 111, 224, 0.035);
82
103
  --color-border: rgba(28, 25, 23, 0.08);
83
104
  --color-border-strong: rgba(28, 25, 23, 0.18);
105
+ --color-border-control: #857F79;
84
106
  --color-border-accent: rgba(59, 111, 224, 0.28);
85
107
  --color-card-border: transparent;
86
108
  --color-scrim: rgba(28, 25, 23, 0.45);
@@ -95,9 +117,51 @@
95
117
  --color-chart-phase-2: #3B6FE0;
96
118
  --color-chart-phase-3: #8FAAEB;
97
119
  --color-chart-phase-4: #1F8A5B;
120
+ --color-selected: #3B6FE0;
121
+ --color-selected-text: #FFFFFF;
122
+ --color-selected-soft: rgba(59, 111, 224, 0.14);
123
+ --color-selected-soft-text: #1C1917;
124
+ --color-inverse: #1C1917;
125
+ --color-inverse-text: #FFFFFF;
126
+ --color-inverse-soft: rgba(255, 255, 255, 0.22);
127
+ --color-inverse-soft-text: #FFFFFF;
128
+ --color-nav-text: #57534E;
129
+ --color-nav-selected: transparent;
130
+ --color-nav-selected-text: #1C1917;
131
+ --color-tab-bar: #FFFFFF;
132
+ --color-tab-bar-text: #57534E;
133
+ --color-tab-bar-active: #3B6FE0;
134
+ --color-tab-bar-active-text: #FFFFFF;
135
+ --color-sheet-handle: rgba(28, 25, 23, 0.18);
136
+ --color-segmented-track: #F4F2EE;
137
+ --color-segmented-border: rgba(28, 25, 23, 0.18);
138
+ --color-scrim-sheet: rgba(28, 25, 23, 0.45);
139
+ --color-avatar-ring: #FFFFFF;
140
+ --color-avatar-fill-1: #ECE9E3;
141
+ --color-avatar-fill-2: #ECE9E3;
142
+ --color-avatar-fill-3: #ECE9E3;
143
+ --color-avatar-fill-4: #ECE9E3;
144
+ --color-avatar-fill-5: #ECE9E3;
145
+ --color-avatar-fill-6: #ECE9E3;
146
+ --color-avatar-ink-1: #57534E;
147
+ --color-avatar-ink-2: #57534E;
148
+ --color-avatar-ink-3: #57534E;
149
+ --color-avatar-ink-4: #57534E;
150
+ --color-avatar-ink-5: #57534E;
151
+ --color-avatar-ink-6: #57534E;
98
152
  --elevation-1: 0 2px 8px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.05);
99
153
  --elevation-2: 0 6px 16px rgba(28, 25, 23, 0.07), 0 20px 48px rgba(28, 25, 23, 0.08);
100
154
  --elevation-3: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
155
+ --shadow-soft: 0 2px 8px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.05);
156
+ --shadow-chip: 0 2px 8px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.05);
157
+ --shadow-raised: 0 6px 16px rgba(28, 25, 23, 0.07), 0 20px 48px rgba(28, 25, 23, 0.08);
158
+ --shadow-dialog: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
159
+ --shadow-drawer: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
160
+ --shadow-sheet: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
161
+ --shadow-tab-bar: 0 6px 16px rgba(28, 25, 23, 0.07), 0 20px 48px rgba(28, 25, 23, 0.08);
162
+ --shadow-action: none;
163
+ --shadow-action-inverse: none;
164
+ --shadow-segmented: none;
101
165
  --material-glass-bg: rgba(251, 250, 248, 0.78);
102
166
  }
103
167
 
@@ -121,6 +185,7 @@
121
185
  --color-accent-wash: rgba(127, 164, 245, 0.05);
122
186
  --color-border: rgba(255, 255, 255, 0.08);
123
187
  --color-border-strong: rgba(255, 255, 255, 0.18);
188
+ --color-border-control: #8A909C;
124
189
  --color-border-accent: rgba(127, 164, 245, 0.32);
125
190
  --color-card-border: rgba(255, 255, 255, 0.08);
126
191
  --color-scrim: rgba(3, 4, 6, 0.6);
@@ -135,9 +200,51 @@
135
200
  --color-chart-phase-2: #7FA4F5;
136
201
  --color-chart-phase-3: #4E6BB0;
137
202
  --color-chart-phase-4: #4FC38A;
203
+ --color-selected: #7FA4F5;
204
+ --color-selected-text: #0B0D12;
205
+ --color-selected-soft: rgba(127, 164, 245, 0.18);
206
+ --color-selected-soft-text: #EDEEF2;
207
+ --color-inverse: #EDEEF2;
208
+ --color-inverse-text: #0B0D12;
209
+ --color-inverse-soft: rgba(11, 13, 18, 0.22);
210
+ --color-inverse-soft-text: #0B0D12;
211
+ --color-nav-text: #A8ADB8;
212
+ --color-nav-selected: transparent;
213
+ --color-nav-selected-text: #EDEEF2;
214
+ --color-tab-bar: #111420;
215
+ --color-tab-bar-text: #A8ADB8;
216
+ --color-tab-bar-active: #7FA4F5;
217
+ --color-tab-bar-active-text: #0B0D12;
218
+ --color-sheet-handle: rgba(255, 255, 255, 0.18);
219
+ --color-segmented-track: #171B28;
220
+ --color-segmented-border: rgba(255, 255, 255, 0.18);
221
+ --color-scrim-sheet: rgba(3, 4, 6, 0.6);
222
+ --color-avatar-ring: #111420;
223
+ --color-avatar-fill-1: #1F2434;
224
+ --color-avatar-fill-2: #1F2434;
225
+ --color-avatar-fill-3: #1F2434;
226
+ --color-avatar-fill-4: #1F2434;
227
+ --color-avatar-fill-5: #1F2434;
228
+ --color-avatar-fill-6: #1F2434;
229
+ --color-avatar-ink-1: #A8ADB8;
230
+ --color-avatar-ink-2: #A8ADB8;
231
+ --color-avatar-ink-3: #A8ADB8;
232
+ --color-avatar-ink-4: #A8ADB8;
233
+ --color-avatar-ink-5: #A8ADB8;
234
+ --color-avatar-ink-6: #A8ADB8;
138
235
  --elevation-1: inset 0 1px 0 rgba(255, 255, 255, 0.06);
139
236
  --elevation-2: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
140
237
  --elevation-3: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
238
+ --shadow-soft: inset 0 1px 0 rgba(255, 255, 255, 0.06);
239
+ --shadow-chip: inset 0 1px 0 rgba(255, 255, 255, 0.06);
240
+ --shadow-raised: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
241
+ --shadow-dialog: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
242
+ --shadow-drawer: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
243
+ --shadow-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
244
+ --shadow-tab-bar: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
245
+ --shadow-action: none;
246
+ --shadow-action-inverse: none;
247
+ --shadow-segmented: none;
141
248
  --material-glass-bg: rgba(11, 13, 18, 0.78);
142
249
  }
143
250
 
@@ -166,6 +273,7 @@
166
273
  --color-accent-wash: rgba(127, 164, 245, 0.05);
167
274
  --color-border: rgba(255, 255, 255, 0.08);
168
275
  --color-border-strong: rgba(255, 255, 255, 0.18);
276
+ --color-border-control: #8A909C;
169
277
  --color-border-accent: rgba(127, 164, 245, 0.32);
170
278
  --color-card-border: rgba(255, 255, 255, 0.08);
171
279
  --color-scrim: rgba(3, 4, 6, 0.6);
@@ -180,9 +288,51 @@
180
288
  --color-chart-phase-2: #7FA4F5;
181
289
  --color-chart-phase-3: #4E6BB0;
182
290
  --color-chart-phase-4: #4FC38A;
291
+ --color-selected: #7FA4F5;
292
+ --color-selected-text: #0B0D12;
293
+ --color-selected-soft: rgba(127, 164, 245, 0.18);
294
+ --color-selected-soft-text: #EDEEF2;
295
+ --color-inverse: #EDEEF2;
296
+ --color-inverse-text: #0B0D12;
297
+ --color-inverse-soft: rgba(11, 13, 18, 0.22);
298
+ --color-inverse-soft-text: #0B0D12;
299
+ --color-nav-text: #A8ADB8;
300
+ --color-nav-selected: transparent;
301
+ --color-nav-selected-text: #EDEEF2;
302
+ --color-tab-bar: #111420;
303
+ --color-tab-bar-text: #A8ADB8;
304
+ --color-tab-bar-active: #7FA4F5;
305
+ --color-tab-bar-active-text: #0B0D12;
306
+ --color-sheet-handle: rgba(255, 255, 255, 0.18);
307
+ --color-segmented-track: #171B28;
308
+ --color-segmented-border: rgba(255, 255, 255, 0.18);
309
+ --color-scrim-sheet: rgba(3, 4, 6, 0.6);
310
+ --color-avatar-ring: #111420;
311
+ --color-avatar-fill-1: #1F2434;
312
+ --color-avatar-fill-2: #1F2434;
313
+ --color-avatar-fill-3: #1F2434;
314
+ --color-avatar-fill-4: #1F2434;
315
+ --color-avatar-fill-5: #1F2434;
316
+ --color-avatar-fill-6: #1F2434;
317
+ --color-avatar-ink-1: #A8ADB8;
318
+ --color-avatar-ink-2: #A8ADB8;
319
+ --color-avatar-ink-3: #A8ADB8;
320
+ --color-avatar-ink-4: #A8ADB8;
321
+ --color-avatar-ink-5: #A8ADB8;
322
+ --color-avatar-ink-6: #A8ADB8;
183
323
  --elevation-1: inset 0 1px 0 rgba(255, 255, 255, 0.06);
184
324
  --elevation-2: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
185
325
  --elevation-3: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
326
+ --shadow-soft: inset 0 1px 0 rgba(255, 255, 255, 0.06);
327
+ --shadow-chip: inset 0 1px 0 rgba(255, 255, 255, 0.06);
328
+ --shadow-raised: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
329
+ --shadow-dialog: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
330
+ --shadow-drawer: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
331
+ --shadow-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
332
+ --shadow-tab-bar: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
333
+ --shadow-action: none;
334
+ --shadow-action-inverse: none;
335
+ --shadow-segmented: none;
186
336
  --material-glass-bg: rgba(11, 13, 18, 0.78);
187
337
  }
188
338
  }