@aitrien/motifspec 1.19.0 → 1.20.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 (45) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +89 -70
  3. package/dist/codex.css +56 -3
  4. package/dist/codex.js +1 -1
  5. package/dist/tokens.css +1 -1
  6. package/dist/tokens.js +1 -1
  7. package/dist/tokens.json +1 -1
  8. package/docs/components/_template.md +1 -0
  9. package/docs/components/accession-label.md +1 -0
  10. package/docs/components/backdrop.md +5 -5
  11. package/docs/components/docs-shell.md +2 -1
  12. package/docs/components/figure.md +1 -0
  13. package/docs/components/ornament.md +2 -1
  14. package/docs/components/page-footer.md +24 -5
  15. package/docs/components/prose.md +1 -0
  16. package/docs/components/site-footer.md +2 -2
  17. package/docs/components/specimen-plate.md +1 -1
  18. package/docs/components/status.md +1 -0
  19. package/docs/components/token-table.md +96 -0
  20. package/docs/foundations/colour.md +19 -0
  21. package/docs/foundations/icons.md +13 -0
  22. package/docs/foundations/motion.md +14 -0
  23. package/docs/foundations/ornaments.md +21 -0
  24. package/docs/foundations/space-and-size.md +26 -0
  25. package/docs/foundations/type.md +22 -0
  26. package/docs/hugo.md +9 -5
  27. package/docs/layouts/a-la-carte.md +1 -0
  28. package/docs/layouts/dashboard.md +2 -0
  29. package/docs/layouts/documentation.md +7 -4
  30. package/docs/layouts/portfolio.md +2 -0
  31. package/docs/reference/checker-rules.md +13 -0
  32. package/docs/reference/contrast.md +18 -0
  33. package/docs/reference/tokens.md +14 -0
  34. package/docs/syntax-highlighting.md +1 -0
  35. package/layouts/_markup/render-blockquote.html +1 -1
  36. package/layouts/_markup/render-image.html +5 -4
  37. package/layouts/_markup/render-link.html +1 -1
  38. package/layouts/_markup/render-table.html +3 -2
  39. package/layouts/_partials/motifspec/article.html +12 -7
  40. package/layouts/_partials/motifspec/body-start.html +5 -4
  41. package/layouts/_partials/motifspec/docs-nav.html +2 -2
  42. package/layouts/_partials/motifspec/page-footer.html +32 -11
  43. package/layouts/_partials/motifspec/site-header.html +1 -1
  44. package/package.json +6 -4
  45. package/scripts/lib.mjs +1 -0
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: token-table
3
+ status: stable
4
+ layouts: [documentation]
5
+ tokens:
6
+ - border.width.hairline
7
+ - color.accent.fill.rest
8
+ - color.border.default
9
+ - color.border.subtle
10
+ - color.surface.base
11
+ - color.surface.sunken
12
+ - color.text.primary
13
+ - font.family.body
14
+ - font.family.mono
15
+ - font.line-height.heading
16
+ - font.line-height.ui
17
+ - font.size.label
18
+ - font.weight.strong
19
+ - size.target.control
20
+ - size.target.min
21
+ - size.target.touch
22
+ - space.inline.sm
23
+ - space.inline.xs
24
+ - space.inset.sm
25
+ - space.inset.xs
26
+ - space.stack.xs
27
+ ---
28
+
29
+ # Token table
30
+
31
+ A token shown as it looks, beside its name, value and rule: colour tiles, a primitive palette, type samples, spacing bars and contrast samples.
32
+
33
+ ## When to use
34
+
35
+ - On the reference pages of a design system's documentation, where a reader compares tokens by eye as well as by name.
36
+ - Inside a data table (`data-table.md`), one sample per row, or as a palette of one hue's steps.
37
+
38
+ ## When not to use
39
+
40
+ - To decorate a page; a swatch stands for a token and is always labelled with its name.
41
+ - For a colour that isn't a token. Show only what the tokens define.
42
+
43
+ ## Markup
44
+
45
+ ```html {preview=true}
46
+ <div class="cx-table cx-token-table" role="region" aria-labelledby="tokens-example" tabindex="0">
47
+ <table>
48
+ <caption id="tokens-example">Text colours</caption>
49
+ <thead><tr><th scope="col">Token</th><th scope="col">Light</th><th scope="col">Dark</th><th scope="col">Rule</th></tr></thead>
50
+ <tbody>
51
+ <tr><th scope="row"><code>color.text.primary</code></th><td><span class="cx-swatch cx-swatch--tile"><b>ash.950</b><span>light value</span></span></td><td><span class="cx-swatch cx-swatch--tile"><b>ash.100</b><span>dark value</span></span></td><td>Body copy, headings and any text a reader must read.</td></tr>
52
+ </tbody>
53
+ </table>
54
+ </div>
55
+ <ol class="cx-palette" aria-label="ash">
56
+ <li><span class="cx-swatch cx-swatch--tile"><b>50</b><span>value</span></span></li>
57
+ <li><span class="cx-swatch cx-swatch--tile"><b>100</b><span>value</span></span></li>
58
+ </ol>
59
+ <span class="cx-pair-sample">Aa</span>
60
+ <span class="cx-token-sample">Type sample</span>
61
+ <span class="cx-token-bar"></span>
62
+ ```
63
+
64
+ <!-- caption: Token table parts -->
65
+ | Class | Shows | Set by the generator |
66
+ |---|---|---|
67
+ | `cx-token-table` | On a data table: keeps each token's name, in the row header, on one line | |
68
+ | `cx-swatch` | A small colour chip | `--_swatch` |
69
+ | `cx-swatch--tile` | A colour tile: the colour as the background, with its name and value written on it | `--_swatch`, and `--_ink` for the text |
70
+ | `cx-palette` | One hue's steps as a grid of tiles, lightest first | Each tile's |
71
+ | `cx-pair-sample` | "Aa" in a foreground on a background, beside the pair's ratio | `--_fg` and `--_bg` |
72
+ | `cx-token-sample` | Text at a size or in a family | `--_size`, `--_family` |
73
+ | `cx-token-bar` | A length, as a bar | `--_width` |
74
+
75
+ The value each part shows comes from a private custom property on the element, set in a `style` attribute by MotifSpec's docs generator (`scripts/docs-reference.mjs`) from `dist/tokens.json`. That's the only place MotifSpec writes a style attribute, and only in generated pages, which the checker doesn't read. Hand-written markup can't set them (the checker fails any `style` attribute), so it shows the neutral fallback, as above.
76
+
77
+ ## Do
78
+
79
+ - Name the token in the same row as its sample, in `<code>`, and write the colour's value on its tile: a reader who can't tell the colours apart reads the value.
80
+ - Write a tile's text in the ink that reads best on it, the darkest or the lightest neutral. The generator measures both and picks the higher contrast; a primitive keeps its value in both themes, so the choice holds in each.
81
+ - Show a semantic colour's light and dark values side by side, so a reader can check both themes in one view.
82
+ - Generate the tables from the tokens, so a changed value shows on the next build.
83
+
84
+ ## Don't
85
+
86
+ - Don't write token tables by hand; they go out of date.
87
+ - Don't show a primitive outside the palette. Pages and components use semantic tokens.
88
+ - Don't let a sample carry meaning the text doesn't.
89
+
90
+ ## Accessibility
91
+
92
+ - Swatches, bars and samples repeat what the text in the same row says; each table has a caption that names it (`data-table.md`).
93
+ - A palette is an ordered list named by its hue (`aria-label`).
94
+ - A tile's text is in whichever of the darkest and lightest neutral contrasts more with the tile. Against black or white, the better of the two is at least 4.5:1 on any colour, so every tile's label meets the label size's target.
95
+ - A pair sample's own contrast is the pair's: it is drawn in the colours it measures, so a failing pair looks like one.
96
+ - Pairs: the text around each sample is `color.text.primary` and `color.text.muted` on `color.surface.raised` (7:1 and 4.5:1); a chip's edge is `color.border.default`.
@@ -0,0 +1,19 @@
1
+ ---
2
+ weight: 3
3
+ ---
4
+
5
+ # Colour
6
+
7
+ The primitive palette, and the semantic colours built on it that components and pages use, each with its light and dark value and its rule.
8
+
9
+ ## Palette
10
+
11
+ Five hues generated in OKLCH so the steps are perceptually even, stored as sRGB. Primitives are never used directly in components or pages: they exist so semantic colours can point at them.
12
+
13
+ *Generated from `tokens/color.json`: the palette.*
14
+
15
+ ## Semantic colours
16
+
17
+ Each semantic colour names a primitive for each theme, and the page switches with `light-dark()`, following the system unless the reader picks a theme. A text colour lists the surfaces it may sit on; [Contrast pairs](/reference/contrast/) measures every one.
18
+
19
+ *Generated from `tokens/color.json`: semantic colours.*
@@ -0,0 +1,13 @@
1
+ ---
2
+ weight: 7
3
+ ---
4
+
5
+ # Icons
6
+
7
+ The approved icons, each for its listed use: Material Symbols in the Sharp style at weight 300, self-hosted as a sprite.
8
+
9
+ ## Approved icons
10
+
11
+ Use them as `icon.md` says: beside text that says the same thing, from the sprite.
12
+
13
+ *Generated from `icons/manifest.json`: the icons.*
@@ -0,0 +1,14 @@
1
+ ---
2
+ weight: 6
3
+ toc: false
4
+ ---
5
+
6
+ # Motion
7
+
8
+ The durations and curves for the few things that move. Under reduced motion every duration is zero.
9
+
10
+ ## Durations and curves
11
+
12
+ Only state changes animate, and the contour survey ([Principles](/foundations/principles/)).
13
+
14
+ *Generated from `tokens/motion.json`: motion tokens.*
@@ -0,0 +1,21 @@
1
+ ---
2
+ weight: 8
3
+ ---
4
+
5
+ # Ornaments
6
+
7
+ The approved Yarndings 12 glyphs, by group, and the ones that are never used. Ornaments are decoration only, always hidden from assistive tech (`ornament.md`).
8
+
9
+ ## Roles
10
+
11
+ The system's own ornaments always use these glyphs.
12
+
13
+ *Generated from `tokens/typography.json`: ornament roles.*
14
+
15
+ ## Approved glyphs
16
+
17
+ *Generated from `tokens/typography.json`: approved glyphs.*
18
+
19
+ ## Never used
20
+
21
+ *Generated from `tokens/typography.json`: forbidden glyphs.*
@@ -0,0 +1,26 @@
1
+ ---
2
+ weight: 5
3
+ toc: false
4
+ ---
5
+
6
+ # Space and size
7
+
8
+ A 4px spacing grid with roles for padding and gaps, and the sizes, radii and borders components are drawn with.
9
+
10
+ ## Spacing
11
+
12
+ Components use the semantic roles: inset is padding, stack is a vertical gap, inline a horizontal gap, and section and gutter space out a page. The steps they point at, to scale:
13
+
14
+ *Generated from `tokens/space.json`: spacing steps.*
15
+
16
+ *Generated from `tokens/space.json`: space tokens.*
17
+
18
+ ## Size
19
+
20
+ *Generated from `tokens/size.json`: size tokens.*
21
+
22
+ ## Radius and border
23
+
24
+ *Generated from `tokens/radius.json`: radius tokens.*
25
+
26
+ *Generated from `tokens/border.json`: border tokens.*
@@ -0,0 +1,22 @@
1
+ ---
2
+ weight: 4
3
+ toc: false
4
+ ---
5
+
6
+ # Type
7
+
8
+ The typefaces, the type scale and the weights, leading and tracking that set every piece of text.
9
+
10
+ ## Typefaces
11
+
12
+ *Generated from `tokens/typography.json`: typefaces.*
13
+
14
+ ## Type scale
15
+
16
+ Sizes are fluid between the smallest and widest screens, and the smallest stay fixed so labels never shrink. Each sample is set at its size.
17
+
18
+ *Generated from `tokens/typography.json`: the type scale.*
19
+
20
+ ## Weight, leading and tracking
21
+
22
+ *Generated from `tokens/typography.json`: weight, leading and tracking.*
package/docs/hugo.md CHANGED
@@ -41,10 +41,11 @@ Pin a release with `hugo mod get github.com/aitrien/motifspec@vX.Y.Z`. The modul
41
41
  </html>
