@grafctory/skin 0.0.0-stage → 0.3.1

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.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +469 -2
  3. package/dist/index.core.d.ts +201 -0
  4. package/dist/index.core.d.ts.map +1 -0
  5. package/dist/index.core.js +17 -0
  6. package/dist/index.core.js.map +1 -0
  7. package/dist/index.css +126 -0
  8. package/dist/index.d.ts +432 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +184 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/markup/alerts.css +83 -0
  13. package/dist/markup/blocks.css +255 -0
  14. package/dist/markup/forms.css +551 -0
  15. package/dist/markup/headings.css +131 -0
  16. package/dist/markup/highlights.css +38 -0
  17. package/dist/markup/inlines.css +183 -0
  18. package/dist/markup/lists.css +206 -0
  19. package/dist/markup/reset.css +38 -0
  20. package/dist/markup/tables.css +78 -0
  21. package/dist/presets/inter.css +194 -0
  22. package/dist/presets/roboto.css +198 -0
  23. package/dist/tokens/borders.css +151 -0
  24. package/dist/tokens/borders.d.ts +57 -0
  25. package/dist/tokens/borders.d.ts.map +1 -0
  26. package/dist/tokens/borders.js +72 -0
  27. package/dist/tokens/borders.js.map +1 -0
  28. package/dist/tokens/colors.css +515 -0
  29. package/dist/tokens/colors.d.ts +171 -0
  30. package/dist/tokens/colors.d.ts.map +1 -0
  31. package/dist/tokens/colors.js +186 -0
  32. package/dist/tokens/colors.js.map +1 -0
  33. package/dist/tokens/elevations.css +110 -0
  34. package/dist/tokens/elevations.d.ts +54 -0
  35. package/dist/tokens/elevations.d.ts.map +1 -0
  36. package/dist/tokens/elevations.js +69 -0
  37. package/dist/tokens/elevations.js.map +1 -0
  38. package/dist/tokens/layers.css +57 -0
  39. package/dist/tokens/layers.d.ts +34 -0
  40. package/dist/tokens/layers.d.ts.map +1 -0
  41. package/dist/tokens/layers.js +49 -0
  42. package/dist/tokens/layers.js.map +1 -0
  43. package/dist/tokens/motions.css +91 -0
  44. package/dist/tokens/motions.d.ts +40 -0
  45. package/dist/tokens/motions.d.ts.map +1 -0
  46. package/dist/tokens/motions.js +55 -0
  47. package/dist/tokens/motions.js.map +1 -0
  48. package/dist/tokens/opacities.css +41 -0
  49. package/dist/tokens/opacities.d.ts +32 -0
  50. package/dist/tokens/opacities.d.ts.map +1 -0
  51. package/dist/tokens/opacities.js +47 -0
  52. package/dist/tokens/opacities.js.map +1 -0
  53. package/dist/tokens/palettes.css +546 -0
  54. package/dist/tokens/palettes.d.ts +140 -0
  55. package/dist/tokens/palettes.d.ts.map +1 -0
  56. package/dist/tokens/palettes.js +155 -0
  57. package/dist/tokens/palettes.js.map +1 -0
  58. package/dist/tokens/scalings.css +81 -0
  59. package/dist/tokens/scalings.d.ts +31 -0
  60. package/dist/tokens/scalings.d.ts.map +1 -0
  61. package/dist/tokens/scalings.js +46 -0
  62. package/dist/tokens/scalings.js.map +1 -0
  63. package/dist/tokens/spacings.css +78 -0
  64. package/dist/tokens/spacings.d.ts +34 -0
  65. package/dist/tokens/spacings.d.ts.map +1 -0
  66. package/dist/tokens/spacings.js +49 -0
  67. package/dist/tokens/spacings.js.map +1 -0
  68. package/dist/tokens/typography.css +156 -0
  69. package/dist/tokens/typography.d.ts +77 -0
  70. package/dist/tokens/typography.d.ts.map +1 -0
  71. package/dist/tokens/typography.js +92 -0
  72. package/dist/tokens/typography.js.map +1 -0
  73. package/dist/tokens/viewports.css +101 -0
  74. package/dist/tokens/viewports.d.ts +75 -0
  75. package/dist/tokens/viewports.d.ts.map +1 -0
  76. package/dist/tokens/viewports.js +90 -0
  77. package/dist/tokens/viewports.js.map +1 -0
  78. package/package.json +87 -4
