@aitrien/motifspec 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +3 -3
- package/dist/backdrop-side.html +1 -0
- package/dist/codex.css +185 -1
- package/dist/codex.js +175 -0
- package/dist/plate.js +4 -4
- package/dist/tokens.css +5 -1
- package/dist/tokens.js +21 -1
- package/dist/tokens.json +21 -1
- package/docs/components/_template.md +1 -1
- package/docs/components/accession-label.md +1 -1
- package/docs/components/backdrop.md +19 -7
- package/docs/components/button-and-link.md +2 -2
- package/docs/components/callout.md +1 -1
- package/docs/components/code-block.md +1 -1
- package/docs/components/component-preview.md +68 -0
- package/docs/components/data-table.md +2 -2
- package/docs/components/disclosure.md +1 -1
- package/docs/components/docs-shell.md +125 -0
- package/docs/components/figure.md +1 -1
- package/docs/components/heading-anchor.md +1 -1
- package/docs/components/icon.md +5 -1
- package/docs/components/keyboard-key.md +1 -1
- package/docs/components/ornament.md +1 -1
- package/docs/components/page-actions.md +56 -0
- package/docs/components/page-footer.md +67 -0
- package/docs/components/pagination.md +2 -1
- package/docs/components/post-list-item.md +1 -1
- package/docs/components/project-card.md +1 -1
- package/docs/components/prose.md +1 -1
- package/docs/components/search.md +117 -0
- package/docs/components/site-footer.md +1 -1
- package/docs/components/site-header.md +22 -1
- package/docs/components/specimen-plate.md +1 -1
- package/docs/components/status.md +1 -1
- package/docs/components/steps.md +70 -0
- package/docs/components/table-of-contents.md +1 -1
- package/docs/components/tabs.md +81 -0
- package/docs/components/tag.md +1 -1
- package/docs/components/tooltip.md +1 -1
- package/docs/hugo.md +67 -3
- package/docs/layouts/documentation.md +4 -7
- package/layouts/_markup/render-codeblock.html +18 -3
- package/layouts/_markup/render-heading.html +1 -1
- package/layouts/_partials/motifspec/article.html +1 -1
- package/layouts/_partials/motifspec/body-start.html +7 -4
- package/layouts/_partials/motifspec/docs-nav.html +31 -0
- package/layouts/_partials/motifspec/page-actions.html +8 -0
- package/layouts/_partials/motifspec/page-footer.html +21 -0
- package/layouts/_partials/motifspec/pagination-docs.html +37 -0
- package/layouts/_partials/motifspec/search.html +18 -0
- package/layouts/_partials/motifspec/site-header.html +11 -2
- package/layouts/_partials/motifspec/table-of-contents.html +1 -1
- package/layouts/home.markdown.md +7 -0
- package/layouts/page.markdown.md +7 -0
- package/layouts/section.markdown.md +7 -0
- package/package.json +2 -1
- package/scripts/check.mjs +55 -21
- package/scripts/lib.mjs +39 -2
- package/tokens/color.json +13 -0
package/docs/components/prose.md
CHANGED
|
@@ -80,7 +80,7 @@ Styles for Markdown-rendered long-form content: headings, paragraphs, lists, blo
|
|
|
80
80
|
|
|
81
81
|
## Markup
|
|
82
82
|
|
|
83
|
-
```html preview
|
|
83
|
+
```html {preview=true}
|
|
84
84
|
<div class="cx-prose">
|
|
85
85
|
<p>A token without a rule is a colour with a name, so the <a href="/writing/rules/">description becomes the contract</a>.</p>
|
|
86
86
|
<h2 id="why">Why tokens need rules <a class="cx-anchor" href="#why" aria-label="Link to Why tokens need rules">#</a></h2>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: search
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
tokens:
|
|
6
|
+
- border.focus.offset
|
|
7
|
+
- border.focus.width
|
|
8
|
+
- border.width.hairline
|
|
9
|
+
- color.border.default
|
|
10
|
+
- color.border.strong
|
|
11
|
+
- color.border.subtle
|
|
12
|
+
- color.focus.ring
|
|
13
|
+
- color.scrim
|
|
14
|
+
- color.surface.base
|
|
15
|
+
- color.surface.highlight
|
|
16
|
+
- color.surface.hover
|
|
17
|
+
- color.surface.raised
|
|
18
|
+
- color.text.muted
|
|
19
|
+
- color.text.primary
|
|
20
|
+
- color.text.secondary
|
|
21
|
+
- color.wash.scrim
|
|
22
|
+
- font.family.mono
|
|
23
|
+
- font.line-height.heading
|
|
24
|
+
- font.line-height.ui
|
|
25
|
+
- font.size.body
|
|
26
|
+
- font.size.label
|
|
27
|
+
- font.size.small
|
|
28
|
+
- font.tracking.ui
|
|
29
|
+
- font.weight.strong
|
|
30
|
+
- radius.pill
|
|
31
|
+
- size.column.card
|
|
32
|
+
- size.target.touch
|
|
33
|
+
- space.gutter.page
|
|
34
|
+
- space.inline.sm
|
|
35
|
+
- space.inline.xs
|
|
36
|
+
- space.inset.md
|
|
37
|
+
- space.inset.sm
|
|
38
|
+
- space.inset.xs
|
|
39
|
+
- space.section.sm
|
|
40
|
+
- space.stack.xs
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# Search
|
|
44
|
+
|
|
45
|
+
A search control in the header that opens a dialog of results as you type, from an index built with the site.
|
|
46
|
+
|
|
47
|
+
## When to use
|
|
48
|
+
|
|
49
|
+
- On a documentation site, where readers arrive with a question rather than a page in mind.
|
|
50
|
+
- On any static site with enough pages that the navigation alone is slow to scan.
|
|
51
|
+
|
|
52
|
+
## When not to use
|
|
53
|
+
|
|
54
|
+
- On a small site; the navigation is quicker.
|
|
55
|
+
- As the only way to reach a page. Every page must also be reachable from the navigation, or from a list of pages, without script.
|
|
56
|
+
- For filtering a list on the page; use a filter (`tag.md`) that changes the list in place.
|
|
57
|
+
|
|
58
|
+
## Markup
|
|
59
|
+
|
|
60
|
+
The trigger goes first in the header's end (`site-header.md`); the dialog can sit next to it.
|
|
61
|
+
|
|
62
|
+
```html {preview=true}
|
|
63
|
+
<button class="cx-search-trigger" type="button" data-search-open aria-haspopup="dialog" aria-controls="cx-search" hidden>
|
|
64
|
+
<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-search"></use></svg>
|
|
65
|
+
<span class="cx-search-trigger__label">Search</span>
|
|
66
|
+
<span class="cx-search-trigger__keys" aria-hidden="true"><kbd class="cx-kbd">Ctrl</kbd><kbd class="cx-kbd">K</kbd></span>
|
|
67
|
+
</button>
|
|
68
|
+
<dialog class="cx-search" id="cx-search" aria-labelledby="cx-search-label" data-search="/pagefind/pagefind.js">
|
|
69
|
+
<form class="cx-search__form" role="search" method="dialog">
|
|
70
|
+
<svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-search"></use></svg>
|
|
71
|
+
<label class="cx-visually-hidden" id="cx-search-label" for="cx-search-input">Search the documentation</label>
|
|
72
|
+
<input class="cx-search__input" id="cx-search-input" type="search" autocomplete="off" spellcheck="false" placeholder="Search" aria-describedby="cx-search-status">
|
|
73
|
+
<button class="cx-search__close" type="button" aria-label="Close search" data-search-close><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
74
|
+
</form>
|
|
75
|
+
<p class="cx-search__status" id="cx-search-status" role="status"></p>
|
|
76
|
+
<ol class="cx-search__results" aria-label="Results"></ol>
|
|
77
|
+
</dialog>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
A result, as the script writes it:
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<li><a class="cx-search__result" href="/guide/checking/"><span class="cx-search__title">Checking a site</span><span class="cx-search__excerpt">Run the <mark>checker</mark> before you push…</span></a></li>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`data-search` is the address of Pagefind's script. Pagefind indexes the built site and writes its index and script into it, so search makes no requests to other hosts. In Hugo, set `params.motifspec.search = true` and run Pagefind after the build (`docs/hugo.md`).
|
|
87
|
+
|
|
88
|
+
## Do
|
|
89
|
+
|
|
90
|
+
- Show the shortcut beside the trigger's label: <kbd class="cx-kbd">Ctrl</kbd> <kbd class="cx-kbd">K</kbd>.
|
|
91
|
+
- Give each result its page title and an excerpt with the matched words marked.
|
|
92
|
+
- Say when there are no results, with the words searched for.
|
|
93
|
+
|
|
94
|
+
## Don't
|
|
95
|
+
|
|
96
|
+
- Don't ship the trigger visible; search needs script, so it starts `hidden`.
|
|
97
|
+
- Don't style Pagefind's own interface or load its stylesheet; this component is the interface.
|
|
98
|
+
- Don't send queries to a search service; the index is part of the site.
|
|
99
|
+
|
|
100
|
+
## Accessibility
|
|
101
|
+
|
|
102
|
+
- The trigger is a button with visible text ("Search"); on a phone, the label hides and its name stays in the DOM. The shortcut keys are `aria-hidden`; the shortcut is a convenience, never the only way in.
|
|
103
|
+
- The dialog is a modal `<dialog>`: focus moves into the field when it opens and returns to where it was when it closes; Escape closes it, even from the field; the page behind is inert.
|
|
104
|
+
- The field is labelled by its visually hidden label, which also names the dialog, and described by the status line, a polite live region that says how many results there are.
|
|
105
|
+
- Arrow keys move from the field into the results and between them; Up from the first result returns to the field.
|
|
106
|
+
- Pairs: `color.text.primary` and `color.text.secondary` on `color.surface.raised` and `color.surface.hover` (7:1); `color.text.primary` on `color.surface.highlight` for matched words (7:1); the trigger's boundary `color.border.strong` on `color.surface.base` (3:1).
|
|
107
|
+
|
|
108
|
+
## Behaviour
|
|
109
|
+
|
|
110
|
+
`dist/codex.js` does all of this; an app that renders search itself does the same.
|
|
111
|
+
|
|
112
|
+
- **Showing the trigger:** every trigger whose `aria-controls` names the dialog is shown.
|
|
113
|
+
- **Opening:** a click on a trigger, Ctrl+K or Cmd+K anywhere, or "/" when focus isn't in a text field. The field's text is selected, and Pagefind's script loads on the first open (`import()` of `data-search`), with `excerptLength: 24`.
|
|
114
|
+
- **Searching:** each input runs `debouncedSearch` (150 ms); the first eight results are shown with their title and excerpt. Only the text and `<mark>` elements of an excerpt are kept. Clearing the field clears the results.
|
|
115
|
+
- **Failing:** if Pagefind's script can't load, the status says "Search isn't available right now." and searching stops.
|
|
116
|
+
- **Closing:** Escape (handled on the dialog, because a search field would otherwise spend the first Escape clearing itself), the close button, or a click on the scrim. Focus returns to the element that had it before opening. Following a result navigates as a link does.
|
|
117
|
+
- **What's indexed:** Pagefind indexes the element with `data-pagefind-body` (the docs shell's `<main>`), skipping anything inside marked `data-pagefind-ignore`; the table of contents, page actions, page footer and pagination are marked.
|
|
@@ -58,7 +58,7 @@ The bar at the top of every page: wordmark, primary nav and the theme toggle. On
|
|
|
58
58
|
|
|
59
59
|
## Markup
|
|
60
60
|
|
|
61
|
-
```html preview
|
|
61
|
+
```html {preview=true}
|
|
62
62
|
<a class="cx-skip-link" href="#main">Skip to content</a>
|
|
63
63
|
<header class="cx-header">
|
|
64
64
|
<div class="cx-container cx-header__inner">
|
|
@@ -81,6 +81,27 @@ The bar at the top of every page: wordmark, primary nav and the theme toggle. On
|
|
|
81
81
|
</header>
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
### In a documentation site
|
|
85
|
+
|
|
86
|
+
A documentation site's header can also carry search (first, before the nav; `search.md`), a link out to the source repository in the nav, with the outward arrow, and the version before the theme toggle, linking to the changelog:
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<div class="cx-header__end">
|
|
90
|
+
<button class="cx-search-trigger" type="button" data-search-open aria-haspopup="dialog" aria-controls="cx-search" hidden>…</button>
|
|
91
|
+
<nav class="cx-nav" aria-label="Main">
|
|
92
|
+
<ul>
|
|
93
|
+
<li><a href="/guide/" aria-current="page">Guide</a></li>
|
|
94
|
+
<li><a href="/reference/">Reference</a></li>
|
|
95
|
+
<li><a href="https://github.com/owner/repo">GitHub<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-arrow-outward"></use></svg></a></li>
|
|
96
|
+
</ul>
|
|
97
|
+
</nav>
|
|
98
|
+
<a class="cx-header__version" href="/reference/changelog/">v1.19.0<span class="cx-visually-hidden">, changelog</span></a>
|
|
99
|
+
<button class="cx-theme-toggle" type="button" data-theme-toggle hidden aria-label="Switch to dark theme">…</button>
|
|
100
|
+
</div>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
A portfolio's header has none of these.
|
|
104
|
+
|
|
84
105
|
### Scripts
|
|
85
106
|
|
|
86
107
|
The toggle needs two scripts, both shipped in `dist/`. The first is a one-line snippet (`dist/theme-init.js`) inlined in `<head>` before the stylesheet, so a stored choice is on `<html>` before the first paint and the page never flashes the wrong theme. The second is `dist/codex.js`, loaded with `defer`, which reveals the toggle and wires it up (it also sets the header's scroll state on backdrop pages, and runs copy buttons, tooltip dismissal and the table of contents).
|
|
@@ -56,7 +56,7 @@ A contour survey of generated terrain: simplex-noise height lines drawn as a sta
|
|
|
56
56
|
|
|
57
57
|
The build writes the plate to `dist/plate.html` (the contours at time zero) and ships the script as `dist/plate.js`. In Hugo, inline the markup and load the script; it finds every `.cx-plate[data-plate-seed]` on its own:
|
|
58
58
|
|
|
59
|
-
```html preview
|
|
59
|
+
```html {preview=true}
|
|
60
60
|
<figure class="cx-plate-frame">
|
|
61
61
|
<label class="cx-plate__pause" hidden>
|
|
62
62
|
<input class="cx-visually-hidden" type="checkbox" aria-label="Pause animation">
|
|
@@ -36,7 +36,7 @@ A short mono label with a dot that names a state: online, degraded, down, live,
|
|
|
36
36
|
|
|
37
37
|
## Markup
|
|
38
38
|
|
|
39
|
-
```html preview
|
|
39
|
+
```html {preview=true}
|
|
40
40
|
<span class="cx-status cx-status--success">Online</span>
|
|
41
41
|
<span class="cx-status cx-status--warning">Degraded</span>
|
|
42
42
|
<span class="cx-status cx-status--danger">Down</span>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: steps
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
tokens:
|
|
6
|
+
- border.width.hairline
|
|
7
|
+
- color.border.subtle
|
|
8
|
+
- color.text.accent
|
|
9
|
+
- font.family.mono
|
|
10
|
+
- font.line-height.body
|
|
11
|
+
- font.line-height.heading
|
|
12
|
+
- font.size.body
|
|
13
|
+
- font.size.label
|
|
14
|
+
- font.tracking.ui
|
|
15
|
+
- font.weight.strong
|
|
16
|
+
- size.target.min
|
|
17
|
+
- space.inline.md
|
|
18
|
+
- space.stack.md
|
|
19
|
+
- space.stack.xs
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Steps
|
|
23
|
+
|
|
24
|
+
A numbered procedure: each step a short title and what to do, in order.
|
|
25
|
+
|
|
26
|
+
## When to use
|
|
27
|
+
|
|
28
|
+
- For a task the reader follows from start to finish: installing, setting up, releasing.
|
|
29
|
+
- When the order matters and the reader needs to keep their place.
|
|
30
|
+
|
|
31
|
+
## When not to use
|
|
32
|
+
|
|
33
|
+
- For items in no particular order; that is a list.
|
|
34
|
+
- For a single action; write it as a sentence.
|
|
35
|
+
- For more than about eight steps; split the task into stages with headings.
|
|
36
|
+
|
|
37
|
+
## Markup
|
|
38
|
+
|
|
39
|
+
```html {preview=true}
|
|
40
|
+
<ol class="cx-steps">
|
|
41
|
+
<li><h3 class="cx-steps__title">Import the module</h3><p>Add it to your site's config.</p></li>
|
|
42
|
+
<li><h3 class="cx-steps__title">Pin a version</h3><p>Run <code>hugo mod get</code> with the version you want.</p></li>
|
|
43
|
+
<li><h3 class="cx-steps__title">Check the site</h3><p>Run the checker before you push.</p></li>
|
|
44
|
+
</ol>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
In Markdown, write an ordered list whose items start with a bold lead-in, and put `{.cx-steps}` on the line after it. The site needs Goldmark's block attributes on (`docs/hugo.md`):
|
|
48
|
+
|
|
49
|
+
```markdown
|
|
50
|
+
1. **Import the module.** Add it to your site's config.
|
|
51
|
+
2. **Pin a version.** Run `hugo mod get` with the version you want.
|
|
52
|
+
{.cx-steps}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Do
|
|
56
|
+
|
|
57
|
+
- Start each step with what the reader does, as a short imperative title.
|
|
58
|
+
- Keep one action per step; a step with "then" in it is two.
|
|
59
|
+
- Use the heading level that fits the page's outline for HTML titles (`h3` under an `h2`).
|
|
60
|
+
|
|
61
|
+
## Don't
|
|
62
|
+
|
|
63
|
+
- Don't nest steps inside steps.
|
|
64
|
+
- Don't number steps by hand; the list numbers them.
|
|
65
|
+
|
|
66
|
+
## Accessibility
|
|
67
|
+
|
|
68
|
+
- It is an `<ol>`, so the count and each step's position are announced.
|
|
69
|
+
- The visible numbers are generated, so they're not read twice.
|
|
70
|
+
- Pairs: `color.text.accent` on `color.surface.base` (4.5:1) for the numbers; `color.text.primary` on `color.surface.base` (7:1).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tabs
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
tokens:
|
|
6
|
+
- border.focus.offset
|
|
7
|
+
- border.focus.width
|
|
8
|
+
- border.width.emphasis
|
|
9
|
+
- border.width.hairline
|
|
10
|
+
- color.accent.border
|
|
11
|
+
- color.border.default
|
|
12
|
+
- color.border.strong
|
|
13
|
+
- color.focus.ring
|
|
14
|
+
- color.text.muted
|
|
15
|
+
- color.text.primary
|
|
16
|
+
- color.text.secondary
|
|
17
|
+
- font.family.mono
|
|
18
|
+
- font.size.label
|
|
19
|
+
- font.size.small
|
|
20
|
+
- font.tracking.label
|
|
21
|
+
- font.weight.strong
|
|
22
|
+
- font.weight.ui
|
|
23
|
+
- size.target.control
|
|
24
|
+
- space.inline.xs
|
|
25
|
+
- space.inset.md
|
|
26
|
+
- space.stack.lg
|
|
27
|
+
- space.stack.sm
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Tabs
|
|
31
|
+
|
|
32
|
+
The same content in two to four forms, such as Hugo and npm, with one shown at a time.
|
|
33
|
+
|
|
34
|
+
## When to use
|
|
35
|
+
|
|
36
|
+
- When readers need one of several equivalent forms and the rest are noise to them: install commands for different stacks, an example as HTML or JSX.
|
|
37
|
+
- When the forms have the same purpose and similar length.
|
|
38
|
+
|
|
39
|
+
## When not to use
|
|
40
|
+
|
|
41
|
+
- For content a reader needs more than one of; show it all.
|
|
42
|
+
- For navigation between pages or sections; use links.
|
|
43
|
+
- For more than four forms, or labels longer than a word or two.
|
|
44
|
+
|
|
45
|
+
## Markup
|
|
46
|
+
|
|
47
|
+
```html {preview=true}
|
|
48
|
+
<div class="cx-tabs" data-tabs="stack" aria-label="Stack">
|
|
49
|
+
<section class="cx-tabs__panel"><h3 class="cx-tabs__label">Hugo</h3><p>Import the module and call the partials.</p></section>
|
|
50
|
+
<section class="cx-tabs__panel"><h3 class="cx-tabs__label">npm</h3><p>Install the package and copy the markup.</p></section>
|
|
51
|
+
</div>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`data-tabs` names the choice. Every set with the same name on a page changes together, and the choice is remembered for the next page.
|
|
55
|
+
|
|
56
|
+
## Do
|
|
57
|
+
|
|
58
|
+
- Label each panel with the form's name, short and parallel: "Hugo", "npm".
|
|
59
|
+
- Put the form most readers need first.
|
|
60
|
+
- Give sets of the same choice the same `data-tabs` name, so a reader picks once.
|
|
61
|
+
|
|
62
|
+
## Don't
|
|
63
|
+
|
|
64
|
+
- Don't hide content that isn't the same thing in another form.
|
|
65
|
+
- Don't nest tabs.
|
|
66
|
+
- Don't write the tab list yourself; the script builds it from the labels.
|
|
67
|
+
|
|
68
|
+
## Accessibility
|
|
69
|
+
|
|
70
|
+
- Without script, every panel shows under its heading, so nothing is hidden from anyone.
|
|
71
|
+
- With script, it follows the ARIA tabs pattern: a `tablist` named by the set's `aria-label`, each tab with `aria-selected` and `aria-controls`, each panel a `tabpanel` named by its tab and focusable.
|
|
72
|
+
- Left and Right move between tabs (wrapping), Home and End go to the first and last; the selected tab is the only one in the Tab order.
|
|
73
|
+
- The selected tab is marked by weight and the accent rule, not colour alone. Pairs: `color.text.primary` and `color.text.secondary` on `color.surface.base` (7:1); `color.accent.border` (3:1).
|
|
74
|
+
|
|
75
|
+
## Behaviour
|
|
76
|
+
|
|
77
|
+
`dist/codex.js` does this; an app that renders tabs itself does the same.
|
|
78
|
+
|
|
79
|
+
- **Building:** in each `.cx-tabs` with two or more `.cx-tabs__panel` children, a tab list is inserted before the first panel, with one button per panel, named by its `.cx-tabs__label`. The set gets `is-tabbed`, which hides the labels.
|
|
80
|
+
- **Choosing:** a click, or the arrow keys, Home and End, selects a tab and shows its panel; the others get `hidden`. Selection follows focus.
|
|
81
|
+
- **Keeping in step:** choosing in a set with `data-tabs` selects the same label in every other set with that name, and stores it as `cx-tabs:<name>` in `localStorage`, which the next page reads. Storage that's blocked is ignored.
|
package/docs/components/tag.md
CHANGED
|
@@ -44,7 +44,7 @@ A small mono label for a topic or technology, optionally linking to its index.
|
|
|
44
44
|
|
|
45
45
|
## Markup
|
|
46
46
|
|
|
47
|
-
```html preview
|
|
47
|
+
```html {preview=true}
|
|
48
48
|
<ul class="cx-tags">
|
|
49
49
|
<li><a class="cx-tag" href="/tags/webgl/">webgl<span class="cx-tag__count">4</span></a></li>
|
|
50
50
|
<li><a class="cx-tag" href="/tags/accessibility/" aria-current="page">accessibility</a></li>
|
|
@@ -38,7 +38,7 @@ A short label that appears beside an icon-only control on hover or keyboard focu
|
|
|
38
38
|
|
|
39
39
|
The tooltip is a child of the control, so hover and focus on the control reveal it:
|
|
40
40
|
|
|
41
|
-
```html preview
|
|
41
|
+
```html {preview=true}
|
|
42
42
|
<button class="cx-theme-toggle" type="button" aria-label="Switch to dark theme">
|
|
43
43
|
<svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-theme-dark"></use></svg>
|
|
44
44
|
<span class="cx-tooltip" aria-hidden="true">Switch to dark theme</span>
|
package/docs/hugo.md
CHANGED
|
@@ -44,12 +44,71 @@ Pin a release with `hugo mod get github.com/aitrien/motifspec@vX.Y.Z`. The modul
|
|
|
44
44
|
| Partial | What it writes |
|
|
45
45
|
|---|---|
|
|
46
46
|
| `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; then the icon sprite and the skip link to `#main`. |
|
|
48
|
-
| `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. |
|
|
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/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
49
|
| `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
50
|
|
|
51
51
|
The footer stays in the site: its columns are the site's own links and colophon. Use the markup in `site-footer.md`.
|
|
52
52
|
|
|
53
|
+
### A documentation page
|
|
54
|
+
|
|
55
|
+
A site using the documentation layout (`docs/layouts/documentation.md`) puts the docs shell inside `<main>`'s place, so the page shell above changes to:
|
|
56
|
+
|
|
57
|
+
```go-html-template
|
|
58
|
+
<body class="cx-backdrop-page cx-backdrop-page--side">
|
|
59
|
+
{{ partial "motifspec/body-start.html" . }}
|
|
60
|
+
{{ partial "motifspec/site-header.html" . }}
|
|
61
|
+
<div class="cx-container cx-docs">
|
|
62
|
+
{{ partial "motifspec/docs-nav.html" . }}
|
|
63
|
+
<main id="main" class="cx-docs__main" tabindex="-1" data-pagefind-body>{{ block "main" . }}{{ end }}</main>
|
|
64
|
+
</div>
|
|
65
|
+
{{/* the site's footer (site-footer.md) */}}
|
|
66
|
+
{{ partial "motifspec/body-end.html" . }}
|
|
67
|
+
</body>
|
|
68
|
+
```
|
|
69
|
+
|
|
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
|
+
|
|
72
|
+
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
|
+
### A Markdown copy of each page
|
|
75
|
+
|
|
76
|
+
The module defines a `markdown` output format that writes `index.md` beside each page's `index.html`: the title, the description and the page's Markdown source. Copy page and View as Markdown use it, and so can an AI assistant. A site turns it on for the kinds of page it wants:
|
|
77
|
+
|
|
78
|
+
```toml {file="hugo.toml"}
|
|
79
|
+
enableGitInfo = true # Lastmod from Git, for "Last updated"
|
|
80
|
+
|
|
81
|
+
[outputs]
|
|
82
|
+
home = ["html", "markdown"]
|
|
83
|
+
page = ["html", "markdown"]
|
|
84
|
+
section = ["html", "markdown"]
|
|
85
|
+
|
|
86
|
+
[params.motifspec]
|
|
87
|
+
layout = "documentation"
|
|
88
|
+
editURL = "https://github.com/owner/repo/edit/main/"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The templates are `layouts/page.markdown.md`, `section.markdown.md` and `home.markdown.md`; a site's own file at the same path wins.
|
|
92
|
+
|
|
93
|
+
### Steps from Markdown
|
|
94
|
+
|
|
95
|
+
Steps (`steps.md`) come from an ordered list with `{.cx-steps}` on the line after it, which needs Goldmark's block attributes:
|
|
96
|
+
|
|
97
|
+
```toml {file="hugo.toml"}
|
|
98
|
+
[markup.goldmark.parser.attribute]
|
|
99
|
+
block = true
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Search
|
|
103
|
+
|
|
104
|
+
Search (`search.md`) reads a Pagefind index of the built site. Turn it on in the header with `params.motifspec.search = true`, and run Pagefind after Hugo, at an exact version, so the index and its script are written into the site:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
hugo --gc --minify && npx pagefind@1.5.0 --site public
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`data-pagefind-body` on the docs shell's `<main>` (above) tells Pagefind to index only the page's own content, so the header, navigation and site footer stay out of the results; the partials mark the table of contents, page actions, page footer and pagination `data-pagefind-ignore`. Pagefind then indexes only pages that have it, so give it to every page that should be found. Search needs script; without it the trigger stays hidden, and the navigation reaches every page.
|
|
111
|
+
|
|
53
112
|
## Component partials
|
|
54
113
|
|
|
55
114
|
Every partial below is called as `partial "motifspec/<name>.html" <context>`.
|
|
@@ -69,6 +128,11 @@ Every partial below is called as `partial "motifspec/<name>.html" <context>`.
|
|
|
69
128
|
| `filed-under.html` | `tag.md`, `docs/layouts/portfolio.md` | A page. "Filed under" and its tags, after an article. |
|
|
70
129
|
| `pagination-entries.html` | `pagination.md` | `dict "page" . "label" "Post navigation" "noun" "Post"`. Previous and next in the page's section, oldest first. |
|
|
71
130
|
| `pagination-pages.html` | `pagination.md` | `dict "pager" $pager "label" "Writing pages"`. Pages of a paginated list; nothing when it fits on one page. |
|
|
131
|
+
| `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
|
+
| `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`. |
|
|
134
|
+
| `pagination-docs.html` | `pagination.md`, `page-footer.md` | A page. Previous and next in the order `docs-nav.html` lists the pages. |
|
|
135
|
+
| `search.html` | `search.md` | A page. The search trigger and dialog; `site-header.html` calls it when `params.motifspec.search` is true. |
|
|
72
136
|
| `back-link.html` | `button-and-link.md` | `dict "href" "…" "label" "All work"`. |
|
|
73
137
|
| `section-heading.html` | `heading-anchor.md` | `dict "id" "work" "title" "Selected work"`, inside a `<section id="work" aria-labelledby="work-title">`. |
|
|
74
138
|
| `tokens.html` | | Call with `partialCached "motifspec/tokens.html" "tokens"`. A map from token name to its entry in `dist/tokens.json`, for templates that need a token's value at build time. |
|
|
@@ -107,7 +171,7 @@ These apply to all Markdown content once the module is imported.
|
|
|
107
171
|
| `render-heading.html` | Headings get ids; h2s get a `#` anchor. | `heading-anchor.md` |
|
|
108
172
|
| `render-image.html` | A standalone image is a numbered figure: ``, image in the page bundle, alt and caption required. `{width="prose"}` on the next line keeps it to the text measure. Inline images stay plain. An `.svg` on its own line becomes a diagram figure, inlined so its `cx-diagram` classes follow the theme. | `figure.md` |
|
|
109
173
|
| `render-table.html` | `{caption="Title \| subtitle"}` on the line after a table is required. Numeric columns align right; more than four columns break out. | `data-table.md` |
|
|
110
|
-
| `render-codeblock.html` | Header bar with language, optional `{file="path"}` and copy button. Breaks out when a line is longer than the prose measure. | `code-block.md` |
|
|
174
|
+
| `render-codeblock.html` | Header bar with language, optional `{file="path"}` and copy button. Breaks out when a line is longer than the prose measure. An `html` fence with `{preview=true}` also shows the example live, above its code. | `code-block.md`, `component-preview.md` |
|
|
111
175
|
| `render-blockquote.html` | `> [!NOTE]`, `[!TIP]`, `[!WARNING]` and `[!CAUTION]` become callouts. A quotation must end with a line `— Name \| Source title`. | `callout.md`, `prose.md` |
|
|
112
176
|
| `render-link.html` | Internal links are resolved, and a broken one fails the build. External links get the outward arrow. | `icon.md` |
|
|
113
177
|
|
|
@@ -4,16 +4,13 @@ For product and system documentation: guides, reference pages and a changelog. m
|
|
|
4
4
|
|
|
5
5
|
## Status
|
|
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
|
-
|
|
10
|
-
- **Not available yet:** the documentation shell, the top bar with search and version, the docs sidebar, page actions (Copy page), the page footer (edit link, last updated), the component preview, the token table, steps and tabs.
|
|
11
|
-
|
|
12
|
-
Don't write classes for parts that aren't available. The checker fails on any `cx-` class MotifSpec doesn't define. Build what you can from the shared components, and say which parts MotifSpec doesn't have yet.
|
|
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.
|
|
13
10
|
|
|
14
11
|
## Shell
|
|
15
12
|
|
|
16
|
-
|
|
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).
|
|
17
14
|
|
|
18
15
|
## Page templates
|
|
19
16
|
|
|
@@ -31,7 +28,7 @@ Every shared component, plus the components whose doc lists `documentation` unde
|
|
|
31
28
|
|
|
32
29
|
## Decoration
|
|
33
30
|
|
|
34
|
-
- The
|
|
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.
|
|
35
32
|
- The footer band. No other ornaments in articles.
|
|
36
33
|
|
|
37
34
|
## Headings
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
{{- /* code-block.md: header bar (language, optional file, copy button revealed by codex.js) around Chroma's
|
|
2
2
|
classed output. Breakout when a line is longer than the prose measure (size.measure.prose, in characters),
|
|
3
|
-
as code-block.md asks. Use {file="path"} for a path.
|
|
3
|
+
as code-block.md asks. Use {file="path"} for a path.
|
|
4
|
+
component-preview.md: an html fence with {preview=true} also shows the example live, above its code, in an
|
|
5
|
+
iframe whose document has the system's theme snippet, stylesheet, script and icon sprite. */ -}}
|
|
4
6
|
{{- $lang := .Type | default "text" -}}
|
|
5
7
|
{{- $measure := (index (partialCached "motifspec/tokens.html" "tokens") "size.measure.prose").value | replaceRE `[^0-9]` "" | int -}}
|
|
6
8
|
{{- $long := false -}}
|
|
7
9
|
{{- range split .Inner "\n" }}{{ if gt (strings.RuneCount .) $measure }}{{ $long = true }}{{ end }}{{ end -}}
|
|
8
10
|
{{- $result := transform.HighlightCodeBlock . -}}
|
|
11
|
+
{{- $preview := and .Attributes.preview (eq $lang "html") -}}
|
|
12
|
+
{{- if $preview }}
|
|
13
|
+
{{- $css := resources.Get "motifspec/codex.css" | resources.Copy "cx/codex.css" | minify | fingerprint -}}
|
|
14
|
+
{{- $js := resources.Get "motifspec/codex.js" | resources.Copy "cx/codex.js" | minify | fingerprint -}}
|
|
15
|
+
{{- $init := (resources.Get "motifspec/theme-init.js").Content -}}
|
|
16
|
+
{{- $sprite := (resources.Get "motifspec/icons.svg").Content -}}
|
|
17
|
+
{{- $doc := printf `<!doctype html><html lang="%s"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><script>%s</script><link rel="stylesheet" href="%s"><script src="%s" defer></script></head><body class="cx-preview-body"><div hidden>%s</div>%s</body></html>` (site.Language.LanguageCode | default "en") $init $css.RelPermalink $js.RelPermalink $sprite .Inner }}
|
|
18
|
+
<div class="cx-preview">
|
|
19
|
+
<iframe class="cx-preview__frame" title="Example{{ with .Page }}: {{ .LinkTitle }}{{ end }}" loading="lazy" srcdoc="{{ $doc }}"></iframe>
|
|
20
|
+
{{- end }}
|
|
9
21
|
<figure class="cx-code{{ if $long }} cx-code--breakout{{ end }}">
|
|
10
|
-
<figcaption class="cx-code__bar">
|
|
22
|
+
<figcaption class="cx-code__bar" data-pagefind-ignore>
|
|
11
23
|
<span>{{ $lang }}</span>
|
|
12
24
|
{{- with .Attributes.file }}
|
|
13
25
|
<span class="cx-code__file">{{ . }}</span>
|
|
14
26
|
{{- end }}
|
|
15
27
|
<button class="cx-code__copy" type="button" hidden><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use data-copy-icon href="#cx-icon-content-copy"></use></svg><span class="cx-code__copy-label">Copy</span></button>
|
|
16
28
|
</figcaption>
|
|
17
|
-
{{ replaceRE ` file="[^"]*"` "" (string $result.Wrapped)
|
|
29
|
+
{{ replaceRE ` (?:file|preview)="[^"]*"` "" (string $result.Wrapped) 2 | safeHTML }}
|
|
18
30
|
</figure>
|
|
31
|
+
{{- if $preview }}
|
|
32
|
+
</div>
|
|
33
|
+
{{- end }}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
{{- /* heading-anchor.md: every heading gets an id; h2s get the "#" anchor after a space. */ -}}
|
|
2
|
-
<h{{ .Level }} id="{{ .Anchor }}">{{ .Text }}{{ if eq .Level 2 }} <a class="cx-anchor" href="#{{ .Anchor }}" aria-label="Link to {{ .PlainText }}">#</a>{{ end }}</h{{ .Level }}>
|
|
2
|
+
<h{{ .Level }} id="{{ .Anchor }}">{{ .Text }}{{ if eq .Level 2 }} <a class="cx-anchor" href="#{{ .Anchor }}" aria-label="Link to {{ .PlainText }}" data-pagefind-ignore>#</a>{{ end }}</h{{ .Level }}>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{{- /* ornament.md: the flower ("g") goes after the last sentence, so the content must end with a paragraph. */ -}}
|
|
9
9
|
{{- $content := $p.Content | strings.TrimSpace -}}
|
|
10
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 -}}
|
|
11
|
-
{{- $endMark := `<span class="cx-end-mark" aria-hidden="true">g</span></p>` -}}
|
|
11
|
+
{{- $endMark := `<span class="cx-end-mark" aria-hidden="true" data-pagefind-ignore>g</span></p>` -}}
|
|
12
12
|
{{- if strings.HasSuffix $content "</p>" -}}
|
|
13
13
|
{{- $content = printf "%s%s" (strings.TrimSuffix "</p>" $content) $endMark -}}
|
|
14
14
|
{{- else -}}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
{{- /* docs/hugo.md. Call first inside <body class="cx-backdrop-page"> with the page:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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" }}
|
|
6
|
+
{{ with resources.Get "motifspec/backdrop-side.html" }}{{ .Content | safeHTML }}{{ else }}{{ errorf "motifspec/backdrop-side.html is missing: is the MotifSpec module imported?" }}{{ end }}
|
|
7
|
+
{{- else if .IsHome }}
|
|
5
8
|
{{ with resources.Get "motifspec/backdrop.html" }}{{ .Content | safeHTML }}{{ else }}{{ errorf "motifspec/backdrop.html is missing: is the MotifSpec module imported?" }}{{ end }}
|
|
6
9
|
{{- end }}
|
|
7
10
|
<div hidden>{{ with resources.Get "motifspec/icons.svg" }}{{ .Content | safeHTML }}{{ end }}</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{{- /* docs-shell.md: the documentation layout's page navigation. Pages at the top level of the site come first,
|
|
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
|
|
4
|
+
current page is marked. Context: the current page. */ -}}
|
|
5
|
+
{{- $current := . -}}
|
|
6
|
+
{{- $top := where (where site.Home.RegularPages "Params.docs_nav" "ne" false) "Kind" "page" -}}
|
|
7
|
+
<nav class="cx-docs-nav" aria-label="Documentation">
|
|
8
|
+
<details class="cx-docs-nav__menu">
|
|
9
|
+
<summary>Menu<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-expand"></use></svg></summary>
|
|
10
|
+
<div class="cx-docs-nav__groups">
|
|
11
|
+
{{- with $top.ByWeight }}
|
|
12
|
+
<ul class="cx-docs-nav__list">
|
|
13
|
+
{{- range . }}
|
|
14
|
+
<li><a href="{{ .RelPermalink }}"{{ if eq .RelPermalink $current.RelPermalink }} aria-current="page"{{ end }}>{{ .LinkTitle }}</a></li>
|
|
15
|
+
{{- end }}
|
|
16
|
+
</ul>
|
|
17
|
+
{{- end }}
|
|
18
|
+
{{- range where site.Home.Sections.ByWeight "Params.docs_nav" "ne" false }}
|
|
19
|
+
{{- $id := printf "docs-nav-%s" (.Section | urlize) }}
|
|
20
|
+
<details class="cx-docs-nav__group" open>
|
|
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
|
+
<ul class="cx-docs-nav__list" aria-labelledby="{{ $id }}">
|
|
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>
|
|
25
|
+
{{- end }}
|
|
26
|
+
</ul>
|
|
27
|
+
</details>
|
|
28
|
+
{{- end }}
|
|
29
|
+
</div>
|
|
30
|
+
</details>
|
|
31
|
+
</nav>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{{- /* page-actions.md: Copy page and View as Markdown, for a page that has the markdown output format (docs/hugo.md).
|
|
2
|
+
Writes nothing for a page without it. Context: a page. */ -}}
|
|
3
|
+
{{- with .OutputFormats.Get "markdown" }}
|
|
4
|
+
<div class="cx-page-actions" data-pagefind-ignore>
|
|
5
|
+
<button class="cx-button cx-button--sm" type="button" data-copy-page="{{ .RelPermalink }}" hidden><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-content-copy"></use></svg><span class="cx-page-actions__label">Copy page</span></button>
|
|
6
|
+
<a class="cx-button cx-button--sm" href="{{ .RelPermalink }}" type="text/markdown">View as Markdown</a>
|
|
7
|
+
</div>
|
|
8
|
+
{{- end -}}
|