@slotted/theme 0.1.0-beta.0 → 0.1.0-beta.2

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,21 @@
1
+ import type { TokenDefinition } from './contract-types';
2
+ /**
3
+ * What each token of the contract is for. A group covers its tokens by a
4
+ * pattern of `{dimension}` slots or by a list of names. The published token
5
+ * page is generated from the groups, and `groupErrors` holds them complete:
6
+ * every token in exactly one group, every meaning stated.
7
+ */
8
+ export interface TokenGroup {
9
+ readonly id: string;
10
+ readonly purpose: string;
11
+ /** `application`: an element of the application's own reads it. `family`: only its family does. */
12
+ readonly reader: 'application' | 'family';
13
+ readonly pattern?: string;
14
+ /** Per slot: the meaning of each value, or `open` for values with no meaning of their own. */
15
+ readonly dimensions?: Readonly<Record<string, Readonly<Record<string, string>> | 'open'>>;
16
+ readonly tokens?: Readonly<Record<string, string>>;
17
+ }
18
+ export declare function groupCovers(group: TokenGroup, name: string): boolean;
19
+ /** The value a token takes in each slot of its group's pattern. */
20
+ export declare function dimensionValues(group: TokenGroup, name: string): Record<string, string>;
21
+ export declare function groupErrors(tokens: readonly TokenDefinition[], groups: readonly TokenGroup[]): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slotted/theme",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/src/contract.json CHANGED
@@ -4,6 +4,356 @@
4
4
  "axes": ["base", "scheme", "density"],
5
5
  "requiredSchemes": ["light", "dark", "high-contrast"],
6
6
  "requiredDensities": ["comfortable", "compact", "dense"],