package/README.md CHANGED
@@ -1,3 +1,470 @@
1
- # Temporary Holding Version
1
+ # @grafctory/skin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@grafctory/skin)](https://www.npmjs.com/package/@grafctory/skin)
4
+
5
+ Essential design tokens and styles.
6
+
7
+ **@grafctory/skin** is a foundational design system with clean, minimalist tokens for typography, spacing, colour,
8
+ elevation and motion, and a base stylesheet that gives plain document markup a coherent look in light and dark schemes:
9
+
10
+ - **Accessible Colours**: every colour role held to the WCAG 2.2 contrast minimums in both schemes by the test suite
11
+ - **Framework-Free**: plain CSS for plain document markup, with no components and no rendering framework
12
+ - **Typed Token Contract**: every token named in TypeScript and registered in CSS, so a misspelt name fails the build
13
+ - **Content Palettes**: colour-blind-safe series and area colours for charts and maps, plus scales and editor colours
14
+
15
+ The default look sets a slate and orange palette in the platform faces and adapts to any brand book: a preset or an
16
+ app restating the tokens for a brand's faces, colours and shapes restyles every interface without a component change.
17
+
18
+ # Installation
19
+
20
+ ```shell
21
+ npm install @grafctory/skin
22
+ ```
23
+
24
+ > [!WARNING]
25
+ >
26
+ > TypeScript consumers must use `"moduleResolution": "nodenext"/"node16"/"bundler"` in `tsconfig.json`.
27
+ > The legacy `"node"` resolver is not supported.
28
+
29
+ # Usage
30
+
31
+ > [!NOTE]
32
+ >
33
+ > This section introduces essential concepts; for complete coverage, see the
34
+ > [API reference](https://grafctory.github.io/skin/).
35
+
36
+ Include the stylesheet once, at the entry point of the app, ahead of the app styles overriding it:
37
+
38
+ ```typescript
39
+ import "@grafctory/skin/index.css";
40
+ ```
41
+
42
+ An app assembling its own HTML links it in the document head instead: the stylesheet has to reach the document before
43
+ it is painted, or the first frame shows the unstyled markup.
44
+
45
+ ## Presets
46
+
47
+ A preset is the whole design system restyled for a brand, included **in place of** `index.css`, never beside it:
48
+
49
+ ```typescript
50
+ import "@grafctory/skin/presets/roboto.css";
51
+ ```
52
+
53
+ | Stylesheet | Faces |
54
+ |----------------------|------------------------------------------------------------------------------------|
55
+ | `index.css` | the platform faces, with no download |
56
+ | `presets/inter.css` | Inter for text, Inter Tight for headings, Geist Mono for code |
57
+ | `presets/roboto.css` | Roboto, Roboto Condensed and Roboto Mono, the variable faces of the Metreeca brand |
58
+
59
+ Every stylesheet keeps the Metreeca colours unless it states colours of its own, so the presets shipped today differ in
60
+ their faces alone. An app overrides a preset exactly as it overrides `index.css`, and its rules win over the preset.
61
+
62
+ A preset bundles its faces with the app through package imports, which a bundler such as Vite resolves. Until they
63
+ load, it sets the text in platform faces scaled to their metrics, so tables, grids and labels sized to their content
64
+ keep their width when the faces arrive. Linked from the document head without a bundler, it keeps those platform faces.
65
+
66
+ A bundle carries only the faces of the stylesheet an app imports: an app on `index.css` ships no face file, and the
67
+ presets it does not import never reach its build, although every preset's face packages are installed with this one.
68
+
69
+ ## Theming
70
+
71
+ An app brands the interface by restating tokens in an ordinary rule, with no change to any component. A colour that
72
+ differs by scheme is stated once, as a `light-dark()` pair with the light value first:
73
+
74
+ ```html
75
+ <style>
76
+ :root {
77
+ --skin--color-subtle: light-dark(#1C275D, #9AB);
78
+ --skin--color-strong: light-dark(#06C, #4AF);
79
+ }
80
+ </style>
81
+ ```
82
+
83
+ The stylesheet declares its rules in a `skin` cascade layer, so a rule an app writes outside a layer wins whatever order
84
+ the two stylesheets reach the document in, and whichever selector is the more specific. An app declaring layers of its
85
+ own orders them after `skin`, or the design system outranks them, along with every rule they hold.
86
+
87
+ A preset restates tokens inside the same layer, after the defaults it overrides, so an app rule wins over a preset too.
88
+
89
+ An override in the document head, as above, is in force from the first frame, so a loader painted before the
90
+ stylesheet arrives already reads the brand. An override in an app stylesheet takes effect once that stylesheet loads.
91
+
92
+ A malformed override is caught only where the token has a fixed type: a weight, a duration or an opacity the browser
93
+ cannot parse stays on its default. Most tokens, the colour anchors and the sizes among them, take an override as
94
+ written, so a malformed value leaves whatever reads it unstyled rather than on the default.
95
+
96
+ ### Colours
97
+
98
+ Retheme by retuning the anchors alone, `--skin--color`, `--skin--background-color`, `--skin--color-subtle`,
99
+ `--skin--color-strong` and the five status colours `--skin--color-note`, `--skin--color-pass`, `--skin--color-flag`,
100
+ `--skin--color-warn` and `--skin--color-fail`: labels, borders, stripes, focus rings, state fills, notice tints and
101
+ elevation surfaces derive from them and follow. The status colours take values of their own rather than derivations of
102
+ an accent, so a success or a failure reads as itself in both colour schemes, whatever accents an app brands with.
103
+
104
+ Each anchor holds its `light-dark()` pair unresolved, so every scheme and every pinned subtree follows a single
105
+ override, with no rule restated in a `prefers-color-scheme` query or per pinned scheme.
106
+
107
+ The accents ship the Metreeca slate and orange, so an app supplies its own: a quieter value and a louder one, for each
108
+ colour scheme. Each accent has a contrast target set by what it paints. An accent that meets its target keeps every
109
+ colour derived from it within [WCAG 2.2](https://www.w3.org/TR/WCAG22/) AA, on the page and on the fills a control
110
+ paints: 4.5:1 for [text](https://www.w3.org/TR/WCAG22/#contrast-minimum), and 3:1 for marks, control boundaries and
111
+ focus rings, as [non-text contrast](https://www.w3.org/TR/WCAG22/#non-text-contrast) requires.
112
+
113
+ | Accent | Paints | Target in each scheme |
114
+ |------------------------|---------------------------------------|--------------------------------------------------------|
115
+ | `--skin--color-strong` | selected items, labels on state fills | 5.3:1 on the page, for 4.5:1 on the pressed fill |
116
+ | `--skin--color-subtle` | text set in the top of its scale | 4.5:1 on the page |
117
+
118
+ The other accent colours need no target of their own. Hover and pressed text moves the strong accent further from the
119
+ page, so it gains contrast. Links and enabled controls take only the hue of the subtle accent and set their own
120
+ lightness. Text over a strong fill picks black or white, whichever reads better.
121
+
122
+ To try a candidate pair, open the [theming tuner](https://grafctory.github.io/skin/lab/#theming) of the specimen. It
123
+ applies both accents to the whole page, and the [colour roles table](https://grafctory.github.io/skin/lab/#colours)
124
+ marks every role that falls short of its budget, the strong accent included on the pressed fill it is tightest on.
125
+ Against white, the defaults hold 5.51:1 for the strong orange and 10.0:1 for the subtle slate, so the orange clears its
126
+ target by a hair and the slate by far, so a brand's strong accent is the one that needs checking in the tuner.
127
+
128
+ The package test suite holds only the shipped colours to these targets. A preset or an app stating colours of its own
129
+ checks them in the tuner, since a brand falling short of its targets fails no build and shows only on the page.
130
+
131
+ ### Typography
132
+
133
+ `--skin--font-family` sets the body face, `--skin--font-family-heading` the face titles are set in, and
134
+ `--skin--font-family-mono` the face for code spans and aligned figures, each a stack read in order.
135
+
136
+ The faces default to the platform faces, which cost no download, and a [preset](#presets) sets faces it bundles.
137
+
138
+ An app setting a face of its own imports `index.css`, so its build carries no face it does not use. It loads the face
139
+ in the same stylesheet restating the tokens that name it, so the two never drift apart:
140
+
141
+ ```css
142
+ @import "@grafctory/skin/index.css";
143
+ @import "@fontsource-variable/source-sans-3";
144
+
145
+ :root {
146
+ --skin--font-family: "Source Sans 3 Variable", system-ui, sans-serif;
147
+ }
148
+ ```
149
+
150
+ A variable face covers every weight the weight tokens may be retuned to, where a face loaded in fixed weights leaves
151
+ the browser synthesising the rest, and a generic fallback after it keeps text readable until it loads.
152
+
153
+ A mono face runs wider than the text face it is paired with. Each preset scales its mono face to match its text face,
154
+ so anything set in `--skin--font-family-mono` matches the text around it with no size of its own. An app supplying a
155
+ mono face scales it the same way, through the `size-adjust` descriptor of its `@font-face` rules, so it stays matched
156
+ wherever a component sets it. The platform faces vary by system and are left unscaled.
157
+
158
+ `--skin--font-size`, `--skin--font-size-heading`, `--skin--font-weight` and `--skin--line-height` retune the type
159
+ scale, and `--skin--letter-spacing-heading` corrects the heading tracking for a condensed or a wide face.
160
+
161
+ `--skin--line-height-display` sets the tighter leading of display type, `--skin--letter-spacing-caps` the tracking of
162
+ small capitals and `--skin--inline-size-prose` the reading measure of prose. A component reads them in place of
163
+ literals, so an app retuning one of them reaches every title, label and lead in the interface at once.
164
+
165
+ `--skin--text-transform-heading` sets the casing of headings, as written by default, and `--skin--text-transform-caps`
166
+ that of labels in capitals. Both inherit, so a call site restating one on a subtree recases every title or label in it.
167
+ The caps casing and the caps tracking are independent tokens, so an app setting labels in mixed case with
168
+ `--skin--text-transform-caps: none` restates `--skin--letter-spacing-caps` as `normal` in the same rule.
169
+
170
+ Running text wraps so that no lone word is left on its last line, and a heading spread over several lines has them
171
+ balanced, while text being typed keeps the platform wrapping. No token carries this choice: an app opting out writes
172
+ `text-wrap-style: auto` in an ordinary rule, which outranks the design system wherever it reaches the page.
173
+
174
+ ### Other Tokens
175
+
176
+ Spacings, radii, elevations, palettes, motions and the other families are overridden the same way. Every token is listed
177
+ by family in the [API reference](https://grafctory.github.io/skin/), along with what it decides, so an app finds the
178
+ token to retune without reading through the stylesheets and the modules that state its value.
179
+
180
+ The viewport breakpoints are the one exception: CSS does not accept a custom property in a media query, so an app cannot
181
+ move them, though it can still force a breakpoint on or off by overriding its switch.
182
+
183
+ ### Subtrees
184
+
185
+ An interface follows the platform colour scheme on its own. An app that has to pin one sets `data-scheme` to `light` or
186
+ `dark`, on the root element or on any subtree that has to differ from the page around it, which a
187
+ `prefers-color-scheme` query cannot express. The pinned subtree takes its side of every `light-dark()` pair, the app's
188
+ overrides included, and the stylesheet states `color-scheme` alongside, so native controls and scrollbars follow it
189
+ too.
190
+
191
+ A single subtree takes a look of its own from tokens assigned inline through `css`. It names each token by its
192
+ TypeScript entry, so a misspelt name fails the build rather than leaving the subtree unstyled:
193
+
194
+ ```tsx
195
+ <section style={css({ colorStrong: "#06C" })}>
196
+ ```
197
+
198
+ ## Modes
199
+
200
+ A widget built on the design system says what it is for through at most two attributes, and the two never compete
201
+ for the same channel, so a widget can carry both without one reading interfering with the other.
202
+
203
+ **`look` — how loud it appears.** Structural, carried by layout, weight and border rather than by colour: `subtle`
204
+ recedes, `normal` is ordinary, `strong` is larger, earlier, heavier and bounded, and would read as strong in a
205
+ single-colour interface. The pair is the one the colour anchors already use, so a single vocabulary names this axis
206
+ throughout. A widget offers the steps that say something about it and names them in its own documentation, so a tab
207
+ strip with no form louder than its rule takes `subtle` and `normal` alone.
208
+
209
+ **What it means** is colour-coded, and every meaning lands on one five-step scale:
210
+
211
+ | Step | Says | Token |
212
+ |--------|---------------------------|----------------------|
213
+ | `note` | stated or provisional | `--skin--color-note` |
214
+ | `pass` | completed as intended | `--skin--color-pass` |
215
+ | `flag` | singled out for attention | `--skin--color-flag` |
216
+ | `warn` | completed with caveats | `--skin--color-warn` |
217
+ | `fail` | failed to complete | `--skin--color-fail` |
218
+
219
+ The shape is one unjudged step plus a four-step verdict ramp: `note` is not a milder `pass`, it is the absence of a
220
+ verdict, and `flag` is not a milder `warn`, since it says a thing deserves attention without anything having gone
221
+ wrong. Five steps is the ceiling, because colour carries no more at a glance, so a meaning the scale does not carry
222
+ is stated in words rather than in a sixth colour that readers would have to learn.
223
+
224
+ Three kinds of meaning share the scale, and which one a widget carries follows from what the widget is, so no widget
225
+ carries two:
226
+
227
+ - **`level`**, on content: how much attention a passage deserves, set by the author ahead of time
228
+ - **`mode`**, on controls: what activating will do, a consequence not yet incurred
229
+ - **`status`**, on reported things: what the system says happened, at runtime
230
+
231
+ `normal` is **the default of all three, and it is not a step**: it carries no colour coding at all and leaves the
232
+ ordinary page colours, so a widget that states nothing is `normal` and a `level="normal"` passage is not a blue `note`
233
+ admonition. Only the marked values reach the scale. The widget maps those onto the steps and states that mapping in
234
+ its own documentation, so two widgets never put the same meaning on different steps.
235
+
236
+ | Attribute | `normal` | `note` | `pass` | `flag` | `warn` | `fail` |
237
+ |-----------|---------------------|-----------|------------|-----------|------------|-----------------------|
238
+ | `level` | an ordinary passage | `neutral` | `positive` | `notable` | `negative` | `critical` |
239
+ | `mode` | an ordinary control | `safe` | `commit` | `publish` | `alert` | `danger` |
240
+ | `status` | nothing to report | `pending` | `success` | `paused` | `warning` | `failure` or `defect` |
241
+
242
+ The two attributes together read as how it appears and what it means, here on two widgets:
243
+
244
+ ```tsx
245
+ <Button look="subtle" mode="danger"/>
246
+ <Note look="strong" level="negative"/>
247
+ ```
248
+
249
+ > [!IMPORTANT]
250
+ >
251
+ > A step is never told by colour alone: an icon and the wording carry the same meaning, since the two ends of the
252
+ > ramp are the pair colour vision deficiency collapses most readily. Text in the colour of a step takes its stroke
253
+ > role, `--skin--color-note-stroke`, `--skin--color-pass-stroke`, `--skin--color-flag-stroke`,
254
+ > `--skin--color-warn-stroke` or `--skin--color-fail-stroke`, which holds AA contrast on the page, the striped row
255
+ > and the step's tint. The light caution stroke is the exception: it falls short of AA on the caution tint, so
256
+ > caution text is set on the page or a striped row, and never on the caution tint.
257
+
258
+ A thing lifted off the page takes a surface and the shadow that goes with it together, `--skin--background-color-raised`
259
+ with `--skin--box-shadow-raised` for a card that stays in the flow and `--skin--background-color-overlay` with
260
+ `--skin--box-shadow-overlay` for a menu or a dialog that leaves it. `--skin--z-index-*` settles which of two overlapping
261
+ things wins, and `--skin--background-color-blanket` dims what a modal covers.
262
+
263
+ Motion is stated the same way: `--skin--duration-*` says what kind of change a transition carries and
264
+ `--skin--easing-*` how it accelerates, and every duration collapses to zero for a reader who asked for less motion, so
265
+ a transition written through the tokens honours the preference with no rule of its own. `--skin--duration-spin` is
266
+ the exception: a busy mark keeps turning at that period under the preference, since a mark that stopped would say the
267
+ work was over while it is still under way, leaving the reader no sign that anything is pending.
268
+
269
+ Where an author colours content, as a word set in red or a table cell filled in yellow, take the colour from the editor
270
+ grid: `--skin--color-black`, `--skin--color-gray` and `--skin--color-white` for a neutral, and red, yellow, green, blue
271
+ and purple in three steps, as `--skin--color-red-strong`, `--skin--color-red` and `--skin--color-red-subtle`. A strong
272
+ step stands out from the page and a subtle one stays close to it, in either colour scheme. Each colour serves as text or
273
+ as fill and keeps its hue whatever an app brands with. The colours carry no meaning, so a widget never states a status
274
+ with one. The plain step holds 3:1 on the page in either colour scheme, enough for large text and for a mark such as an
275
+ underline. That is the only contrast guarantee: any other step or pairing is the author's to judge, and so is text set
276
+ at body size, which WCAG holds to 4.5:1 rather than the 3:1 that large text and marks need.
277
+
278
+ Where a colour stands for a position rather than for a role, take it from a ten-step scale: `--skin--color-gray-*` for
279
+ a neutral, `--skin--color-subtle-*` and `--skin--color-strong-*` for a branded one, `--skin--color-heat-*` for a
280
+ magnitude. The number is the share of the anchor the step carries, `010` the faintest and `100` the anchor itself, so
281
+ the three derived scales follow a retheme. The heat scale keeps literals of its own and codes by hue, so a step means a
282
+ band a legend names rather than a position on a gradient, and a consumer states the band in text beside the colour.
283
+
284
+ Where a colour stands for one thing among others, take it from a slot or a class. `--skin--color-series-1` to
285
+ `--skin--color-series-9` paint a bar, a line or a wedge: taken in sequence and held to the thing each one paints, so a
286
+ filter dropping a series leaves the survivors their colours. `--skin--color-area-1` to `--skin--color-area-4` fill a
287
+ shape instead, a region on a choropleth or a cell on a grid, and four is the limit: a fifth class is a second map. Both
288
+ families keep one value per slot across colour schemes, and neither follows a rebrand. Nine series hold where only
289
+ neighbours are compared; where every pair is compared, on a scatter, a bubble chart or a map, the first three hold.
290
+ Some of both stay under 3:1 against the light page, so a chart carrying them states its figures in text as well and a
291
+ map keeps its boundaries drawn and names its classes in the legend.
292
+
293
+ Measures are stated in `em`, so a subtree given a size of its own takes its rhythm along. The two ladders answer
294
+ different questions: `--skin--spacing-*` sets a thing apart from what surrounds it, while `--skin--scaling-*` sizes what
295
+ is measured against the text rather than spaced from it, a glyph, a spinner, a swatch or a dot, with
296
+ `--skin--scaling-100` matching the text it sits in.
297
+
298
+ Radii come both ways: `--skin--border-radius` is a length, rounding a field, a panel or a button by the same amount
299
+ whatever size it is given, while `--skin--border-radius-*` carries a share of the box, so a mark rounds with its own
300
+ size and every share above a half draws the same roundel. `--skin--stroke-width` carries a bare number, in the user
301
+ units of the vector viewport it applies to, so the weight of a glyph holds at any size. `--skin--stroke-width-strong`
302
+ strokes a glyph set beside strong text, so the two read at the same weight, and follows the plain width.
303
+
304
+ A breakpoint is not a width token, because CSS accepts no custom property in a media feature and
305
+ `@media (min-width: var(--x))` never matches. The design system runs the four queries once and hands the answers on as
306
+ `--skin--viewport-*` tokens, `off` by default and `on` from each width upwards, which a rule branches on through a
307
+ style query.
308
+
309
+ | Token | From | What it answers |
310
+ |---------------------------|---------|--------------------------------------------------------------|
311
+ | `--skin--viewport-small` | `30rem` | a phone held upright, the one-column floor |
312
+ | `--skin--viewport-medium` | `48rem` | a tablet or a split window, where a second column fits |
313
+ | `--skin--viewport-large` | `64rem` | a laptop, where navigation becomes a rail |
314
+ | `--skin--viewport-xlarge` | `90rem` | a desktop, where the measure is capped rather than stretched |
315
+
316
+ Every width is a floor, so the narrow layout is what a rule states unconditionally and each breakpoint only adds to
317
+ it, leaving the narrower switches on; a band pairs the wider switch as `off` with the narrower one as `on`.
318
+
319
+ ```css
320
+ @container style(--skin--viewport-medium: on) {
321
+ app-screen {
322
+ grid-template-columns: 1fr 2fr;
323
+ }
324
+ }
325
+ ```
326
+
327
+ The tokens are assigned on the root element and inherit, so every element sits inside a container the query matches
328
+ and no rule declares one of its own. They make a breakpoint reusable rather than retunable: the width stays in the
329
+ stylesheet, so overriding a switch forces it without moving the threshold, and an app wanting thresholds of its own
330
+ writes its own media queries. Code needing the same answer reads the token through `getComputedStyle`, as it reads
331
+ any other value outside the cascade, and gets the same answer a style query would at that moment.
332
+
333
+ A widget changing shape because of the space it was given states a `@container` size query against its own inline size
334
+ instead and needs no breakpoint at all.
335
+
336
+ A component styled against a token it cannot count on, because the stylesheet may not be loaded at all, names its own
337
+ fallback in the reference:
338
+
339
+ ```css
340
+ color: var(--skin--color-strong, #B74300);
341
+ ```
342
+
343
+ Restyle a single subtree instead by assigning the tokens inline, naming them through the published contract rather than
344
+ as literal strings, so a renamed token breaks the build instead of silently losing its styling:
345
+
346
+ ```tsx
347
+ import { css } from "@grafctory/skin";
348
+
349
+ <section style={css({ colorStrong: "#06C" })}>
350
+ ```
351
+
352
+ Read a token where a single CSS value is written by hand rather than by a rule, in an inline style or a presentation
353
+ attribute. The reference resolves wherever it is read, so it carries whatever the app overrode and whichever colour
354
+ scheme is in force:
355
+
356
+ ```tsx
357
+ import { css, skin } from "@grafctory/skin";
358
+
359
+ <span style={{ backgroundColor: css.var(skin.colorStrong) }}/>
360
+ ```
361
+
362
+ A component that cannot count on the stylesheet being loaded writes the reference by hand instead, naming in it the
363
+ fallback it wants, as above.
364
+
365
+ Tint a surface with a colour rather than paint it in one, to class an area as the columns of a board along its flow or
366
+ the lanes of a swimlane by type. The colour is washed into the sunken surface by the share given, so at a low share the
367
+ text the area holds stays readable on the page colour, in either colour scheme, with no `color` of its own:
368
+
369
+ ```tsx
370
+ import { css, skin } from "@grafctory/skin";
371
+
372
+ <div style={css({ backgroundColor: css.tint(skin.colorHeat030, 20) })}>
373
+ ```
374
+
375
+ Where a reference doesn't reach, on a canvas or against an API taking a colour as text, take the value a token resolves
376
+ to for the element it applies to, rather than a copy of the default, and keep whatever the app overrode along with the
377
+ colour scheme in force:
378
+
379
+ ```typescript
380
+ import { skin } from "@grafctory/skin";
381
+
382
+ getComputedStyle(element).getPropertyValue(skin.colorStrong);
383
+ ```
384
+
385
+ ## Heading Groups
386
+
387
+ An `hgroup` titles a page or a section with no class attached. Its heading is set as display type, on the tighter
388
+ display leading and with no rule beneath; an `h1` or `h2` also stands well above its size in running text. A paragraph
389
+ ahead of the heading is an eyebrow naming the part of the page, set in strong small capitals of the strong accent. A
390
+ paragraph after it is a lead saying what follows, set larger in the label colour. The whole group keeps to the prose
391
+ measure, so a long title or a long lead never runs across the full width of a wide column.
392
+
393
+ ```html
394
+ <hgroup>
395
+ <p>Foundations</p>
396
+ <h2>Colours</h2>
397
+ <p>A handful of anchors carry literal values, and every other colour derives from them.</p>
398
+ </hgroup>
399
+ ```
400
+
401
+ ## Navigation
402
+
403
+ A list nested inside a `nav` reads as a compact table of contents, one level of nesting for each level of sections.
404
+ Entries are set small in the label colour. A label too long for the column, such as an identifier with no spaces, breaks
405
+ at the column edge rather than widening it. Sibling entries sit further apart than the lines of one label, so a wrapped
406
+ label still reads as a single entry. Where any top-level entry heads subsections, every top-level entry is set in strong
407
+ small capitals with its subsections unindented beneath it; an outline of top-level entries alone reads as a plain list,
408
+ spaced as the entries of a group are, so a flat outline and a nested one share one rhythm. Each level from the third on
409
+ is indented, and a link answers the pointer as any link does. How deep an outline runs is left to its markup: the
410
+ outline never hides an entry it lists, so every entry stays reachable by keyboard, pointer and screen reader alike.
411
+
412
+ A top-level group may fold behind its label: wrap its label and its list in a `details` element, the label as the
413
+ `summary`. The summary reads as the label it stands for, with a chevron at the far end of the line, and folded groups
414
+ close up into a run of labels. Mark a group `open` to show its entries from the start, such as the group holding the
415
+ section in view, so the reader finds the current entry without opening anything.
416
+
417
+ Each entry is a link to the heading of its section, or a `span` naming a section that has no heading to link to, such
418
+ as a group of sections. Keep the entries out of headings: the page outline then lists every heading once, and a screen
419
+ reader announces the depth of each entry from the nesting of its list, as for any other nested list on the page.
420
+
421
+ ```html
422
+ <nav aria-label="Contents">
423
+ <ul>
424
+ <li><span>Foundations</span>
425
+ <ul>
426
+ <li><a href="#colours">Colours</a></li>
427
+ </ul>
428
+ </li>
429
+ </ul>
430
+ </nav>
431
+ ```
432
+
433
+ The entry for the section in view carries `aria-current="location"`. Assistive technologies announce it as the
434
+ current location, and the design system sets it in the strong weight and the strong accent. The app sets the mark from
435
+ the scroll position rather than from the location fragment, which says only where the reader last jumped. Watch every
436
+ section, including a lead section with no entry of its own, so that scrolling back to the top clears every mark:
437
+
438
+ ```typescript
439
+ const links = [...document.querySelectorAll<HTMLAnchorElement>("nav a")];
440
+
441
+ const observer = new IntersectionObserver(entries => entries
442
+ .filter(entry => entry.isIntersecting)
443
+ .forEach(entry => links.forEach(link => link.hash === `#${entry.target.id}`
444
+ ? link.setAttribute("aria-current", "location") // an empty value reads as false
445
+ : link.removeAttribute("aria-current")
446
+ )), { rootMargin: "-30% 0px -65% 0px" } // a band a third of the way down the viewport
447
+ );
448
+
449
+ document.querySelectorAll("main > section").forEach(section => observer.observe(section));
450
+ ```
451
+
452
+ ## Off-screen Content
453
+
454
+ Text only a screen reader needs, such as a status region announcing what a gesture did or the name of a control shown
455
+ as an icon, carries `data-offscreen`. The element is kept from sight and out of the page flow while assistive technology
456
+ still finds and reads it, where the native `hidden` attribute would remove it for every reader alike.
457
+
458
+ ```html
459
+ <p role="status" data-offscreen>Card moved to Done.</p>
460
+ ```
461
+
462
+ # Support
463
+
464
+ - open an [issue](https://github.com/grafctory/skin/issues) to report a problem or to suggest a new feature
465
+ - start a [discussion](https://github.com/grafctory/skin/discussions) to ask a how-to question or to share an idea
466
+
467
+ # License
468
+
469
+ This project is licensed under the Apache 2.0 License –
470
+ see [LICENSE](https://github.com/grafctory/skin?tab=Apache-2.0-1-ov-file) file for details.