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