@calcifer-design/tokens 0.1.1 → 0.3.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/dist/custom-property-scan.d.ts +4 -0
- package/dist/generate.d.ts +14 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +421 -47
- package/dist/theme-contrast.d.ts +26 -0
- package/dist/theme.d.ts +61 -0
- package/dist/tokens.css +150 -0
- package/dist/tokens.d.ts +301 -0
- package/package.json +2 -2
package/dist/theme.d.ts
ADDED
|
@@ -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;
|
|
@@ -83,6 +104,7 @@
|
|
|
83
104
|
--color-border-strong: rgba(28, 25, 23, 0.18);
|
|
84
105
|
--color-border-accent: rgba(59, 111, 224, 0.28);
|
|
85
106
|
--color-card-border: transparent;
|
|
107
|
+
--color-scrim: rgba(28, 25, 23, 0.45);
|
|
86
108
|
--color-focus: #3B6FE0;
|
|
87
109
|
--color-success: #1F8A5B;
|
|
88
110
|
--color-warning: #B7791F;
|
|
@@ -94,9 +116,51 @@
|
|
|
94
116
|
--color-chart-phase-2: #3B6FE0;
|
|
95
117
|
--color-chart-phase-3: #8FAAEB;
|
|
96
118
|
--color-chart-phase-4: #1F8A5B;
|
|
119
|
+
--color-selected: #3B6FE0;
|
|
120
|
+
--color-selected-text: #FFFFFF;
|
|
121
|
+
--color-selected-soft: rgba(59, 111, 224, 0.14);
|
|
122
|
+
--color-selected-soft-text: #1C1917;
|
|
123
|
+
--color-inverse: #1C1917;
|
|
124
|
+
--color-inverse-text: #FFFFFF;
|
|
125
|
+
--color-inverse-soft: rgba(255, 255, 255, 0.22);
|
|
126
|
+
--color-inverse-soft-text: #FFFFFF;
|
|
127
|
+
--color-nav-text: #57534E;
|
|
128
|
+
--color-nav-selected: transparent;
|
|
129
|
+
--color-nav-selected-text: #1C1917;
|
|
130
|
+
--color-tab-bar: #FFFFFF;
|
|
131
|
+
--color-tab-bar-text: #57534E;
|
|
132
|
+
--color-tab-bar-active: #3B6FE0;
|
|
133
|
+
--color-tab-bar-active-text: #FFFFFF;
|
|
134
|
+
--color-sheet-handle: rgba(28, 25, 23, 0.18);
|
|
135
|
+
--color-segmented-track: #F4F2EE;
|
|
136
|
+
--color-segmented-border: rgba(28, 25, 23, 0.18);
|
|
137
|
+
--color-scrim-sheet: rgba(28, 25, 23, 0.45);
|
|
138
|
+
--color-avatar-ring: #FFFFFF;
|
|
139
|
+
--color-avatar-fill-1: #ECE9E3;
|
|
140
|
+
--color-avatar-fill-2: #ECE9E3;
|
|
141
|
+
--color-avatar-fill-3: #ECE9E3;
|
|
142
|
+
--color-avatar-fill-4: #ECE9E3;
|
|
143
|
+
--color-avatar-fill-5: #ECE9E3;
|
|
144
|
+
--color-avatar-fill-6: #ECE9E3;
|
|
145
|
+
--color-avatar-ink-1: #57534E;
|
|
146
|
+
--color-avatar-ink-2: #57534E;
|
|
147
|
+
--color-avatar-ink-3: #57534E;
|
|
148
|
+
--color-avatar-ink-4: #57534E;
|
|
149
|
+
--color-avatar-ink-5: #57534E;
|
|
150
|
+
--color-avatar-ink-6: #57534E;
|
|
97
151
|
--elevation-1: 0 2px 8px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.05);
|
|
98
152
|
--elevation-2: 0 6px 16px rgba(28, 25, 23, 0.07), 0 20px 48px rgba(28, 25, 23, 0.08);
|
|
99
153
|
--elevation-3: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
|
|
154
|
+
--shadow-soft: 0 2px 8px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.05);
|
|
155
|
+
--shadow-chip: 0 2px 8px rgba(28, 25, 23, 0.05), 0 8px 24px rgba(28, 25, 23, 0.05);
|
|
156
|
+
--shadow-raised: 0 6px 16px rgba(28, 25, 23, 0.07), 0 20px 48px rgba(28, 25, 23, 0.08);
|
|
157
|
+
--shadow-dialog: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
|
|
158
|
+
--shadow-drawer: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
|
|
159
|
+
--shadow-sheet: 0 16px 40px rgba(28, 25, 23, 0.10), 0 2px 6px rgba(28, 25, 23, 0.06);
|
|
160
|
+
--shadow-tab-bar: 0 6px 16px rgba(28, 25, 23, 0.07), 0 20px 48px rgba(28, 25, 23, 0.08);
|
|
161
|
+
--shadow-action: none;
|
|
162
|
+
--shadow-action-inverse: none;
|
|
163
|
+
--shadow-segmented: none;
|
|
100
164
|
--material-glass-bg: rgba(251, 250, 248, 0.78);
|
|
101
165
|
}
|
|
102
166
|
|
|
@@ -122,6 +186,7 @@
|
|
|
122
186
|
--color-border-strong: rgba(255, 255, 255, 0.18);
|
|
123
187
|
--color-border-accent: rgba(127, 164, 245, 0.32);
|
|
124
188
|
--color-card-border: rgba(255, 255, 255, 0.08);
|
|
189
|
+
--color-scrim: rgba(3, 4, 6, 0.6);
|
|
125
190
|
--color-focus: #7FA4F5;
|
|
126
191
|
--color-success: #4FC38A;
|
|
127
192
|
--color-warning: #E0B04A;
|
|
@@ -133,9 +198,51 @@
|
|
|
133
198
|
--color-chart-phase-2: #7FA4F5;
|
|
134
199
|
--color-chart-phase-3: #4E6BB0;
|
|
135
200
|
--color-chart-phase-4: #4FC38A;
|
|
201
|
+
--color-selected: #7FA4F5;
|
|
202
|
+
--color-selected-text: #0B0D12;
|
|
203
|
+
--color-selected-soft: rgba(127, 164, 245, 0.18);
|
|
204
|
+
--color-selected-soft-text: #EDEEF2;
|
|
205
|
+
--color-inverse: #EDEEF2;
|
|
206
|
+
--color-inverse-text: #0B0D12;
|
|
207
|
+
--color-inverse-soft: rgba(11, 13, 18, 0.22);
|
|
208
|
+
--color-inverse-soft-text: #0B0D12;
|
|
209
|
+
--color-nav-text: #A8ADB8;
|
|
210
|
+
--color-nav-selected: transparent;
|
|
211
|
+
--color-nav-selected-text: #EDEEF2;
|
|
212
|
+
--color-tab-bar: #111420;
|
|
213
|
+
--color-tab-bar-text: #A8ADB8;
|
|
214
|
+
--color-tab-bar-active: #7FA4F5;
|
|
215
|
+
--color-tab-bar-active-text: #0B0D12;
|
|
216
|
+
--color-sheet-handle: rgba(255, 255, 255, 0.18);
|
|
217
|
+
--color-segmented-track: #171B28;
|
|
218
|
+
--color-segmented-border: rgba(255, 255, 255, 0.18);
|
|
219
|
+
--color-scrim-sheet: rgba(3, 4, 6, 0.6);
|
|
220
|
+
--color-avatar-ring: #111420;
|
|
221
|
+
--color-avatar-fill-1: #1F2434;
|
|
222
|
+
--color-avatar-fill-2: #1F2434;
|
|
223
|
+
--color-avatar-fill-3: #1F2434;
|
|
224
|
+
--color-avatar-fill-4: #1F2434;
|
|
225
|
+
--color-avatar-fill-5: #1F2434;
|
|
226
|
+
--color-avatar-fill-6: #1F2434;
|
|
227
|
+
--color-avatar-ink-1: #A8ADB8;
|
|
228
|
+
--color-avatar-ink-2: #A8ADB8;
|
|
229
|
+
--color-avatar-ink-3: #A8ADB8;
|
|
230
|
+
--color-avatar-ink-4: #A8ADB8;
|
|
231
|
+
--color-avatar-ink-5: #A8ADB8;
|
|
232
|
+
--color-avatar-ink-6: #A8ADB8;
|
|
136
233
|
--elevation-1: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
137
234
|
--elevation-2: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
|
|
138
235
|
--elevation-3: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
236
|
+
--shadow-soft: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
237
|
+
--shadow-chip: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
238
|
+
--shadow-raised: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
|
|
239
|
+
--shadow-dialog: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
240
|
+
--shadow-drawer: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
241
|
+
--shadow-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
242
|
+
--shadow-tab-bar: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
|
|
243
|
+
--shadow-action: none;
|
|
244
|
+
--shadow-action-inverse: none;
|
|
245
|
+
--shadow-segmented: none;
|
|
139
246
|
--material-glass-bg: rgba(11, 13, 18, 0.78);
|
|
140
247
|
}
|
|
141
248
|
|
|
@@ -166,6 +273,7 @@
|
|
|
166
273
|
--color-border-strong: rgba(255, 255, 255, 0.18);
|
|
167
274
|
--color-border-accent: rgba(127, 164, 245, 0.32);
|
|
168
275
|
--color-card-border: rgba(255, 255, 255, 0.08);
|
|
276
|
+
--color-scrim: rgba(3, 4, 6, 0.6);
|
|
169
277
|
--color-focus: #7FA4F5;
|
|
170
278
|
--color-success: #4FC38A;
|
|
171
279
|
--color-warning: #E0B04A;
|
|
@@ -177,9 +285,51 @@
|
|
|
177
285
|
--color-chart-phase-2: #7FA4F5;
|
|
178
286
|
--color-chart-phase-3: #4E6BB0;
|
|
179
287
|
--color-chart-phase-4: #4FC38A;
|
|
288
|
+
--color-selected: #7FA4F5;
|
|
289
|
+
--color-selected-text: #0B0D12;
|
|
290
|
+
--color-selected-soft: rgba(127, 164, 245, 0.18);
|
|
291
|
+
--color-selected-soft-text: #EDEEF2;
|
|
292
|
+
--color-inverse: #EDEEF2;
|
|
293
|
+
--color-inverse-text: #0B0D12;
|
|
294
|
+
--color-inverse-soft: rgba(11, 13, 18, 0.22);
|
|
295
|
+
--color-inverse-soft-text: #0B0D12;
|
|
296
|
+
--color-nav-text: #A8ADB8;
|
|
297
|
+
--color-nav-selected: transparent;
|
|
298
|
+
--color-nav-selected-text: #EDEEF2;
|
|
299
|
+
--color-tab-bar: #111420;
|
|
300
|
+
--color-tab-bar-text: #A8ADB8;
|
|
301
|
+
--color-tab-bar-active: #7FA4F5;
|
|
302
|
+
--color-tab-bar-active-text: #0B0D12;
|
|
303
|
+
--color-sheet-handle: rgba(255, 255, 255, 0.18);
|
|
304
|
+
--color-segmented-track: #171B28;
|
|
305
|
+
--color-segmented-border: rgba(255, 255, 255, 0.18);
|
|
306
|
+
--color-scrim-sheet: rgba(3, 4, 6, 0.6);
|
|
307
|
+
--color-avatar-ring: #111420;
|
|
308
|
+
--color-avatar-fill-1: #1F2434;
|
|
309
|
+
--color-avatar-fill-2: #1F2434;
|
|
310
|
+
--color-avatar-fill-3: #1F2434;
|
|
311
|
+
--color-avatar-fill-4: #1F2434;
|
|
312
|
+
--color-avatar-fill-5: #1F2434;
|
|
313
|
+
--color-avatar-fill-6: #1F2434;
|
|
314
|
+
--color-avatar-ink-1: #A8ADB8;
|
|
315
|
+
--color-avatar-ink-2: #A8ADB8;
|
|
316
|
+
--color-avatar-ink-3: #A8ADB8;
|
|
317
|
+
--color-avatar-ink-4: #A8ADB8;
|
|
318
|
+
--color-avatar-ink-5: #A8ADB8;
|
|
319
|
+
--color-avatar-ink-6: #A8ADB8;
|
|
180
320
|
--elevation-1: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
181
321
|
--elevation-2: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
|
|
182
322
|
--elevation-3: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
323
|
+
--shadow-soft: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
324
|
+
--shadow-chip: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
|
325
|
+
--shadow-raised: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
|
|
326
|
+
--shadow-dialog: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
327
|
+
--shadow-drawer: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
328
|
+
--shadow-sheet: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px rgba(0, 0, 0, 0.5);
|
|
329
|
+
--shadow-tab-bar: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 0 0 1px rgba(255, 255, 255, 0.18);
|
|
330
|
+
--shadow-action: none;
|
|
331
|
+
--shadow-action-inverse: none;
|
|
332
|
+
--shadow-segmented: none;
|
|
183
333
|
--material-glass-bg: rgba(11, 13, 18, 0.78);
|
|
184
334
|
}
|
|
185
335
|
}
|