@aitrien/motifspec 1.25.1 → 1.27.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 +31 -0
- package/dist/codex.css +232 -4
- package/dist/codex.js +301 -3
- package/dist/contrast.md +9 -1
- package/dist/icons.svg +1 -0
- package/dist/tokens.css +9 -3
- package/dist/tokens.js +103 -5
- package/dist/tokens.json +103 -5
- package/docs/components/_groups.json +2 -0
- package/docs/components/alert.md +134 -0
- package/docs/components/breadcrumb.md +76 -0
- package/docs/components/button-and-link.md +19 -1
- package/docs/components/callout.md +2 -1
- package/docs/components/choice.md +104 -0
- package/docs/components/date-picker.md +108 -0
- package/docs/components/dialog.md +148 -0
- package/docs/components/docs-shell.md +7 -1
- package/docs/components/field.md +181 -0
- package/docs/components/icon.md +3 -0
- package/docs/components/status.md +1 -1
- package/docs/components/toast.md +101 -0
- package/docs/hugo.md +4 -1
- package/docs/layouts/dashboard.md +5 -5
- package/docs/layouts/documentation.md +1 -1
- package/icons/manifest.json +8 -4
- package/icons/svg/calendar_today.svg +1 -0
- package/layouts/_partials/motifspec/alert.html +21 -0
- package/layouts/_partials/motifspec/breadcrumb.html +12 -0
- package/layouts/_partials/motifspec/field.html +53 -0
- package/package.json +1 -1
- package/scripts/lib.mjs +7 -0
- package/tokens/color.json +76 -2
- package/tokens/motion.json +15 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: date-picker
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
group: forms
|
|
6
|
+
tokens:
|
|
7
|
+
- border.focus.width
|
|
8
|
+
- border.width.hairline
|
|
9
|
+
- color.accent.border
|
|
10
|
+
- color.border.strong
|
|
11
|
+
- color.border.subtle
|
|
12
|
+
- color.focus.ring
|
|
13
|
+
- color.surface.hover
|
|
14
|
+
- color.surface.raised
|
|
15
|
+
- color.surface.selected
|
|
16
|
+
- color.text.accent
|
|
17
|
+
- color.text.muted
|
|
18
|
+
- color.text.primary
|
|
19
|
+
- color.text.secondary
|
|
20
|
+
- font.family.mono
|
|
21
|
+
- font.size.label
|
|
22
|
+
- font.size.small
|
|
23
|
+
- font.tracking.label
|
|
24
|
+
- font.weight.strong
|
|
25
|
+
- font.weight.ui
|
|
26
|
+
- motion.duration.fast
|
|
27
|
+
- motion.easing.standard
|
|
28
|
+
- radius.pill
|
|
29
|
+
- size.target.control
|
|
30
|
+
- size.target.touch
|
|
31
|
+
- space.inline.sm
|
|
32
|
+
- space.inline.xs
|
|
33
|
+
- space.inset.sm
|
|
34
|
+
- space.inset.xs
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# Date picker
|
|
38
|
+
|
|
39
|
+
A date field with a button that opens a calendar, where the month and the year can each be picked from a grid.
|
|
40
|
+
|
|
41
|
+
## When to use
|
|
42
|
+
|
|
43
|
+
- When the date matters in relation to the days around it, such as a weekday for maintenance.
|
|
44
|
+
- When the reader may need to go a long way back, as for a date of birth: the year grid goes twenty years at a time.
|
|
45
|
+
- Where the calendar should look like the rest of the page.
|
|
46
|
+
|
|
47
|
+
## When not to use
|
|
48
|
+
|
|
49
|
+
- When the browser's own date field is enough: `<input type="date">` in a field (`field.md`) gives the reader's own calendar, in their language and date order, and the system's date wheel on a phone. It's the better choice in most forms.
|
|
50
|
+
- For a range of dates, or to grey out dates that can't be chosen; this calendar doesn't do either yet.
|
|
51
|
+
- For a time of day.
|
|
52
|
+
|
|
53
|
+
## Markup
|
|
54
|
+
|
|
55
|
+
```html {preview=true}
|
|
56
|
+
<div class="cx-field">
|
|
57
|
+
<div class="cx-field__box cx-field__box--date" data-date-picker>
|
|
58
|
+
<input class="cx-field__control cx-field__control--mono" id="maintenance-date" placeholder="DD/MM/YYYY" inputmode="numeric" autocomplete="off" value="12/12/2026" aria-describedby="maintenance-date-hint">
|
|
59
|
+
<label class="cx-field__label" for="maintenance-date">Maintenance date</label>
|
|
60
|
+
<button class="cx-date__button" type="button" aria-label="Choose a maintenance date" aria-haspopup="dialog" hidden><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-calendar"></use></svg></button>
|
|
61
|
+
</div>
|
|
62
|
+
<p class="cx-field__hint" id="maintenance-date-hint">Day, month and year, like 12/12/2026.</p>
|
|
63
|
+
</div>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The browser's own date field is a field with `type="date"`:
|
|
67
|
+
|
|
68
|
+
```html {preview=true}
|
|
69
|
+
<div class="cx-field">
|
|
70
|
+
<div class="cx-field__box">
|
|
71
|
+
<input class="cx-field__control cx-field__control--mono" id="backup-date" type="date" value="2026-12-12">
|
|
72
|
+
<label class="cx-field__label" for="backup-date">Backup date</label>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Do
|
|
78
|
+
|
|
79
|
+
- Keep the text field: typing a date is often quicker than finding it.
|
|
80
|
+
- Say the format in the hint ("Day, month and year, like 12/12/2026"). The calendar reads and writes day first.
|
|
81
|
+
- Name the button for what it chooses ("Choose a date of birth").
|
|
82
|
+
|
|
83
|
+
## Don't
|
|
84
|
+
|
|
85
|
+
- Don't make the field read-only so that the calendar is the only way in.
|
|
86
|
+
- Don't put two date pickers next to each other for a range. Use two fields with hints until a range picker exists.
|
|
87
|
+
|
|
88
|
+
## Accessibility
|
|
89
|
+
|
|
90
|
+
- The button is `hidden` until `codex.js` shows it, so without script the field still takes a typed date.
|
|
91
|
+
- The calendar is a non-modal dialog named by its button. Focus moves to the chosen date (or today) when it opens, and back to the button when it closes.
|
|
92
|
+
- The days, months and years are each a grid of buttons with one tab stop. Each day is named in full ("Saturday 12 December 2026"), today has `aria-current="date"`, the chosen date `aria-pressed="true"`, and the shown month is read out when it changes.
|
|
93
|
+
- Days are `size.target.touch` square, and the calendar is a fixed size, so its arrows never move under the pointer.
|
|
94
|
+
- Pairs: `color.text.primary` on `color.surface.selected` (the chosen date) and on `color.surface.raised`; `color.border.strong` outlines today.
|
|
95
|
+
|
|
96
|
+
## Behaviour
|
|
97
|
+
|
|
98
|
+
`dist/codex.js` does this; an app that renders the date picker itself does the same.
|
|
99
|
+
|
|
100
|
+
- **Opening:** the button opens one calendar for the page (a `popover`), on the field's date if it can read one, or today. Pressing it again closes it.
|
|
101
|
+
- **Placing:** under the field, or above it when there's more room there; left-aligned with it, kept inside the window, and in page coordinates, so it scrolls with the field.
|
|
102
|
+
- **Days:** the arrow keys move a day or a week, Page Up and Page Down a month, Home and End to the ends of the week (Monday to Sunday). Enter, Space or a click chooses the date, writes it as DD/MM/YYYY, fires `input` and `change` on the field, and closes the calendar.
|
|
103
|
+
- **Months and years:** the month and year at the top open a grid of the year's months, or of twenty years. The arrows at the sides then step a year, or twenty years. Choosing a year opens its months; choosing a month opens its days.
|
|
104
|
+
- **Closing:** Escape, a click outside, Close, or choosing a date. Today moves back to today.
|
|
105
|
+
|
|
106
|
+
## Specimens
|
|
107
|
+
|
|
108
|
+
None: the calendar opens from the field, so its page shows it working.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dialog
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
group: messages
|
|
6
|
+
tokens:
|
|
7
|
+
- border.focus.width
|
|
8
|
+
- border.width.hairline
|
|
9
|
+
- color.border.strong
|
|
10
|
+
- color.border.subtle
|
|
11
|
+
- color.focus.ring
|
|
12
|
+
- color.scrim
|
|
13
|
+
- color.surface.hover
|
|
14
|
+
- color.surface.raised
|
|
15
|
+
- color.surface.sunken
|
|
16
|
+
- color.text.primary
|
|
17
|
+
- color.text.secondary
|
|
18
|
+
- color.wash.scrim
|
|
19
|
+
- font.line-height.heading
|
|
20
|
+
- font.size.heading-4
|
|
21
|
+
- font.weight.heading
|
|
22
|
+
- motion.distance.nudge
|
|
23
|
+
- motion.duration.base
|
|
24
|
+
- motion.easing.enter
|
|
25
|
+
- motion.easing.exit
|
|
26
|
+
- radius.pill
|
|
27
|
+
- size.column.card
|
|
28
|
+
- size.measure.caption
|
|
29
|
+
- size.measure.prose
|
|
30
|
+
- size.target.control
|
|
31
|
+
- space.gutter.page
|
|
32
|
+
- space.inline.sm
|
|
33
|
+
- space.inset.lg
|
|
34
|
+
- space.inset.md
|
|
35
|
+
- space.inset.sm
|
|
36
|
+
- space.stack.md
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
# Dialog
|
|
40
|
+
|
|
41
|
+
A box over the page that asks the reader to confirm something, or to fill in a short form, before they go on.
|
|
42
|
+
|
|
43
|
+
## When to use
|
|
44
|
+
|
|
45
|
+
- To confirm an action that deletes or stops something, with a danger button (`button-and-link.md`).
|
|
46
|
+
- For a short form that belongs to the page behind it, such as adding an item to a list.
|
|
47
|
+
|
|
48
|
+
## When not to use
|
|
49
|
+
|
|
50
|
+
- For a message; use an alert (`alert.md`) or a toast (`toast.md`).
|
|
51
|
+
- For a long form or one with steps; give it a page.
|
|
52
|
+
- For something the reader didn't ask for, such as a sign-up when the page loads.
|
|
53
|
+
|
|
54
|
+
## Markup
|
|
55
|
+
|
|
56
|
+
```html {preview=true}
|
|
57
|
+
<button class="cx-button" type="button" data-dialog-open="remove-sonarr">Remove service</button>
|
|
58
|
+
<dialog class="cx-dialog" id="remove-sonarr" aria-labelledby="remove-sonarr-title" aria-describedby="remove-sonarr-text">
|
|
59
|
+
<div class="cx-dialog__head">
|
|
60
|
+
<h2 class="cx-dialog__title" id="remove-sonarr-title">Remove Sonarr?</h2>
|
|
61
|
+
<button class="cx-dialog__close" type="button" aria-label="Close" data-dialog-close><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="cx-dialog__body">
|
|
64
|
+
<p id="remove-sonarr-text">Sonarr stops and its container is deleted from tern. Its settings stay in <code>/srv/sonarr</code>, so you can add it again later.</p>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="cx-dialog__actions">
|
|
67
|
+
<button class="cx-button" type="button" data-dialog-close autofocus>Cancel</button>
|
|
68
|
+
<button class="cx-button cx-button--danger" type="button">Remove service</button>
|
|
69
|
+
</div>
|
|
70
|
+
</dialog>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
For a form, add `cx-dialog--wide` and `data-dialog-keep`, and put the parts in a `form` (fields from `field.md`):
|
|
74
|
+
|
|
75
|
+
```html {preview=true}
|
|
76
|
+
<button class="cx-button" type="button" data-dialog-open="add-node">Add a node</button>
|
|
77
|
+
<dialog class="cx-dialog cx-dialog--wide" id="add-node" aria-labelledby="add-node-title" data-dialog-keep>
|
|
78
|
+
<form method="dialog">
|
|
79
|
+
<div class="cx-dialog__head">
|
|
80
|
+
<h2 class="cx-dialog__title" id="add-node-title">Add a node</h2>
|
|
81
|
+
<button class="cx-dialog__close" type="button" aria-label="Close" data-dialog-close><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="cx-dialog__body">
|
|
84
|
+
<div class="cx-field">
|
|
85
|
+
<div class="cx-field__box"><input class="cx-field__control" id="add-node-name" placeholder="e.g. tui" required autocomplete="off" autofocus><label class="cx-field__label" for="add-node-name">Name</label></div>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="cx-field">
|
|
88
|
+
<div class="cx-field__box"><input class="cx-field__control cx-field__control--mono" id="add-node-address" placeholder="e.g. 192.168.1.40" inputmode="decimal" autocomplete="off" aria-describedby="add-node-address-hint"><label class="cx-field__label" for="add-node-address">Address</label></div>
|
|
89
|
+
<p class="cx-field__hint" id="add-node-address-hint">Its IP address or host name on your network.</p>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
<div class="cx-dialog__actions">
|
|
93
|
+
<button class="cx-button" type="button" data-dialog-close>Cancel</button>
|
|
94
|
+
<button class="cx-button cx-button--primary" type="submit">Add node</button>
|
|
95
|
+
</div>
|
|
96
|
+
</form>
|
|
97
|
+
</dialog>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
<!-- caption: Dialog parts -->
|
|
101
|
+
| Class | What it is |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `cx-dialog` | A `<dialog>`, opened with `showModal()`; `--wide` for a form |
|
|
104
|
+
| `cx-dialog__head` | The title and the close button, over a rule |
|
|
105
|
+
| `cx-dialog__title` | An `h2` that names the dialog, linked with `aria-labelledby` |
|
|
106
|
+
| `cx-dialog__close` | The close button, top right, named "Close" |
|
|
107
|
+
| `cx-dialog__body` | The question or the form; it scrolls when it's taller than the window |
|
|
108
|
+
| `cx-dialog__actions` | The buttons, in a recessed band: Cancel first, the main action last |
|
|
109
|
+
|
|
110
|
+
## Do
|
|
111
|
+
|
|
112
|
+
- Ask a question in the title, and say in the body what will happen ("Sonarr stops and its container is deleted").
|
|
113
|
+
- Name the main button for what it does ("Remove service"), never "OK" or "Yes".
|
|
114
|
+
- Start focus on Cancel when the action deletes or stops something (`autofocus`), and on the first field in a form.
|
|
115
|
+
- For something that can't be undone, ask the reader to type its name to turn the button on.
|
|
116
|
+
|
|
117
|
+
## Don't
|
|
118
|
+
|
|
119
|
+
- Don't open a dialog from a dialog.
|
|
120
|
+
- Don't let a click outside close a form; that's what `data-dialog-keep` is for.
|
|
121
|
+
- Don't put a danger button anywhere but a dialog's actions.
|
|
122
|
+
|
|
123
|
+
## Accessibility
|
|
124
|
+
|
|
125
|
+
- `showModal()` makes the rest of the page inert, moves focus into the dialog, closes it on Escape, and returns focus to the button that opened it.
|
|
126
|
+
- The title names the dialog (`aria-labelledby`), and a confirmation's text describes it (`aria-describedby`), so both are read when it opens.
|
|
127
|
+
- The page behind it doesn't scroll, and recedes behind `color.scrim` at `color.wash.scrim`.
|
|
128
|
+
- It fades and rises in by `motion.distance.nudge`, at `motion.duration.base`; under `prefers-reduced-motion` it appears at once.
|
|
129
|
+
- On a phone (below `size.breakpoint.md`), a confirmation docks to the bottom with full-width buttons, Cancel below, and a form fills the screen.
|
|
130
|
+
- Pairs: `color.text.primary` and `color.text.secondary` on `color.surface.raised`; the actions on `color.surface.sunken`.
|
|
131
|
+
|
|
132
|
+
## Behaviour
|
|
133
|
+
|
|
134
|
+
`dist/codex.js` does this; an app that renders dialogs itself does the same, or calls `showModal()` and `close()` itself.
|
|
135
|
+
|
|
136
|
+
- **Opening:** a click on `[data-dialog-open="id"]` calls `showModal()` on the dialog with that id.
|
|
137
|
+
- **Closing:** `[data-dialog-close]` inside the dialog closes it, as does Escape. A click on the backdrop closes it too, unless the dialog has `data-dialog-keep`.
|
|
138
|
+
- **Forms:** with `<form method="dialog">`, sending the form closes the dialog once the fields are valid; the page reads the values on the dialog's `close` event.
|
|
139
|
+
|
|
140
|
+
## Specimens
|
|
141
|
+
|
|
142
|
+
```html {specimen="Confirm" wide=true}
|
|
143
|
+
<div class="cx-dialog">
|
|
144
|
+
<div class="cx-dialog__head"><h2 class="cx-dialog__title">Remove Sonarr?</h2><button class="cx-dialog__close" type="button" aria-label="Close"><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button></div>
|
|
145
|
+
<div class="cx-dialog__body"><p>Sonarr stops and its container is deleted from tern. Its settings stay in <code>/srv/sonarr</code>.</p></div>
|
|
146
|
+
<div class="cx-dialog__actions"><button class="cx-button" type="button">Cancel</button><button class="cx-button cx-button--danger" type="button">Remove service</button></div>
|
|
147
|
+
</div>
|
|
148
|
+
```
|
|
@@ -50,7 +50,7 @@ The frame of a documentation page: grouped page navigation on the left, the page
|
|
|
50
50
|
|
|
51
51
|
## Markup
|
|
52
52
|
|
|
53
|
-
The site header (`site-header.md`) and footer (`site-footer.md`) go around it as on any page. The main column holds the page head and a `cx-article`, whose table of contents (`table-of-contents.md`) is "On this page".
|
|
53
|
+
The site header (`site-header.md`) and footer (`site-footer.md`) go around it as on any page. The main column holds the page head, which starts with the breadcrumb (`breadcrumb.md`), and a `cx-article`, whose table of contents (`table-of-contents.md`) is "On this page".
|
|
54
54
|
|
|
55
55
|
```html {preview=true}
|
|
56
56
|
<div class="cx-container cx-docs">
|
|
@@ -77,6 +77,12 @@ The site header (`site-header.md`) and footer (`site-footer.md`) go around it as
|
|
|
77
77
|
</nav>
|
|
78
78
|
<main id="main" class="cx-docs__main" tabindex="-1" data-pagefind-body>
|
|
79
79
|
<div class="cx-page-head">
|
|
80
|
+
<nav class="cx-breadcrumb" aria-label="Breadcrumb" data-pagefind-ignore>
|
|
81
|
+
<ol class="cx-breadcrumb__list">
|
|
82
|
+
<li><a href="/">MotifSpec</a></li>
|
|
83
|
+
<li><a href="/guide/">Guide</a></li>
|
|
84
|
+
</ol>
|
|
85
|
+
</nav>
|
|
80
86
|
<h1>Getting started</h1>
|
|
81
87
|
<p class="cx-lede">Install the module, import it, and check your site.</p>
|
|
82
88
|
</div>
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: field
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
group: forms
|
|
6
|
+
tokens:
|
|
7
|
+
- border.width.hairline
|
|
8
|
+
- color.accent.border
|
|
9
|
+
- color.border.strong
|
|
10
|
+
- color.status.danger.border
|
|
11
|
+
- color.status.danger.text
|
|
12
|
+
- color.surface.raised
|
|
13
|
+
- color.surface.sunken
|
|
14
|
+
- color.text.accent
|
|
15
|
+
- color.text.muted
|
|
16
|
+
- color.text.primary
|
|
17
|
+
- color.text.secondary
|
|
18
|
+
- font.family.mono
|
|
19
|
+
- font.line-height.ui
|
|
20
|
+
- font.size.body
|
|
21
|
+
- font.size.label
|
|
22
|
+
- font.size.small
|
|
23
|
+
- font.weight.strong
|
|
24
|
+
- motion.duration.base
|
|
25
|
+
- motion.easing.standard
|
|
26
|
+
- radius.control
|
|
27
|
+
- size.column.sidebar
|
|
28
|
+
- size.icon.md
|
|
29
|
+
- size.target.control
|
|
30
|
+
- space.inline.xs
|
|
31
|
+
- space.inset.sm
|
|
32
|
+
- space.inset.xs
|
|
33
|
+
- space.stack.md
|
|
34
|
+
- space.stack.sm
|
|
35
|
+
- space.stack.xs
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
# Field
|
|
39
|
+
|
|
40
|
+
A text field, select or text area, with its label on the top border: it rests where the text goes, and moves up to the border when the field has focus or a value.
|
|
41
|
+
|
|
42
|
+
## When to use
|
|
43
|
+
|
|
44
|
+
- For anything the reader types or picks from a list: a name, an address, a port, a setting.
|
|
45
|
+
- With a hint under the field when the reader needs to know the format or where to find the value.
|
|
46
|
+
|
|
47
|
+
## When not to use
|
|
48
|
+
|
|
49
|
+
- For a yes or no, or a choice of two to five options the reader should see at once; use a checkbox, radio buttons or a switch (`choice.md`).
|
|
50
|
+
- For a date; use the date picker (`date-picker.md`), which is a field with a calendar.
|
|
51
|
+
- For search; use search (`search.md`).
|
|
52
|
+
|
|
53
|
+
## Markup
|
|
54
|
+
|
|
55
|
+
```html {preview=true}
|
|
56
|
+
<div class="cx-field">
|
|
57
|
+
<div class="cx-field__box">
|
|
58
|
+
<input class="cx-field__control" id="service-name" placeholder="e.g. Sonarr" autocomplete="off">
|
|
59
|
+
<label class="cx-field__label" for="service-name">Name</label>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
<div class="cx-field">
|
|
63
|
+
<div class="cx-field__box">
|
|
64
|
+
<input class="cx-field__control cx-field__control--mono" id="service-image" placeholder=" " value="lscr.io/linuxserver/sonarr:4.0.11" aria-describedby="service-image-hint">
|
|
65
|
+
<label class="cx-field__label" for="service-image">Image</label>
|
|
66
|
+
</div>
|
|
67
|
+
<p class="cx-field__hint" id="service-image-hint">The registry, name and tag, as you would pull it.</p>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="cx-field">
|
|
70
|
+
<div class="cx-field__box">
|
|
71
|
+
<input class="cx-field__control cx-field__control--mono cx-field__control--short" id="service-port" placeholder=" " inputmode="numeric" value="8096" aria-invalid="true" aria-describedby="service-port-error">
|
|
72
|
+
<label class="cx-field__label" for="service-port">Port</label>
|
|
73
|
+
</div>
|
|
74
|
+
<p class="cx-field__error" id="service-port-error"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-danger"></use></svg>Port 8096 is already used by Jellyfin.</p>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="cx-field">
|
|
77
|
+
<div class="cx-field__box">
|
|
78
|
+
<select class="cx-field__control" id="service-node"><option>tern</option><option>kea</option><option>ruru</option></select>
|
|
79
|
+
<label class="cx-field__label" for="service-node">Node</label>
|
|
80
|
+
<svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-expand"></use></svg>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="cx-field">
|
|
84
|
+
<div class="cx-field__box cx-field__box--area">
|
|
85
|
+
<textarea class="cx-field__control" id="service-notes" placeholder=" "></textarea>
|
|
86
|
+
<label class="cx-field__label" for="service-notes">Notes <span class="cx-field__optional">(optional)</span></label>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The label comes straight after the control, and the control has a `placeholder`: an example the reader sees once they're in the field ("e.g. Sonarr"), or a single space when there's none. The label uses it to tell an empty field from a filled one, with no script.
|
|
92
|
+
|
|
93
|
+
<!-- caption: Field parts -->
|
|
94
|
+
| Class | What it is |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `cx-field` | The field: the box, then any hint or error |
|
|
97
|
+
| `cx-field__box` | The control and its label; `--area` for a text area, whose label rests at the top |
|
|
98
|
+
| `cx-field__control` | The `input`, `select` or `textarea`; `--mono` for values like paths and ports, `--short` for a value a few characters long |
|
|
99
|
+
| `cx-field__label` | The label, on the border once the field has focus or a value |
|
|
100
|
+
| `cx-field__optional` | "(optional)" after the label |
|
|
101
|
+
| `cx-field__hint` | Help under the field, linked with `aria-describedby` |
|
|
102
|
+
| `cx-field__error` | What's wrong and how to fix it, with the `danger` icon, linked the same way |
|
|
103
|
+
| `cx-fieldset` | A `fieldset` of related fields or choices, with its `legend` as the group's name |
|
|
104
|
+
|
|
105
|
+
Group related fields in a fieldset:
|
|
106
|
+
|
|
107
|
+
```html {preview=true}
|
|
108
|
+
<fieldset class="cx-fieldset">
|
|
109
|
+
<legend>Where it runs</legend>
|
|
110
|
+
<div class="cx-field">
|
|
111
|
+
<div class="cx-field__box">
|
|
112
|
+
<input class="cx-field__control cx-field__control--mono" id="where-address" placeholder="e.g. 192.168.1.40" inputmode="decimal" autocomplete="off">
|
|
113
|
+
<label class="cx-field__label" for="where-address">Address</label>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</fieldset>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
In Hugo, `motifspec/field.html` writes one (`docs/hugo.md`).
|
|
120
|
+
|
|
121
|
+
## Do
|
|
122
|
+
|
|
123
|
+
- Write the label as the thing it asks for, in a word or two ("Name", "Port"). It's 0.75rem once it moves, and a long one is cut off.
|
|
124
|
+
- Mark the optional fields with "(optional)", not the required ones: most fields are required.
|
|
125
|
+
- Put the format in a hint when it matters ("Day, month and year"), since the label covers the placeholder until the reader is in the field.
|
|
126
|
+
- Say in the error what went wrong and how to fix it, and show it only once the reader has left the field or sent the form.
|
|
127
|
+
- Use `--mono` for values that are code: paths, ports, image names, addresses.
|
|
128
|
+
|
|
129
|
+
## Don't
|
|
130
|
+
|
|
131
|
+
- Don't leave out the label, or put the only label in the placeholder.
|
|
132
|
+
- Don't put a hint or error between the label and the box; they go underneath.
|
|
133
|
+
- Don't disable a field without saying why in its hint.
|
|
134
|
+
- Don't round the box. Fields stay square (`radius.control`); pills are for what you press (`button-and-link.md`).
|
|
135
|
+
|
|
136
|
+
## Accessibility
|
|
137
|
+
|
|
138
|
+
- The label is a real `<label for>`, always visible, so a screen reader reads it and a click on it focuses the field.
|
|
139
|
+
- Hints and errors are linked with `aria-describedby`, and a field with an error has `aria-invalid="true"`, so both are read with the field.
|
|
140
|
+
- Focus doubles the field's border in `color.accent.border`. The inner line changes from the field's surface to accent (4.7:1 in light, 5.8:1 in dark), so the change shows without colour vision too.
|
|
141
|
+
- The field is `size.target.control` plus `space.inset.xs` above and below.
|
|
142
|
+
- The label moves with no animation under `prefers-reduced-motion`.
|
|
143
|
+
- Pairs: `color.text.primary` and `color.text.secondary` on `color.surface.raised`; `color.border.strong` against it (3:1); `color.status.danger.text` for errors.
|
|
144
|
+
|
|
145
|
+
## Specimens
|
|
146
|
+
|
|
147
|
+
```html {specimen="Empty, filled"}
|
|
148
|
+
<div class="cx-field">
|
|
149
|
+
<div class="cx-field__box"><input class="cx-field__control" id="sp-field-a" placeholder=" "><label class="cx-field__label" for="sp-field-a">Name</label></div>
|
|
150
|
+
</div>
|
|
151
|
+
<div class="cx-field">
|
|
152
|
+
<div class="cx-field__box"><input class="cx-field__control" id="sp-field-b" placeholder=" " value="Sonarr"><label class="cx-field__label" for="sp-field-b">Name</label></div>
|
|
153
|
+
</div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```html {specimen="Hint, error"}
|
|
157
|
+
<div class="cx-field">
|
|
158
|
+
<div class="cx-field__box"><input class="cx-field__control cx-field__control--mono" id="sp-field-c" placeholder=" " value="lscr.io/linuxserver/sonarr" aria-describedby="sp-field-c-hint"><label class="cx-field__label" for="sp-field-c">Image</label></div>
|
|
159
|
+
<p class="cx-field__hint" id="sp-field-c-hint">The registry, name and tag.</p>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="cx-field">
|
|
162
|
+
<div class="cx-field__box"><input class="cx-field__control cx-field__control--mono" id="sp-field-d" placeholder=" " value="99999" aria-invalid="true" aria-describedby="sp-field-d-error"><label class="cx-field__label" for="sp-field-d">Port</label></div>
|
|
163
|
+
<p class="cx-field__error" id="sp-field-d-error"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-danger"></use></svg>Enter a port from 1 to 65535.</p>
|
|
164
|
+
</div>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```html {specimen="Select, text area"}
|
|
168
|
+
<div class="cx-field">
|
|
169
|
+
<div class="cx-field__box"><select class="cx-field__control" id="sp-field-e"><option>Unless stopped</option></select><label class="cx-field__label" for="sp-field-e">Restart policy</label><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-expand"></use></svg></div>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="cx-field">
|
|
172
|
+
<div class="cx-field__box cx-field__box--area"><textarea class="cx-field__control" id="sp-field-f" placeholder=" "></textarea><label class="cx-field__label" for="sp-field-f">Notes <span class="cx-field__optional">(optional)</span></label></div>
|
|
173
|
+
</div>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```html {specimen="Disabled"}
|
|
177
|
+
<div class="cx-field">
|
|
178
|
+
<div class="cx-field__box"><input class="cx-field__control cx-field__control--mono" id="sp-field-g" placeholder=" " value="/srv/sonarr" disabled aria-describedby="sp-field-g-hint"><label class="cx-field__label" for="sp-field-g">Volume</label></div>
|
|
179
|
+
<p class="cx-field__hint" id="sp-field-g-hint">Stop the service to change it.</p>
|
|
180
|
+
</div>
|
|
181
|
+
```
|
package/docs/components/icon.md
CHANGED
|
@@ -8,13 +8,16 @@ tokens:
|
|
|
8
8
|
- color.border.strong
|
|
9
9
|
- color.surface.hover
|
|
10
10
|
- color.text.muted
|
|
11
|
+
- color.text.secondary
|
|
11
12
|
- motion.duration.base
|
|
13
|
+
- motion.duration.fast
|
|
12
14
|
- motion.easing.standard
|
|
13
15
|
- radius.pill
|
|
14
16
|
- size.icon.lg
|
|
15
17
|
- size.icon.md
|
|
16
18
|
- size.icon.sm
|
|
17
19
|
- space.inline.xs
|
|
20
|
+
- space.inset.sm
|
|
18
21
|
- space.inset.xs
|
|
19
22
|
---
|
|
20
23
|
|
|
@@ -33,7 +33,7 @@ A short mono label with a dot that names a state: online, degraded, down, live,
|
|
|
33
33
|
|
|
34
34
|
- For a topic or technology; that is a tag (`tag.md`).
|
|
35
35
|
- For a message the reader must read in full; that is a callout (`callout.md`).
|
|
36
|
-
- As the only sign of a problem on a page. A problem that needs action also gets
|
|
36
|
+
- As the only sign of a problem on a page. A problem that needs action also gets an alert (`alert.md`).
|
|
37
37
|
|
|
38
38
|
## Markup
|
|
39
39
|
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: toast
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
group: messages
|
|
6
|
+
tokens:
|
|
7
|
+
- border.focus.width
|
|
8
|
+
- color.surface.inverse
|
|
9
|
+
- color.text.inverse
|
|
10
|
+
- font.line-height.ui
|
|
11
|
+
- font.size.small
|
|
12
|
+
- motion.distance.nudge
|
|
13
|
+
- motion.duration.base
|
|
14
|
+
- motion.easing.enter
|
|
15
|
+
- motion.easing.exit
|
|
16
|
+
- radius.control
|
|
17
|
+
- size.column.card
|
|
18
|
+
- size.target.min
|
|
19
|
+
- space.gutter.page
|
|
20
|
+
- space.inline.sm
|
|
21
|
+
- space.inset.md
|
|
22
|
+
- space.inset.sm
|
|
23
|
+
- space.inset.xs
|
|
24
|
+
- space.stack.sm
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Toast
|
|
28
|
+
|
|
29
|
+
A short confirmation that something the reader just did has worked, shown at the bottom of the screen for a few seconds.
|
|
30
|
+
|
|
31
|
+
## When to use
|
|
32
|
+
|
|
33
|
+
- After an action whose result isn't otherwise visible where the reader is: settings saved, a link copied, an item moved to another list.
|
|
34
|
+
- When the message needs nothing from the reader, and missing it costs nothing.
|
|
35
|
+
|
|
36
|
+
## When not to use
|
|
37
|
+
|
|
38
|
+
- For an error, or anything the reader has to act on; that's an alert (`alert.md`), which stays until it's dealt with.
|
|
39
|
+
- When the control can say it itself, as a copy button does by changing to "Copied" (`code-block.md`, `page-actions.md`).
|
|
40
|
+
- For a message the reader didn't cause, such as a new reading arriving; show it where it happened.
|
|
41
|
+
|
|
42
|
+
## Markup
|
|
43
|
+
|
|
44
|
+
`dist/codex.js` makes the toasts. A page sends one with an event:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
document.dispatchEvent(new CustomEvent('cx-toast', { detail: { text: 'Settings saved', kind: 'success' } }));
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`text` is required, and is set as text, not HTML. `kind: 'success'` adds the check icon; leave it out for a plain message. The script keeps one region per page for them, `<div class="cx-toasts" role="status">` at the end of `<body>`, and makes it if the page has none. Each toast it adds:
|
|
51
|
+
|
|
52
|
+
```html {preview=true}
|
|
53
|
+
<div class="cx-toast">
|
|
54
|
+
<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-check"></use></svg>
|
|
55
|
+
<p class="cx-toast__text">Settings saved</p>
|
|
56
|
+
<button class="cx-toast__dismiss" type="button" aria-label="Dismiss"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
57
|
+
</div>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Do
|
|
61
|
+
|
|
62
|
+
- Say what happened in a few words, in the past tense: "Settings saved", "Link copied".
|
|
63
|
+
- Send it as soon as the action has worked, not before.
|
|
64
|
+
- Keep one toast to one result. Three or more at once means the page should say it some other way.
|
|
65
|
+
|
|
66
|
+
## Don't
|
|
67
|
+
|
|
68
|
+
- Don't put a link or another control in it; the reader may not reach it before it goes. Anything they might need afterwards goes on the page.
|
|
69
|
+
- Don't send one when the page loads; nothing has happened yet.
|
|
70
|
+
- Don't make it the only record of something the reader needs to see again.
|
|
71
|
+
|
|
72
|
+
## Accessibility
|
|
73
|
+
|
|
74
|
+
- The region is a polite live region (`role="status"`), so a toast is read once, after what the screen reader is saying, and focus stays where it is.
|
|
75
|
+
- It stays for `motion.duration.toast`, and the time starts again while the pointer or focus is on it, so it can be read at any pace. Escape, inside it, or its button closes it.
|
|
76
|
+
- The dismiss button is named "Dismiss" and is at least `size.target.min`; its focus ring is `color.text.inverse`, which shows on the toast.
|
|
77
|
+
- It appears with a short fade and rise; under `prefers-reduced-motion` it appears at once.
|
|
78
|
+
- Pairs: `color.text.inverse` on `color.surface.inverse` (7:1).
|
|
79
|
+
|
|
80
|
+
## Behaviour
|
|
81
|
+
|
|
82
|
+
`dist/codex.js` does this; an app that renders toasts itself does the same.
|
|
83
|
+
|
|
84
|
+
- **Adding:** a `cx-toast` event on the document adds a `cx-toast` to the region, at the bottom of the stack, and shows it with `is-shown`.
|
|
85
|
+
- **Limit:** three at a time. A fourth closes the oldest.
|
|
86
|
+
- **Going:** each closes after `motion.duration.toast`, read from the token. The time stops while the pointer is over it or focus is in it, and starts again in full when both have left. Its button, or Escape with focus in it, closes it at once. If focus was in it, focus moves to `#main`.
|
|
87
|
+
- **Without script:** there are no toasts, so nothing a reader needs can depend on one.
|
|
88
|
+
|
|
89
|
+
## Specimens
|
|
90
|
+
|
|
91
|
+
```html {specimen="Plain, success"}
|
|
92
|
+
<div class="cx-toast">
|
|
93
|
+
<p class="cx-toast__text">Moved to Archived</p>
|
|
94
|
+
<button class="cx-toast__dismiss" type="button" aria-label="Dismiss"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="cx-toast">
|
|
97
|
+
<svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-check"></use></svg>
|
|
98
|
+
<p class="cx-toast__text">Settings saved</p>
|
|
99
|
+
<button class="cx-toast__dismiss" type="button" aria-label="Dismiss"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
100
|
+
</div>
|
|
101
|
+
```
|
package/docs/hugo.md
CHANGED
|
@@ -72,7 +72,7 @@ A site using the documentation layout (`docs/layouts/documentation.md`) puts the
|
|
|
72
72
|
|
|
73
73
|
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; below `size.breakpoint.lg` 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.
|
|
74
74
|
|
|
75
|
-
An article page's `main` block, in order: the page head with `page-actions.html` after the lede
|
|
75
|
+
An article page's `main` block, in order: the page head, with `breadcrumb.html` before the h1 and `page-actions.html` after the lede; any alerts (`alert.html`); `article.html`, `page-footer.html`, then `pagination-docs.html`.
|
|
76
76
|
|
|
77
77
|
### A Markdown copy of each page
|
|
78
78
|
|
|
@@ -142,6 +142,9 @@ Every partial below is called as `partial "motifspec/<name>.html" <context>`.
|
|
|
142
142
|
| `search.html` | `search.md` | A page. The search trigger and dialog; `site-header.html` calls it when `params.motifspec.search` is true. |
|
|
143
143
|
| `theme-toggle.html` | `site-header.md` | A page. The theme toggle; `site-header.html` writes it in the bar and, on a documentation site, in the menu. |
|
|
144
144
|
| `back-link.html` | `button-and-link.md` | `dict "href" "…" "label" "All work"`. |
|
|
145
|
+
| `alert.html` | `alert.md` | `dict "kind" "warning" "title" "…" "text" "…"`: kind `info` (the default), `success`, `warning` or `danger`; text in Markdown; optional `"dismiss" true`, or a key to keep it dismissed on later pages. |
|
|
146
|
+
| `breadcrumb.html` | `breadcrumb.md` | A page. The trail from the home page to its parent, in a documentation site's page head; nothing when its parent is the home page. |
|
|
147
|
+
| `field.html` | `field.md`, `date-picker.md` | `dict "id" "…" "label" "…"`, plus `"type"` (`text` by default, `select` with `"options"`, `textarea`, `date-picker`, or any input type), `"value"`, `"placeholder"` (an example), `"hint"`, `"error"`, `"optional"`, `"required"`, `"disabled"`, `"mono"`, `"short"`, `"inputmode"`, `"autocomplete"`, and for a date picker `"choose"`, its button's name. |
|
|
145
148
|
| `section-heading.html` | `heading-anchor.md` | `dict "id" "work" "title" "Selected work"`, inside a `<section id="work" aria-labelledby="work-title">`. |
|
|
146
149
|
| `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. |
|
|
147
150
|
| `h2s.html` | | A page. Its h2 headings with their h3 children; used by the article and the TOC. |
|
|
@@ -6,8 +6,8 @@ For tools and admin screens: an overview of systems, lists of things to act on,
|
|
|
6
6
|
|
|
7
7
|
In progress. The dashboard's own components arrive in later releases, so this file says what exists now and what doesn't.
|
|
8
8
|
|
|
9
|
-
- **Available now:** every shared component, including buttons
|
|
10
|
-
- **Not available yet:** the app shell, side navigation, panels, stat tiles, meters, sparklines and charts, resource cards, the facts list, the event feed
|
|
9
|
+
- **Available now:** every shared component, including buttons (with compact and danger buttons), fields, choices and the date picker, the dialog, alerts and toasts, callouts, data tables with state and action cells, status labels in five tones, tabs, disclosures, keyboard keys, code blocks, tags, tooltips, and icons for navigation and tools (`icon.md`).
|
|
10
|
+
- **Not available yet:** the app shell, side navigation, panels, stat tiles, meters, sparklines and charts, resource cards, the facts list, the event feed and the segmented control.
|
|
11
11
|
|
|
12
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.
|
|
13
13
|
|
|
@@ -20,10 +20,10 @@ Planned: a side navigation column (wordmark, grouped links, the theme toggle and
|
|
|
20
20
|
<!-- caption: Page templates -->
|
|
21
21
|
| Template | Order | Dominant | Secondary |
|
|
22
22
|
|---|---|---|---|
|
|
23
|
-
| **Overview** | Page head (title, when the readings were last updated, page-wide controls) → alerts
|
|
23
|
+
| **Overview** | Page head (title, when the readings were last updated, page-wide controls) → alerts (`alert.md`) → headline figures → the main column and a side column of sections | Alerts and headline figures | Detail sections |
|
|
24
24
|
| **List** | Page head → filters → a data table with row actions → pagination | The table | Filters |
|
|
25
25
|
| **Detail** | Page head with the item's status → its facts → its readings → related lists | Status and readings | Related lists |
|
|
26
|
-
| **Form** | Page head → grouped
|
|
26
|
+
| **Form** | Page head → fields grouped in fieldsets (`field.md`, `choice.md`) → actions at the end of the form; a destructive action asks in a dialog (`dialog.md`) | The fields | Help text |
|
|
27
27
|
| **Empty and error** | Page head → what's missing or what failed, and what to do next | The message | Links back |
|
|
28
28
|
|
|
29
29
|
## Components
|
|
@@ -44,7 +44,7 @@ Every shared component, plus the components whose doc lists `dashboard` under `l
|
|
|
44
44
|
|
|
45
45
|
MotifSpec doesn't fetch data; where an app gets its readings is the project's decision. How readings appear:
|
|
46
46
|
|
|
47
|
-
- Readings that update on a schedule aren't live regions, so a screen reader isn't interrupted on every update. New alerts and state changes are announced once, through one polite live region (`role="status"`) per page.
|
|
47
|
+
- Readings that update on a schedule aren't live regions, so a screen reader isn't interrupted on every update. New alerts and state changes are announced once, through one polite live region (`role="status"`) per page; an alert added after the page loads has it (`alert.md`).
|
|
48
48
|
- The page says when its readings were last updated, as a `<time>`. A source that has gone quiet says so ("No readings since 13:58"); old numbers are never shown as current.
|
|
49
49
|
- Values change in place, with no counting animation and nothing flashing.
|
|
50
50
|
- A section whose source fails says so and when it last worked; the rest of the page keeps working.
|