42
42
  ```
43
43
 
44
+ <!-- caption: Page shell partials -->
44
45
  | Partial | What it writes |
45
46
  |---|---|
46
47
  | `motifspec/head.html` | The stored-theme snippet, font preloads, `codex.css` and `codex.js`, in that order. |
47
- | `motifspec/body-start.html` | Call with the page. On the home page, the head of the backdrop (on a documentation site, the side, on every page); then the icon sprite and the skip link to `#main`. |
48
+ | `motifspec/body-start.html` | Call with the page. On the home page, the head of the backdrop (on a documentation site's other pages, the side); then the icon sprite and the skip link to `#main`. |
48
49
  | `motifspec/site-header.html` | `site-header.md`: wordmark from `site.Title` and `site.Params.role`, nav from `site.Menus.main` and the theme toggle. A menu entry is current when its `identifier` is the page's section; one whose URL starts with `http` gets the outward arrow. With `params.motifspec.search = true`, search comes first (`search.md`); with `params.motifspec.version` (and `changelog`, a URL), the version comes before the theme toggle. |
49
50
  | `motifspec/body-end.html` | The foot of the backdrop, behind the footer, and `plate.js`, which settles the home page's contours and lets the pointer warm them. |
50
51
 
@@ -67,7 +68,7 @@ A site using the documentation layout (`docs/layouts/documentation.md`) puts the
67
68
  </body>
68
69
  ```
69
70
 
70
- With `params.motifspec.layout = "documentation"`, `body-start.html` writes the side of the backdrop on every page, the docs home included, and `cx-backdrop-page--side` puts it down the left edge; on a phone the foot shows instead (`backdrop.md`).
71
+ With `params.motifspec.layout = "documentation"`, `body-start.html` writes the side of the backdrop on every page but the home page, and `cx-backdrop-page--side` puts it down the left edge; on a phone the foot shows instead (`backdrop.md`). The home page is the landing page: full width, outside the docs shell, with `<body class="cx-backdrop-page">` and the head of the backdrop, as in the page shell above.
71
72
 
72
73
  An article page's `main` block, in order: the page head with `page-actions.html` after the lede, `article.html`, `page-footer.html`, then `pagination-docs.html`.
73
74
 
@@ -85,7 +86,7 @@ enableGitInfo = true # Lastmod from Git, for "Last updated"
85
86
 
86
87
  [params.motifspec]
87
88
  layout = "documentation"
88
- editURL = "https://github.com/owner/repo/edit/main/"
89
+ sourceURL = "https://github.com/owner/repo/blob/main/"
89
90
  ```
90
91
 
91
92
  The templates are `layouts/page.markdown.md`, `section.markdown.md` and `home.markdown.md`; a site's own file at the same path wins.
@@ -113,9 +114,10 @@ hugo --gc --minify && npx pagefind@1.5.0 --site public
113
114
 
114
115
  Every partial below is called as `partial "motifspec/<name>.html" <context>`.
115
116
 
117
+ <!-- caption: Component partials -->
116
118
  | Partial | Doc | Context |
117
119
  |---|---|---|
118
- | `article.html` | `prose.md`, `table-of-contents.md`, `ornament.md` | `dict "page" . "toc" "always"` or `"auto"` (auto shows the TOC at three or more h2s). Ends the prose with the end mark, so the content must end with a paragraph. |
120
+ | `article.html` | `prose.md`, `table-of-contents.md`, `ornament.md` | `dict "page" . "toc" "always"`, `"auto"` (the TOC at three or more h2s) or `"never"` (for a page such as a changelog, whose headings repeat). Ends the prose with the end mark, so the content must end with a paragraph; on a documentation site, no end mark (`docs/layouts/documentation.md`, Decoration). |
119
121
  | `project-card.html` | `project-card.md` | `dict "page" . "level" 2` (the heading level that fits the page outline; default 3). |
120
122
  | `post-list-item.html` | `post-list-item.md` | `dict "page" . "level" 3`. Writes an `<li>`, so put it in `<ol class="cx-posts">`. |
121
123
  | `accession/label.html` | `accession-label.md` | `dict "page" . "variant" "lead"` above the title, or `"card"` after the article (shown on a phone). |
@@ -130,7 +132,7 @@ Every partial below is called as `partial "motifspec/<name>.html" <context>`.
130
132
  | `pagination-pages.html` | `pagination.md` | `dict "pager" $pager "label" "Writing pages"`. Pages of a paginated list; nothing when it fits on one page. |
131
133
  | `docs-nav.html` | `docs-shell.md` | A page. The documentation layout's navigation: top-level pages, then a group per top-level section in weight order. `docs_nav: false` in front matter leaves a page or section out. |
132
134
  | `page-actions.html` | `page-actions.md` | A page. Copy page and View as Markdown, when the page has the markdown output format; nothing otherwise. |
133
- | `page-footer.html` | `page-footer.md` | A page. Last updated (its `Lastmod`) and Edit this page, from `params.motifspec.editURL` and, for a site in a folder of its repository, `params.motifspec.siteDir`. |
135
+ | `page-footer.html` | `page-footer.md` | A page. Last updated (its `Lastmod`), Generated from (its `data` param) and View source, from `params.motifspec.sourceURL` (or Edit this page, from `editURL`) and, for a site in a folder of its repository, `params.motifspec.siteDir`. A page with no file of its own sets `source` and, for one section of a file, `sourceAnchor`. |
134
136
  | `pagination-docs.html` | `pagination.md`, `page-footer.md` | A page. Previous and next in the order `docs-nav.html` lists the pages. |
135
137
  | `search.html` | `search.md` | A page. The search trigger and dialog; `site-header.html` calls it when `params.motifspec.search` is true. |
136
138
  | `back-link.html` | `button-and-link.md` | `dict "href" "…" "label" "All work"`. |
@@ -152,6 +154,7 @@ tags: [react, webgl, a11y]
152
154
  hero: { src: hero.png, alt: "…", caption: "…" }
153
155
  ```
154
156
 
157
+ <!-- caption: Front matter -->
155
158
  | Field | Used by | Notes |
156
159
  |---|---|---|
157
160
  | `summary` | cards, rows | The lede and the card or row summary. |
@@ -166,6 +169,7 @@ hero: { src: hero.png, alt: "…", caption: "…" }
166
169
 
167
170
  These apply to all Markdown content once the module is imported.
168
171
 
172
+ <!-- caption: Render hooks -->
169
173
  | Hook | Markdown | Doc |
170
174
  |---|---|---|
171
175
  | `render-heading.html` | Headings get ids; h2s get a `#` anchor. | `heading-anchor.md` |
@@ -29,6 +29,7 @@ One `<h1>` per page. Use heading anchors only on headings that start sections of
29
29
 
30
30
  ## Choosing a stack
31
31
 
32
+ <!-- caption: Choosing a stack -->
32
33
  | The project | Use |
33
34
  |---|---|
34
35
  | Already has a stack | Keep it. MotifSpec adapts to the project, not the reverse. |
@@ -17,6 +17,7 @@ Planned: a side navigation column (wordmark, grouped links, the theme toggle and
17
17
 
18
18
  ## Page templates
19
19
 
20
+ <!-- caption: Page templates -->
20
21
  | Template | Order | Dominant | Secondary |
21
22
  |---|---|---|---|
22
23
  | **Overview** | Page head (title, when the readings were last updated, page-wide controls) → alerts as callouts → headline figures → the main column and a side column of sections | Alerts and headline figures | Detail sections |
@@ -51,6 +52,7 @@ MotifSpec doesn't fetch data; where an app gets its readings is the project's de
51
52
 
52
53
  ## Choosing a stack
53
54
 
55
+ <!-- caption: Choosing a stack -->
54
56
  | The project | Use |
55
57
  |---|---|
56
58
  | Already has a stack | Keep it. MotifSpec adapts to the project, not the reverse. |
@@ -6,17 +6,18 @@ For product and system documentation: guides, reference pages and a changelog. m
6
6
 
7
7
  Complete since 1.19.0: the docs shell with its page navigation (`docs-shell.md`), search (`search.md`) and the version and repository link in the header (`site-header.md`), page actions (`page-actions.md`), the page footer with previous and next (`page-footer.md`), a Markdown copy of each page, and the component preview (`component-preview.md`), with every shared component, including steps, tabs, disclosures and keyboard keys, plus the table of contents, heading anchors and the ornaments.
8
8
 
9
- Not yet: tables generated from MotifSpec's own data (tokens, icons, checker rules) come with motifspec.com, the layout's first site. Don't write classes for anything MotifSpec doesn't define; the checker fails on them.
9
+ Since 1.20.0, the token table (`token-table.md`) for reference pages generated from a design system's tokens. Don't write classes for anything MotifSpec doesn't define; the checker fails on them.
10
10
 
11
11
  ## Shell
12
12
 
13
- The site header and footer, and between them the docs shell (`docs-shell.md`): grouped page navigation on the left, the page in the middle and "On this page" (the table of contents) on the right when there is room. Below `size.breakpoint.lg` "On this page" moves above the article, and below `size.breakpoint.md` the page navigation sits behind a Menu control above the page. In Hugo, see `docs/hugo.md` (A documentation page).
13
+ The site header and footer, and between them, on every page but the landing page, the docs shell (`docs-shell.md`): grouped page navigation on the left, the page in the middle and "On this page" (the table of contents) on the right when there is room. Below `size.breakpoint.lg` "On this page" moves above the article, and below `size.breakpoint.md` the page navigation sits behind a Menu control above the page. In Hugo, see `docs/hugo.md` (A documentation page).
14
14
 
15
15
  ## Page templates
16
16
 
17
+ <!-- caption: Page templates -->
17
18
  | Template | Order | Dominant | Secondary |
18
19
  |---|---|---|---|
19
- | **Docs home** | Header → statement (display h1, lede) → entry points to each section → what's new → footer | The statement and entry points | What's new |
20
+ | **Landing** | Header → statement (display h1, lede, a primary button to Getting started and a secondary one) on the frost → why the product exists → entry points to each section → footer. Full width, outside the docs shell. | The statement and its call to action | Why, entry points, the backdrop |
20
21
  | **Article** | Header → title and lede → TOC + prose with figures, code blocks, callouts and tables → edit link and last updated → previous and next → footer | The prose column | TOC, page actions |
21
22
  | **Reference table** | Header → title and one-line intro → the table (tokens, icons, rules) → footer | The table | Intro |
22
23
  | **Changelog** | Header → title → releases, newest first, each with its version, date and changes → footer | The releases | Dates |
@@ -28,7 +29,8 @@ Every shared component, plus the components whose doc lists `documentation` unde
28
29
 
29
30
  ## Decoration
30
31
 
31
- - The side of the backdrop on every page, down the left edge behind the navigation, fading out before the article (`backdrop.md`). On a phone, the foot behind the footer instead. No head, so every page, the docs home included, opens on the plain surface.
32
+ - The landing page: the head of the backdrop behind the statement and the foot behind the footer, as on a portfolio's home page (`backdrop.md`).
33
+ - Every page in the docs shell: the side of the backdrop, down the left edge behind the navigation, fading out before the article. On a phone, the foot behind the footer instead.
32
34
  - The footer band. No other ornaments in articles.
33
35
 
34
36
  ## Headings
@@ -38,6 +40,7 @@ Every shared component, plus the components whose doc lists `documentation` unde
38
40
 
39
41
  ## Choosing a stack
40
42
 
43
+ <!-- caption: Choosing a stack -->
41
44
  | The project | Use |
42
45
  |---|---|
43
46
  | Already has a stack | Keep it. MotifSpec adapts to the project, not the reverse. |
@@ -10,6 +10,7 @@ The site header, the main region and the site footer, on a backdrop page. In Hug
10
10
 
11
11
  Every template sits on the backdrop (`backdrop.md`): its contours show behind the footer, and on the home page behind the header and the statement too. Every template keeps the full site header (Work, Writing, About, the theme toggle) and the footer.
12
12
 
13
+ <!-- caption: Page templates -->
13
14
  | Template | Order | Dominant | Secondary |
14
15
  |---|---|---|---|
15
16
  | **Home** | Header → statement (eyebrow, display h1, lede, primary + secondary button) on the frost, inside the top fade → selected work (2–3 project cards) → recent writing (5 post rows) → capabilities table → footer | Statement and selected work | Writing rows, capabilities, the backdrop |
@@ -46,6 +47,7 @@ The fields each template reads are in `docs/hugo.md` (Front matter the partials
46
47
 
47
48
  ## Choosing a stack
48
49
 
50
+ <!-- caption: Choosing a stack -->
49
51
  | The project | Use |
50
52
  |---|---|
51
53
  | Already has a stack | Keep it. MotifSpec adapts to the project, not the reverse. |
@@ -0,0 +1,13 @@
1
+ ---
2
+ weight: 3
3
+ ---
4
+
5
+ # Checker rules
6
+
7
+ What the checker reports, and what to do instead. Rules that warn will fail the run in a later release.
8
+
9
+ ## Rules
10
+
11
+ *Generated from `scripts/check.mjs`: checker rules.*
12
+
13
+ [Checking a project](/guide/checking/) says how to run it.
@@ -0,0 +1,18 @@
1
+ ---
2
+ weight: 2
3
+ toc: false
4
+ ---
5
+
6
+ # Contrast pairs
7
+
8
+ Every foreground and the surfaces it may sit on (`codex.pairsWith`), measured in both themes on every build.
9
+
10
+ ## Targets
11
+
12
+ Reading text targets 7:1, metadata and status labels 4.5:1, and controls, focus and graphics 3:1. Each sample is drawn in the pair's own colours for that theme.
13
+
14
+ *Generated from `tokens/color.json`: the contrast summary.*
15
+
16
+ ## Pairs
17
+
18
+ *Generated from `tokens/color.json`: contrast pairs.*
@@ -0,0 +1,14 @@
1
+ ---
2
+ weight: 1
3
+ toc: false
4
+ ---
5
+
6
+ # Tokens
7
+
8
+ Every semantic token, with its value and rule. Pages and components use these; the primitives behind them are not for use outside MotifSpec.
9
+
10
+ *Generated from `tokens/`: deprecated tokens.*
11
+
12
+ A token's CSS name is `--cx-` and its name with dashes: `color.text.primary` is `--cx-color-text-primary`. A colour shows its light value, then its dark one.
13
+
14
+ *Generated from `tokens/`: every semantic token.*
@@ -31,6 +31,7 @@ Wrap highlighted output in the code-block component (see `components/code-block.
31
31
  Generated by `npm run build` from `syntax/chroma.json`. Values are light / dark.
32
32
 
33
33
  <!-- TABLE:START -->
34
+ <!-- caption: Chroma mapping -->
34
35
  | Role | Chroma classes | Token | Light / dark | Contrast on code surface (light / dark) |
35
36
  |---|---|---|---|---|
36
37
  | Keywords | `.k` `.kd` `.kn` `.kp` `.kr` `.ow` `.bp` | `color.syntax.keyword` + weight `font.weight.strong` | #942f29 / #feb5ac | 6.79 / 10.36 |
@@ -2,7 +2,7 @@
2
2
  Alerts become callout.md: > [!NOTE], [!TIP], [!WARNING], [!CAUTION] (danger). The title names the kind,
3
3
  the icon repeats it. At most two per article, no code blocks inside.
4
4
  Quotations follow prose.md: end with a line "— Name | Source title" and it becomes the attributed footer. */ -}}
5
- {{- $file := printf "content/%s" .Page.File.Path -}}
5
+ {{- $file := "" }}{{ with .Page.File }}{{ $file = printf "content/%s" .Path }}{{ else }}{{ $file = .Page.Path }}{{ end -}}
6
6
  {{- if eq .Type "alert" -}}
7
7
  {{- $kinds := dict
8
8
  "note" (dict "class" "cx-callout" "icon" "note" "title" "Note")
@@ -3,14 +3,15 @@
3
3
  {width="prose"} on the line after a figure keeps it to the prose measure instead of breaking out.
4
4
  An .svg is a diagram: inlined, coloured by its cx-diagram classes, named by the alt text. */ -}}
5
5
  {{- $img := .Page.Resources.Get .Destination -}}
6
- {{- if not $img }}{{ errorf "content/%s: image %q is not in the page bundle." .Page.File.Path .Destination }}{{ end -}}
7
- {{- if not .PlainText }}{{ errorf "content/%s: image %q has no alt text. Describe what the image shows (figure.md)." .Page.File.Path .Destination }}{{ end -}}
6
+ {{- $file := "" }}{{ with .Page.File }}{{ $file = printf "content/%s" .Path }}{{ else }}{{ $file = .Page.Path }}{{ end -}}
7
+ {{- if not $img }}{{ errorf "%s: image %q is not in the page bundle." $file .Destination }}{{ end -}}
8
+ {{- if not .PlainText }}{{ errorf "%s: image %q has no alt text. Describe what the image shows (figure.md)." $file .Destination }}{{ end -}}
8
9
  {{- if .IsBlock -}}
9
- {{- if not .Title }}{{ errorf "content/%s: figure %q has no caption. Add one as the image title: ![alt](file \"what to notice\")." .Page.File.Path .Destination }}{{ end -}}
10
+ {{- if not .Title }}{{ errorf "%s: figure %q has no caption. Add one as the image title: ![alt](file \"what to notice\")." $file .Destination }}{{ end -}}
10
11
  {{- $first := cond (isset .Page.Params "hero") 2 1 -}}
11
12
  {{- partial "motifspec/figure.html" (dict "image" $img "alt" .PlainText "caption" (.Title | markdownify) "plate" (add .Ordinal $first) "prose" (eq (index .Attributes "width") "prose")) -}}
12
13
  {{- else if eq $img.MediaType.SubType "svg" -}}
13
- {{- errorf "content/%s: %q is an SVG diagram; give it a line of its own so it becomes a figure (figure.md)." .Page.File.Path .Destination -}}
14
+ {{- errorf "%s: %q is an SVG diagram; give it a line of its own so it becomes a figure (figure.md)." $file .Destination -}}
14
15
  {{- else -}}
15
16
  {{- $s := $img.Process "webp" -}}
16
17
  <img src="{{ $s.RelPermalink }}" alt="{{ .PlainText }}" width="{{ $s.Width }}" height="{{ $s.Height }}" loading="lazy" decoding="async">
@@ -7,7 +7,7 @@
7
7
  {{- with or (.Page.GetPage $u.Path) (site.GetPage $u.Path) -}}
8
8
  {{- $dest = printf "%s%s" .RelPermalink (cond (ne $u.Fragment "") (printf "#%s" $u.Fragment) "") -}}
9
9
  {{- else -}}
10
- {{- with $.Page.Resources.Get $u.Path }}{{ $dest = .RelPermalink }}{{ else }}{{ if not (hasPrefix $u.Path "/") }}{{ errorf "content/%s: link %q does not resolve to a page or bundle file." $.Page.File.Path $.Destination }}{{ end }}{{ end -}}
10
+ {{- with $.Page.Resources.Get $u.Path }}{{ $dest = .RelPermalink }}{{ else }}{{ if not (hasPrefix $u.Path "/") }}{{ $file := "" }}{{ with $.Page.File }}{{ $file = printf "content/%s" .Path }}{{ else }}{{ $file = $.Page.Path }}{{ end }}{{ errorf "%s: link %q does not resolve to a page or bundle file." $file $.Destination }}{{ end }}{{ end -}}
11
11
  {{- end -}}
12
12
  {{- end -}}
13
13
  <a href="{{ $dest | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $external }} rel="noopener"{{ end }}>{{ .Text }}{{ if $external }}<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-arrow-outward"></use></svg>{{ end }}</a>
@@ -1,10 +1,11 @@
1
1
  {{- /* data-table.md: a focusable region named by its caption ({caption="…"} after the table; " | " becomes a
2
2
  separator), the first cell of each row as a row header, numeric or right-aligned columns marked is-num,
3
3
  and breakout above four columns. */ -}}
4
- {{- $file := printf "content/%s" .Page.File.Path -}}
4
+ {{- $file := "" }}{{ with .Page.File }}{{ $file = printf "content/%s" .Path }}{{ else }}{{ $file = .Page.Path }}{{ end -}}
5
5
  {{- $caption := .Attributes.caption -}}
6
6
  {{- if not $caption }}{{ errorf "%s: table %d has no caption. Add {caption=\"…\"} on the line after it (data-table.md)." $file (add .Ordinal 1) }}{{ end -}}
7
- {{- $id := printf "tbl-%s-%d" (.Page.File.ContentBaseName | urlize) .Ordinal -}}
7
+ {{- $base := "" }}{{ with .Page.File }}{{ $base = .ContentBaseName }}{{ else }}{{ $base = path.Base .Page.Path }}{{ end -}}
8
+ {{- $id := printf "tbl-%s-%d" ($base | urlize) .Ordinal -}}
8
9
  {{- $cols := 0 }}{{ range first 1 .THead }}{{ $cols = len . }}{{ end -}}
9
10
  {{- $num := slice -}}
10
11
  {{- range $c := seq 0 (sub $cols 1) -}}
@@ -1,18 +1,23 @@
1
1
  {{- /* The cx-article layout: TOC before the main column in the DOM, then prose ending in the flower end mark.
2
- Context: dict "page" "toc" (always | auto). auto shows the TOC when the content has three or more h2s
3
- (table-of-contents.md); a case study passes always. */ -}}
2
+ Context: dict "page" "toc" (always | auto | never). auto shows the TOC when the content has three or more h2s
3
+ (table-of-contents.md); a case study passes always. A documentation site (params.motifspec.layout
4
+ "documentation") has no end mark: its only ornament is the footer band (docs/layouts/documentation.md). */ -}}
4
5
  {{- $p := .page -}}
6
+ {{- $where := "" -}}
7
+ {{- with $p.File }}{{ $where = printf "content/%s" .Path }}{{ else }}{{ $where = $p.Path }}{{ end -}}
8
+ {{- $docs := eq site.Params.motifspec.layout "documentation" -}}
5
9
  {{- $h2s := partial "motifspec/h2s.html" $p -}}
6
- {{- $toc := or (eq .toc "always") (ge (len $h2s) 3) -}}
7
- {{- if and (eq .toc "always") (lt (len $h2s) 1) }}{{ errorf "content/%s: toc \"always\" needs h2 sections to list (table-of-contents.md)." $p.File.Path }}{{ end -}}
10
+ {{- $toc := and (ne .toc "never") (or (eq .toc "always") (ge (len $h2s) 3)) -}}
11
+ {{- if and (eq .toc "always") (lt (len $h2s) 1) }}{{ errorf "%s: toc \"always\" needs h2 sections to list (table-of-contents.md)." $where }}{{ end -}}
8
12
  {{- /* ornament.md: the flower ("g") goes after the last sentence, so the content must end with a paragraph. */ -}}
9
13
  {{- $content := $p.Content | strings.TrimSpace -}}
10
- {{- if gt (len (findRE `class="cx-callout[ "]` $content)) 2 }}{{ errorf "content/%s: more than two callouts in one article; they lose force when repeated (callout.md)." $p.File.Path }}{{ end -}}
14
+ {{- if gt (len (findRE `class="cx-callout[ "]` $content)) 2 }}{{ errorf "%s: more than two callouts in one article; they lose force when repeated (callout.md)." $where }}{{ end -}}
11
15
  {{- $endMark := `<span class="cx-end-mark" aria-hidden="true" data-pagefind-ignore>g</span></p>` -}}
12
- {{- if strings.HasSuffix $content "</p>" -}}
16
+ {{- if $docs -}}
17
+ {{- else if strings.HasSuffix $content "</p>" -}}
13
18
  {{- $content = printf "%s%s" (strings.TrimSuffix "</p>" $content) $endMark -}}
14
19
  {{- else -}}
15
- {{- warnf "content/%s: the article should end with a paragraph so the end mark follows the last sentence." $p.File.Path -}}
20
+ {{- warnf "%s: the article should end with a paragraph so the end mark follows the last sentence." $where -}}
16
21
  {{- end }}
17
22
  <div class="cx-article">
18
23
  {{- if $toc }}
@@ -1,8 +1,9 @@
1
1
  {{- /* docs/hugo.md. Call first inside <body class="cx-backdrop-page"> with the page: the contour backdrop's first
2
- layer (backdrop.md), which is the side layer on every page of a documentation site (params.motifspec.layout
3
- "documentation", with <body class="cx-backdrop-page cx-backdrop-page--side">) and otherwise the head, on the home
4
- page only; the icon sprite (icon.md), once, before anything that uses it; and the skip link to <main id="main">. */ -}}
5
- {{- if eq site.Params.motifspec.layout "documentation" }}
2
+ layer (backdrop.md), which is the head on the home page (a documentation site's landing page included) and,
3
+ on every other page of a documentation site (params.motifspec.layout "documentation", with
4
+ <body class="cx-backdrop-page cx-backdrop-page--side">), the side; the icon sprite (icon.md), once, before
5
+ anything that uses it; and the skip link to <main id="main">. */ -}}
6
+ {{- if and (eq site.Params.motifspec.layout "documentation") (not .IsHome) }}
6
7
  {{ with resources.Get "motifspec/backdrop-side.html" }}{{ .Content | safeHTML }}{{ else }}{{ errorf "motifspec/backdrop-side.html is missing: is the MotifSpec module imported?" }}{{ end }}
7
8
  {{- else if .IsHome }}
8
9
  {{ with resources.Get "motifspec/backdrop.html" }}{{ .Content | safeHTML }}{{ else }}{{ errorf "motifspec/backdrop.html is missing: is the MotifSpec module imported?" }}{{ end }}
@@ -1,6 +1,6 @@
1
1
  {{- /* docs-shell.md: the documentation layout's page navigation. Pages at the top level of the site come first,
2
2
  ungrouped; then each top-level section is a group, in weight order, listing its pages in weight order.
3
- A section or page with `docs_nav: false` in its front matter is left out. Every group starts open; the
3
+ A section or page with `docs_nav: false` in its front matter is left out; one with `deprecated` set says so after its title. Every group starts open; the
4
4
  current page is marked. Context: the current page. */ -}}
5
5
  {{- $current := . -}}
6
6
  {{- $top := where (where site.Home.RegularPages "Params.docs_nav" "ne" false) "Kind" "page" -}}
@@ -21,7 +21,7 @@
21
21
  <summary id="{{ $id }}">{{ .LinkTitle }}<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-expand"></use></svg></summary>
22
22
  <ul class="cx-docs-nav__list" aria-labelledby="{{ $id }}">
23
23
  {{- range where .Pages.ByWeight "Params.docs_nav" "ne" false }}
24
- <li><a href="{{ .RelPermalink }}"{{ if eq .RelPermalink $current.RelPermalink }} aria-current="page"{{ end }}>{{ .LinkTitle }}</a></li>
24
+ <li><a href="{{ .RelPermalink }}"{{ if eq .RelPermalink $current.RelPermalink }} aria-current="page"{{ end }}>{{ .LinkTitle }}{{ if .Params.deprecated }} (deprecated){{ end }}</a></li>
25
25
  {{- end }}
26
26
  </ul>
27
27
  </details>
@@ -1,18 +1,39 @@
1
- {{- /* page-footer.md: when the page last changed (its Lastmod; with enableGitInfo, from Git) and a link to edit its
2
- source. The edit link needs params.motifspec.editURL, the repository's edit address ending in "/", such as
3
- "https://github.com/owner/repo/edit/main/". When the site lives in a folder of the repository, also set
4
- params.motifspec.siteDir to that folder, so files mounted from outside it get the right path.
5
- Context: a page. */ -}}
1
+ {{- /* page-footer.md: when the page last changed (its Lastmod; with enableGitInfo, from Git), what its generated parts
2
+ come from, and a link to its source. Context: a page.
3
+ - The link needs the repository's address for viewing files, params.motifspec.sourceURL, such as
4
+ "https://github.com/owner/repo/blob/main/" ("View source"), or for editing them, params.motifspec.editURL,
5
+ such as "https://github.com/owner/repo/edit/main/" ("Edit this page"). With both, View source is shown.
6
+ - The path is the page's file. When the site lives in a folder of the repository, set params.motifspec.siteDir to
7
+ that folder. A page with no file of its own, such as one a content adapter makes from another file, names that
8
+ file's repository path as its `source` param, and `sourceAnchor` for the heading it starts at, if it is one
9
+ section of the file (View source only; an editor can't open at a heading).
10
+ - A page whose tables or lists are generated names the files they come from as its `data` param (a list of
11
+ repository paths), shown after the date and linked with sourceURL. */ -}}
6
12
  {{- $p := . -}}
7
- {{- $edit := "" -}}
8
- {{- with and site.Params.motifspec.editURL $p.File -}}
13
+ {{- $path := "" -}}
14
+ {{- with $p.Params.source -}}
15
+ {{- $path = strings.TrimPrefix "/" . -}}
16
+ {{- else with $p.File -}}
9
17
  {{- $root := strings.TrimSuffix (printf "/%s" (site.Params.motifspec.siteDir | default "" | strings.Trim "/")) hugo.WorkingDir -}}
10
- {{- $edit = printf "%s%s" site.Params.motifspec.editURL (strings.TrimPrefix (printf "%s/" $root) $p.File.Filename) -}}
18
+ {{- $path = strings.TrimPrefix (printf "%s/" $root) .Filename -}}
19
+ {{- end -}}
20
+ {{- $view := "" -}}
21
+ {{- $edit := "" -}}
22
+ {{- with and $path site.Params.motifspec.sourceURL -}}
23
+ {{- $view = printf "%s%s%s" . $path (cond (ne ($p.Params.sourceAnchor | default "") "") (printf "#%s" $p.Params.sourceAnchor) "") -}}
24
+ {{- else with and $path site.Params.motifspec.editURL -}}
25
+ {{- $edit = printf "%s%s" . $path -}}
11
26
  {{- end -}}
12
- {{- if or (not $p.Lastmod.IsZero) $edit }}
27
+ {{- if or (not $p.Lastmod.IsZero) $view $edit }}
13
28
  <footer class="cx-page-footer" data-pagefind-ignore>
14
- {{- if not $p.Lastmod.IsZero }}
15
- <p class="cx-meta">Last updated <time datetime="{{ $p.Lastmod.Format "2006-01-02" }}">{{ $p.Lastmod.Format "2 January 2006" }}</time></p>
29
+ {{- if or (not $p.Lastmod.IsZero) $p.Params.data }}
30
+ <p class="cx-meta">
31
+ {{- if not $p.Lastmod.IsZero }}Last updated <time datetime="{{ $p.Lastmod.Format "2006-01-02" }}">{{ $p.Lastmod.Format "2 January 2006" }}</time>{{ end }}
32
+ {{- with $p.Params.data }}{{ if not $p.Lastmod.IsZero }} <span class="cx-sep" aria-hidden="true">|</span> {{ end }}<span>Generated from {{ range $i, $d := . }}{{ if $i }}{{ if eq $i (sub (len $p.Params.data) 1) }} and {{ else }}, {{ end }}{{ end }}{{ with site.Params.motifspec.sourceURL }}<a href="{{ . }}{{ $d }}">{{ $d }}</a>{{ else }}{{ $d }}{{ end }}{{ end }}</span>{{ end -}}
33
+ </p>
34
+ {{- end }}
35
+ {{- with $view }}
36
+ <a class="cx-link" href="{{ . }}">View source<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-arrow-outward"></use></svg></a>
16
37
  {{- end }}
17
38
  {{- with $edit }}
18
39
  <a class="cx-link" href="{{ . }}"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-edit"></use></svg>Edit this page<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-arrow-outward"></use></svg></a>