7
+ "groups": [
8
+ {
9
+ "id": "space",
10
+ "reader": "application",
11
+ "purpose": "How much separation or inset a layout needs, smallest first; a gap or an inset is one step.",
12
+ "pattern": "--slotted-space-{step}",
13
+ "dimensions": {
14
+ "step": "open"
15
+ }
16
+ },
17
+ {
18
+ "id": "radius",
19
+ "reader": "application",
20
+ "purpose": "How rounded a box or a part is drawn, from none to full.",
21
+ "pattern": "--slotted-radius-{step}",
22
+ "dimensions": {
23
+ "step": "open"
24
+ }
25
+ },
26
+ {
27
+ "id": "font-family",
28
+ "reader": "application",
29
+ "purpose": "The typeface text is set in.",
30
+ "pattern": "--slotted-font-family-{family}",
31
+ "dimensions": {
32
+ "family": {
33
+ "sans": "The typeface of the interface's text.",
34
+ "mono": "The typeface of code and of values read character by character.",
35
+ "heading": "The typeface of headings; a theme may point it at a face of its own."
36
+ }
37
+ }
38
+ },
39
+ {
40
+ "id": "font-size",
41
+ "reader": "application",
42
+ "purpose": "What size text is set in, smallest first; text of the application's own takes its size from the `typography` family before this scale.",
43
+ "pattern": "--slotted-font-size-{step}",
44
+ "dimensions": {
45
+ "step": "open"
46
+ }
47
+ },
48
+ {
49
+ "id": "line-height",
50
+ "reader": "application",
51
+ "purpose": "The line height that pairs with the font-size step of the same name.",
52
+ "pattern": "--slotted-line-height-{step}",
53
+ "dimensions": {
54
+ "step": "open"
55
+ }
56
+ },
57
+ {
58
+ "id": "font-weight",
59
+ "reader": "application",
60
+ "purpose": "How much typographic emphasis text carries.",
61
+ "pattern": "--slotted-font-weight-{weight}",
62
+ "dimensions": {
63
+ "weight": {
64
+ "regular": "Running text.",
65
+ "medium": "Text that stands out from running text without heading it.",
66
+ "semibold": "A heading, a control's label, a figure that leads."
67
+ }
68
+ }
69
+ },
70
+ {
71
+ "id": "border-width",
72
+ "reader": "application",
73
+ "purpose": "How thick an edge or a ring is drawn.",
74
+ "pattern": "--slotted-border-width-{width}",
75
+ "dimensions": {
76
+ "width": {
77
+ "thin": "The edge of a box, a control or a divider.",
78
+ "medium": "The weight between thin and thick.",
79
+ "thick": "The heaviest edge."
80
+ }
81
+ }
82
+ },
83
+ {
84
+ "id": "duration",
85
+ "reader": "application",
86
+ "purpose": "How long a transition or one cycle of a loop takes. The steps from instant to long collapse under reduced motion; the loops do not, so a repeating animation stops there instead.",
87
+ "pattern": "--slotted-duration-{step}",
88
+ "dimensions": {
89
+ "step": {
90
+ "instant": "A change that must not read as motion.",
91
+ "short": "A control changing state: a ground, a border, a mark.",
92
+ "medium": "A part appearing or leaving: a popover, a menu, a tooltip.",
93
+ "long": "A surface entering or leaving over a larger distance: a drawer, a dialog.",
94
+ "loop-fast": "One cycle of a fast repeating animation.",
95
+ "loop": "One cycle of a repeating animation.",
96
+ "loop-slow": "One cycle of a slow repeating animation."
97
+ }
98
+ }
99
+ },
100
+ {
101
+ "id": "easing",
102
+ "reader": "application",
103
+ "purpose": "How the velocity of a transition changes.",
104
+ "pattern": "--slotted-easing-{curve}",
105
+ "dimensions": {
106
+ "curve": {
107
+ "standard": "A change within the screen.",
108
+ "enter": "A part arriving.",
109
+ "exit": "A part leaving.",
110
+ "emphasized": "A change meant to be noticed; it overshoots its end."
111
+ }
112
+ }
113
+ },
114
+ {
115
+ "id": "z-index",
116
+ "reader": "application",
117
+ "purpose": "Which layer an element occupies above the page.",
118
+ "pattern": "--slotted-z-index-{layer}",
119
+ "dimensions": {
120
+ "layer": {
121
+ "sticky": "A header or a column that stays in place while its region scrolls.",
122
+ "overlay": "A modal surface and the scrim under it.",
123
+ "popover": "A popover, a menu or a tooltip; above an overlay, so one opens from a dialog.",
124
+ "toast": "A toast; above every other layer."
125
+ }
126
+ }
127
+ },
128
+ {
129
+ "id": "shadow",
130
+ "reader": "application",
131
+ "purpose": "What elevation a surface has above the one under it, smallest first; under forced colours every step is none.",
132
+ "pattern": "--slotted-shadow-{step}",
133
+ "dimensions": {
134
+ "step": "open"
135
+ }
136
+ },
137
+ {
138
+ "id": "surface",
139
+ "reader": "application",
140
+ "purpose": "The grounds content stands on.",
141
+ "tokens": {
142
+ "--slotted-surface": "The ground of the page's content and of a card.",
143
+ "--slotted-surface-raised": "The ground of a surface above another: a popover, a menu, a dialog; paired with a step of `shadow`.",
144
+ "--slotted-surface-sunken": "The canvas under the content: the ground a card and a field stand out from.",
145
+ "--slotted-surface-inverse": "A ground in the opposite lightness, with `--slotted-text-inverse` on it."
146
+ }
147
+ },
148
+ {
149
+ "id": "text",
150
+ "reader": "application",
151
+ "purpose": "The colours text is painted in.",
152
+ "tokens": {
153
+ "--slotted-text": "Text on a surface.",
154
+ "--slotted-text-muted": "Text that ranks below the text beside it: a caption, a hint, a secondary value.",
155
+ "--slotted-text-inverse": "Text on `--slotted-surface-inverse`."
156
+ }
157
+ },
158
+ {
159
+ "id": "border",
160
+ "reader": "application",
161
+ "purpose": "The colours of lines between and inside surfaces.",
162
+ "tokens": {
163
+ "--slotted-border-subtle": "A rule inside a surface: a divider, the edge of a region, the seam under a header.",
164
+ "--slotted-border-strong": "The line between two surfaces; it holds 3:1 against every surface a control stands on."
165
+ }
166
+ },
167
+ {
168
+ "id": "disabled",
169
+ "reader": "application",
170
+ "purpose": "How an unavailable control is painted.",
171
+ "pattern": "--slotted-disabled-{role}",
172
+ "dimensions": {
173
+ "role": {
174
+ "background": "The ground of an unavailable control.",
175
+ "foreground": "The text and icons of an unavailable control.",
176
+ "border": "The edge of an unavailable control, a step lighter than the edge of an available one."
177
+ }
178
+ }
179
+ },
180
+ {
181
+ "id": "focus-ring",
182
+ "reader": "application",
183
+ "purpose": "The outline every focused element draws.",
184
+ "tokens": {
185
+ "--slotted-focus-ring-width": "The thickness of the focus outline.",
186
+ "--slotted-focus-ring-offset": "The distance between the element and its focus outline.",
187
+ "--slotted-focus-ring-color": "The colour of the focus outline.",
188
+ "--slotted-focus-ring-color-invalid": "The colour of the focus outline of a control in error; an element in error points `--slotted-focus-ring-color` at it."
189
+ }
190
+ },
191
+ {
192
+ "id": "target",
193
+ "reader": "application",
194
+ "purpose": "How small an interactive target may be.",
195
+ "tokens": {
196
+ "--slotted-target-min": "The smallest target in both axes: 24 by 24 CSS pixels.",
197
+ "--slotted-target-comfortable": "The size a target grows to under a coarse pointer."
198
+ }
199
+ },
200
+ {
201
+ "id": "tone",
202
+ "reader": "application",
203
+ "purpose": "What an element carrying an intent is painted with: five tones, each with the same nine roles.",
204
+ "pattern": "--slotted-tone-{tone}-{role}",
205
+ "dimensions": {
206
+ "tone": {
207
+ "accent": "The product's intent: the primary action, the chosen option, the current place.",
208
+ "secondary": "A second intent beside accent, for an action or a mark that must not compete with it.",
209
+ "success": "A result that completed or a state that is healthy.",
210
+ "warning": "A state that needs attention before it becomes a failure.",
211
+ "danger": "A failure, an error or an action that destroys data."
212
+ },
213
+ "role": {
214
+ "solid": "A filled ground: the primary button of the tone.",
215
+ "solid-hover": "The filled ground under the pointer.",
216
+ "solid-active": "The filled ground while pressed.",
217
+ "on-solid": "Text and icons on the filled ground.",
218
+ "surface": "A tinted ground; a state that must be seen pairs it with the tone's border.",
219
+ "subtle-hover": "The tint under the pointer of an element with no filled ground.",
220
+ "subtle-active": "That tint while pressed.",
221
+ "border": "An edge in the tone, at the non-text contrast ratio against the page and against its own surface.",
222
+ "text": "Text in the tone on a surface."
223
+ }
224
+ }
225
+ },
226
+ {
227
+ "id": "data",
228
+ "reader": "application",
229
+ "purpose": "What a series of data is painted with: a line, a bar, a slice. Slots are assigned in order and never skipped.",
230
+ "pattern": "--slotted-data-{slot}",
231
+ "dimensions": {
232
+ "slot": "open"
233
+ }
234
+ },
235
+ {
236
+ "id": "control",
237
+ "reader": "application",
238
+ "purpose": "What a control's text and frame look like at every size.",
239
+ "tokens": {
240
+ "--slotted-control-font-family": "The typeface of a control's text.",
241
+ "--slotted-control-font-weight": "The weight of a control's label.",
242
+ "--slotted-control-line-height": "The line height of a control's text.",
243
+ "--slotted-control-letter-spacing": "The letter spacing of a control's text.",
244
+ "--slotted-control-border-width": "The edge width of a control at rest.",
245
+ "--slotted-control-radius": "The corner of a control.",
246
+ "--slotted-control-shadow-focus-geometry": "Offset, blur and spread of the shadow a focused control draws, with no colour; drawn with `--slotted-focus-ring-color`.",
247
+ "--slotted-control-transition-duration": "How long a control takes to change state.",
248
+ "--slotted-control-transition-easing": "The curve of a control's change of state.",
249
+ "--slotted-control-invalid-edge-width": "The edge an invalid control adds inside its border, so the state reads where colour cannot.",
250
+ "--slotted-control-border-color": "The edge colour of a control at rest.",
251
+ "--slotted-control-surface": "The ground of a control at rest: a field, a select, a segmented control.",
252
+ "--slotted-control-shadow": "The shadow of a control at rest."
253
+ }
254
+ },
255
+ {
256
+ "id": "control-size",
257
+ "reader": "application",
258
+ "purpose": "The size and inner spacing of a control at each size step; every value follows density.",
259
+ "pattern": "--slotted-control-{part}-{size}",
260
+ "dimensions": {
261
+ "part": {
262
+ "height": "The block size of the control.",
263
+ "padding-inline": "The inline space between the control's edge and its content.",
264
+ "font-size": "The size of the control's text.",
265
+ "icon-size": "The size of an icon inside the control.",
266
+ "gap": "The space between items inside the control, and between one choice and the next in a group.",
267
+ "label-gap": "The space between a binary control — a box, a circle, a switch — and its own label.",
268
+ "inner-size": "The block size of what stands inside the control: a key, a chip, a clear mark."
269
+ },
270
+ "size": {
271
+ "sm": "The small step.",
272
+ "md": "The medium step.",
273
+ "lg": "The large step."
274
+ }
275
+ }
276
+ },
277
+ {
278
+ "id": "selection",
279
+ "reader": "application",
280
+ "purpose": "The size of a selection control and of the halo behind it.",
281
+ "tokens": {
282
+ "--slotted-selection-size-sm": "The box of a checkbox and the circle of a radio at the small step.",
283
+ "--slotted-selection-size-md": "The box and the circle at the medium step.",
284
+ "--slotted-selection-size-lg": "The box and the circle at the large step.",
285
+ "--slotted-selection-halo-opacity": "The share of `--slotted-tone-accent-text` in the halo behind a selection control under the pointer."
286
+ }
287
+ },
288
+ {
289
+ "id": "highlight",
290
+ "reader": "application",
291
+ "purpose": "How strong the band behind a matched span is.",
292
+ "tokens": {
293
+ "--slotted-highlight-tint-opacity": "The share of `--slotted-tone-accent-text` in the band behind a matched span."
294
+ }
295
+ },
296
+ {
297
+ "id": "current",
298
+ "reader": "application",
299
+ "purpose": "How the place the reader is on is marked.",
300
+ "tokens": {
301
+ "--slotted-current-edge": "The edge of the row the reader is on, drawn over its tone ground."
302
+ }
303
+ },
304
+ {
305
+ "id": "scrim",
306
+ "reader": "application",
307
+ "purpose": "The veil under a modal surface.",
308
+ "tokens": {
309
+ "--slotted-scrim": "The veil between the page and a modal surface above it."
310
+ }
311
+ },
312
+ {
313
+ "id": "icon",
314
+ "reader": "family",
315
+ "purpose": "The geometry of an icon a family draws itself; an icon of the application's own is drawn with the `icon` family.",
316
+ "pattern": "--slotted-icon-{glyph}",
317
+ "dimensions": {
318
+ "glyph": "open"
319
+ }
320
+ },
321
+ {
322
+ "id": "upload-kind",
323
+ "reader": "family",
324
+ "purpose": "The tile colours of file kinds in `upload` and `attachment`.",
325
+ "pattern": "--slotted-upload-kind-{kind}",
326
+ "dimensions": {
327
+ "kind": "open"
328
+ }
329
+ },
330
+ {
331
+ "id": "code",
332
+ "reader": "family",
333
+ "purpose": "The colours of syntax scopes in `code-block`.",
334
+ "pattern": "--slotted-code-{scope}",
335
+ "dimensions": {
336
+ "scope": "open"
337
+ }
338
+ },
339
+ {
340
+ "id": "rating",
341
+ "reader": "family",
342
+ "purpose": "The edge of a star in `rating`.",
343
+ "tokens": {
344
+ "--slotted-rating-edge": "The edge of a star."
345
+ }
346
+ },
347
+ {
348
+ "id": "avatar-size",
349
+ "reader": "family",
350
+ "purpose": "The sizes of `avatar`, smallest first.",
351
+ "pattern": "--slotted-avatar-size-{size}",
352
+ "dimensions": {
353
+ "size": "open"
354
+ }
355
+ }
356
+ ],
7
357
  "tokens": [
8
358
  {
9
359
  "name": "--slotted-radius-none",