@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
package/dist/tokens.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.27.0",
|
|
3
3
|
"changelog": "https://github.com/Aitrien/motifspec/blob/main/CHANGELOG.md",
|
|
4
4
|
"showcase": "https://motifspec.com",
|
|
5
5
|
"tokens": [
|
|
@@ -571,7 +571,7 @@
|
|
|
571
571
|
"referencesDark": "primitive.color.ash.100",
|
|
572
572
|
"value": "#252a28",
|
|
573
573
|
"valueDark": "#eaf1ee",
|
|
574
|
-
"description": "Background of tooltips and other small transient labels that must stand out from every surface. Never for panels or cards."
|
|
574
|
+
"description": "Background of tooltips, toasts and other small transient labels that must stand out from every surface. Never for panels or cards."
|
|
575
575
|
},
|
|
576
576
|
{
|
|
577
577
|
"name": "color.surface.highlight",
|
|
@@ -584,6 +584,17 @@
|
|
|
584
584
|
"valueDark": "#01441f",
|
|
585
585
|
"description": "Text selection and <mark>. Never for large areas or decoration."
|
|
586
586
|
},
|
|
587
|
+
{
|
|
588
|
+
"name": "color.surface.selected",
|
|
589
|
+
"css": "--cx-color-surface-selected",
|
|
590
|
+
"tier": "semantic",
|
|
591
|
+
"type": "color",
|
|
592
|
+
"references": "primitive.color.sap.100",
|
|
593
|
+
"referencesDark": "primitive.color.sap.800",
|
|
594
|
+
"value": "#d8f9df",
|
|
595
|
+
"valueDark": "#01441f",
|
|
596
|
+
"description": "The chosen item among options the reader picks from: a calendar's date, month or year (date-picker.md). With color.text.primary. Never for large areas or decoration."
|
|
597
|
+
},
|
|
587
598
|
{
|
|
588
599
|
"name": "color.text.primary",
|
|
589
600
|
"css": "--cx-color-text-primary",
|
|
@@ -615,6 +626,10 @@
|
|
|
615
626
|
"token": "color.surface.highlight",
|
|
616
627
|
"min": 7
|
|
617
628
|
},
|
|
629
|
+
{
|
|
630
|
+
"token": "color.surface.selected",
|
|
631
|
+
"min": 7
|
|
632
|
+
},
|
|
618
633
|
{
|
|
619
634
|
"token": "color.status.success.surface",
|
|
620
635
|
"min": 7
|
|
@@ -721,7 +736,7 @@
|
|
|
721
736
|
"referencesDark": "primitive.color.ash.900",
|
|
722
737
|
"value": "#f4f8f6",
|
|
723
738
|
"valueDark": "#252a28",
|
|
724
|
-
"description": "Text on color.surface.inverse (tooltips). Only there.",
|
|
739
|
+
"description": "Text on color.surface.inverse (tooltips and toasts), and the focus ring inside a toast. Only there.",
|
|
725
740
|
"pairsWith": [
|
|
726
741
|
{
|
|
727
742
|
"token": "color.surface.inverse",
|
|
@@ -750,6 +765,27 @@
|
|
|
750
765
|
}
|
|
751
766
|
]
|
|
752
767
|
},
|
|
768
|
+
{
|
|
769
|
+
"name": "color.text.on-danger",
|
|
770
|
+
"css": "--cx-color-text-on-danger",
|
|
771
|
+
"tier": "semantic",
|
|
772
|
+
"type": "color",
|
|
773
|
+
"references": "primitive.color.ash.0",
|
|
774
|
+
"referencesDark": "primitive.color.ash.1000",
|
|
775
|
+
"value": "#fbfefd",
|
|
776
|
+
"valueDark": "#0e100f",
|
|
777
|
+
"description": "Text and icons on color.status.danger.fill and its hover, such as a danger button’s label. Only there.",
|
|
778
|
+
"pairsWith": [
|
|
779
|
+
{
|
|
780
|
+
"token": "color.status.danger.fill",
|
|
781
|
+
"min": 4.5
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
"token": "color.status.danger.fill-hover",
|
|
785
|
+
"min": 4.5
|
|
786
|
+
}
|
|
787
|
+
]
|
|
788
|
+
},
|
|
753
789
|
{
|
|
754
790
|
"name": "color.link.rest",
|
|
755
791
|
"css": "--cx-color-link-rest",
|
|
@@ -1137,6 +1173,52 @@
|
|
|
1137
1173
|
}
|
|
1138
1174
|
]
|
|
1139
1175
|
},
|
|
1176
|
+
{
|
|
1177
|
+
"name": "color.status.danger.fill",
|
|
1178
|
+
"css": "--cx-color-status-danger-fill",
|
|
1179
|
+
"tier": "semantic",
|
|
1180
|
+
"type": "color",
|
|
1181
|
+
"references": "primitive.color.madder.700",
|
|
1182
|
+
"referencesDark": "primitive.color.madder.300",
|
|
1183
|
+
"value": "#942f29",
|
|
1184
|
+
"valueDark": "#feb5ac",
|
|
1185
|
+
"description": "Fill of a button that deletes or stops something, in a dialog asking to confirm it (cx-button--danger, button-and-link.md). Its label says what it does; never the only sign.",
|
|
1186
|
+
"pairsWith": [
|
|
1187
|
+
{
|
|
1188
|
+
"token": "color.surface.base",
|
|
1189
|
+
"min": 3
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
"token": "color.surface.raised",
|
|
1193
|
+
"min": 3
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
"token": "color.surface.sunken",
|
|
1197
|
+
"min": 3
|
|
1198
|
+
}
|
|
1199
|
+
]
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
"name": "color.status.danger.fill-hover",
|
|
1203
|
+
"css": "--cx-color-status-danger-fill-hover",
|
|
1204
|
+
"tier": "semantic",
|
|
1205
|
+
"type": "color",
|
|
1206
|
+
"references": "primitive.color.madder.800",
|
|
1207
|
+
"referencesDark": "primitive.color.madder.200",
|
|
1208
|
+
"value": "#651916",
|
|
1209
|
+
"valueDark": "#ffd6d1",
|
|
1210
|
+
"description": "Fill of a danger button while hovered or pressed.",
|
|
1211
|
+
"pairsWith": [
|
|
1212
|
+
{
|
|
1213
|
+
"token": "color.surface.raised",
|
|
1214
|
+
"min": 3
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
"token": "color.surface.sunken",
|
|
1218
|
+
"min": 3
|
|
1219
|
+
}
|
|
1220
|
+
]
|
|
1221
|
+
},
|
|
1140
1222
|
{
|
|
1141
1223
|
"name": "color.status.info.text",
|
|
1142
1224
|
"css": "--cx-color-status-info-text",
|
|
@@ -1737,6 +1819,13 @@
|
|
|
1737
1819
|
"css": "--cx-primitive-motion-duration-6",
|
|
1738
1820
|
"tier": "primitive",
|
|
1739
1821
|
"type": "duration",
|
|
1822
|
+
"value": "6000ms"
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
"name": "primitive.motion.duration.7",
|
|
1826
|
+
"css": "--cx-primitive-motion-duration-7",
|
|
1827
|
+
"tier": "primitive",
|
|
1828
|
+
"type": "duration",
|
|
1740
1829
|
"value": "60000ms"
|
|
1741
1830
|
},
|
|
1742
1831
|
{
|
|
@@ -1831,7 +1920,7 @@
|
|
|
1831
1920
|
"css": "--cx-motion-duration-drift",
|
|
1832
1921
|
"tier": "semantic",
|
|
1833
1922
|
"type": "duration",
|
|
1834
|
-
"references": "primitive.motion.duration.
|
|
1923
|
+
"references": "primitive.motion.duration.7",
|
|
1835
1924
|
"value": "60000ms",
|
|
1836
1925
|
"description": "Time the specimen plate's terrain takes to drift one noise unit, so its lines reshape slowly and continuously. The only looping motion in the system: one plate per page, with a visible pause control, stopped under prefers-reduced-motion. The backdrop doesn't drift."
|
|
1837
1926
|
},
|
|
@@ -1844,6 +1933,15 @@
|
|
|
1844
1933
|
"value": "3200ms",
|
|
1845
1934
|
"description": "The backdrop's response time. The home page's contours settle into place over it on arrival and then stay still, and a hill the pointer warms takes about two-thirds of it to rise and twice it to flatten. Under five seconds, so nothing runs long enough to need a pause control; none of it happens under prefers-reduced-motion."
|
|
1846
1935
|
},
|
|
1936
|
+
{
|
|
1937
|
+
"name": "motion.duration.toast",
|
|
1938
|
+
"css": "--cx-motion-duration-toast",
|
|
1939
|
+
"tier": "semantic",
|
|
1940
|
+
"type": "duration",
|
|
1941
|
+
"references": "primitive.motion.duration.6",
|
|
1942
|
+
"value": "6000ms",
|
|
1943
|
+
"description": "How long a toast (toast.md) stays before it goes on its own. The time starts again while the pointer or focus is on it, and isn't shortened under prefers-reduced-motion: it is time to read, not motion."
|
|
1944
|
+
},
|
|
1847
1945
|
{
|
|
1848
1946
|
"name": "motion.duration.pulse",
|
|
1849
1947
|
"css": "--cx-motion-duration-pulse",
|
|
@@ -1870,7 +1968,7 @@
|
|
|
1870
1968
|
"type": "cubicBezier",
|
|
1871
1969
|
"references": "primitive.motion.easing.decelerate",
|
|
1872
1970
|
"value": "cubic-bezier(0, 0, 0.2, 1)",
|
|
1873
|
-
"description": "Elements appearing: disclosures opening, a toast arriving."
|
|
1971
|
+
"description": "Elements appearing: disclosures opening, a toast arriving (toast.md)."
|
|
1874
1972
|
},
|
|
1875
1973
|
{
|
|
1876
1974
|
"name": "motion.easing.exit",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
[
|
|
2
2
|
{"key": "actions", "title": "Actions"},
|
|
3
|
+
{"key": "forms", "title": "Forms"},
|
|
3
4
|
{"key": "navigation", "title": "Navigation"},
|
|
4
5
|
{"key": "content", "title": "Content"},
|
|
6
|
+
{"key": "messages", "title": "Messages"},
|
|
5
7
|
{"key": "collections", "title": "Cards and lists"},
|
|
6
8
|
{"key": "labels", "title": "Labels and status"},
|
|
7
9
|
{"key": "data", "title": "Data"},
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: alert
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
group: messages
|
|
6
|
+
tokens:
|
|
7
|
+
- border.focus.offset
|
|
8
|
+
- border.focus.width
|
|
9
|
+
- border.width.emphasis
|
|
10
|
+
- border.width.hairline
|
|
11
|
+
- color.focus.ring
|
|
12
|
+
- color.status.danger.border
|
|
13
|
+
- color.status.danger.surface
|
|
14
|
+
- color.status.danger.text
|
|
15
|
+
- color.status.info.border
|
|
16
|
+
- color.status.info.surface
|
|
17
|
+
- color.status.info.text
|
|
18
|
+
- color.status.success.border
|
|
19
|
+
- color.status.success.surface
|
|
20
|
+
- color.status.success.text
|
|
21
|
+
- color.status.warning.border
|
|
22
|
+
- color.status.warning.surface
|
|
23
|
+
- color.status.warning.text
|
|
24
|
+
- color.surface.hover
|
|
25
|
+
- color.text.primary
|
|
26
|
+
- font.line-height.ui
|
|
27
|
+
- font.weight.strong
|
|
28
|
+
- radius.control
|
|
29
|
+
- size.icon.md
|
|
30
|
+
- size.measure.prose
|
|
31
|
+
- size.target.min
|
|
32
|
+
- space.inline.md
|
|
33
|
+
- space.inset.md
|
|
34
|
+
- space.inset.xs
|
|
35
|
+
- space.stack.lg
|
|
36
|
+
- space.stack.xs
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
# Alert
|
|
40
|
+
|
|
41
|
+
A message about the page or the system, at the top of the main column: an outage, a change that affects the reader, the result of a form that failed.
|
|
42
|
+
|
|
43
|
+
## When to use
|
|
44
|
+
|
|
45
|
+
- For something the reader should know before they use the page: a deprecation, planned maintenance, an incident, readings that have stopped.
|
|
46
|
+
- For the result of an action that the reader has to do something about, such as a form that couldn't be sent. It stays until they deal with it or dismiss it.
|
|
47
|
+
- On a dashboard's overview, for each alert in its sources (`docs/layouts/dashboard.md`).
|
|
48
|
+
|
|
49
|
+
## When not to use
|
|
50
|
+
|
|
51
|
+
- For a note about the text around it; that's a callout (`callout.md`), inside the article.
|
|
52
|
+
- To confirm that something worked and needs nothing more; that's a toast (`toast.md`).
|
|
53
|
+
- For a state shown beside the thing it describes; that's a status (`status.md`).
|
|
54
|
+
|
|
55
|
+
## Markup
|
|
56
|
+
|
|
57
|
+
```html {preview=true}
|
|
58
|
+
<div class="cx-alert cx-alert--warning">
|
|
59
|
+
<svg class="cx-icon cx-alert__icon" aria-hidden="true" focusable="false"><use href="#cx-icon-warning"></use></svg>
|
|
60
|
+
<div class="cx-alert__body">
|
|
61
|
+
<p class="cx-alert__title">Planned maintenance</p>
|
|
62
|
+
<p>Readings pause on Saturday 12 December from 02:00 to 03:00 NZDT. <a class="cx-link" href="/guide/">What stays available</a></p>
|
|
63
|
+
</div>
|
|
64
|
+
<button class="cx-alert__dismiss" type="button" data-alert-dismiss aria-label="Dismiss" hidden><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-close"></use></svg></button>
|
|
65
|
+
</div>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
<!-- caption: Alert kinds -->
|
|
69
|
+
| Kind | Class | Icon | For |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| Info | `cx-alert` | `note` | Something the reader should know, with nothing wrong |
|
|
72
|
+
| Success | `cx-alert--success` | `check` | A result that stays on the page, such as an import that finished with a report to read |
|
|
73
|
+
| Warning | `cx-alert--warning` | `warning` | Something that will affect the reader soon, or works only in part |
|
|
74
|
+
| Danger | `cx-alert--danger` | `danger` | Something has failed or stopped, and the reader may need to act |
|
|
75
|
+
|
|
76
|
+
In Hugo, `motifspec/alert.html` writes one (`docs/hugo.md`): `dict "kind" "warning" "title" "Planned maintenance" "text" "…" "dismiss" "maintenance-1212"`.
|
|
77
|
+
|
|
78
|
+
## Do
|
|
79
|
+
|
|
80
|
+
- Put it at the top of the main column, under the page head, so it's read before the content it affects.
|
|
81
|
+
- Say what happened and what the reader can do, in one or two sentences. A title helps when there are two.
|
|
82
|
+
- Link to more, or to the next step, with a text link (`button-and-link.md`).
|
|
83
|
+
- Let the reader dismiss an alert that's for information. Give the dismiss button a key when the alert shows on every page, so it stays dismissed.
|
|
84
|
+
- Take it away when the cause has gone: the incident is over, the form has been sent.
|
|
85
|
+
|
|
86
|
+
## Don't
|
|
87
|
+
|
|
88
|
+
- Don't show more than one or two on a page. If there are more, the page has a bigger problem than the alerts can describe.
|
|
89
|
+
- Don't let a danger alert about something unresolved be dismissed.
|
|
90
|
+
- Don't use one for marketing or announcements; that isn't a message about the page.
|
|
91
|
+
- Don't pick a kind for its colour. Pick it by what the reader should do.
|
|
92
|
+
|
|
93
|
+
## Accessibility
|
|
94
|
+
|
|
95
|
+
- An alert in the page when it loads is read in order, with the page; it has no live role, so it isn't announced over the page's title.
|
|
96
|
+
- An alert added after the page has loaded is announced once: give it `role="status"`, or `role="alert"` for a danger alert the reader must act on now.
|
|
97
|
+
- The kind is in the words (the title or the first sentence) as well as the icon and colour. The icon is hidden from assistive technology.
|
|
98
|
+
- The dismiss button is named "Dismiss" and is at least `size.target.min`. Dismissing moves focus to the main column, so it isn't lost.
|
|
99
|
+
- Pairs: `color.text.primary` on each `color.status.*.surface`; the icon is that kind's `color.status.*.text`, the rule its `color.status.*.border`.
|
|
100
|
+
|
|
101
|
+
## Behaviour
|
|
102
|
+
|
|
103
|
+
`dist/codex.js` does this; an app that renders alerts itself does the same.
|
|
104
|
+
|
|
105
|
+
- **Showing the button:** each `[data-alert-dismiss]` in an alert is `hidden` until the script shows it, so there's no button that does nothing without script.
|
|
106
|
+
- **Dismissing:** the button hides its alert and moves focus to `#main`. With a key, `data-alert-dismiss="maintenance-1212"`, it stores `cx-alert:maintenance-1212` in `localStorage`, and the alert is hidden on later pages until the key changes. Storage that's blocked is ignored.
|
|
107
|
+
- **Added later:** the script listens on the document, so an alert added after the page loads dismisses the same way.
|
|
108
|
+
|
|
109
|
+
## Specimens
|
|
110
|
+
|
|
111
|
+
```html {specimen="Info, dismissible" wide=true}
|
|
112
|
+
<div class="cx-alert">
|
|
113
|
+
<svg class="cx-icon cx-alert__icon" aria-hidden="true" focusable="false"><use href="#cx-icon-note"></use></svg>
|
|
114
|
+
<div class="cx-alert__body">
|
|
115
|
+
<p>Version 2.0.0 removes the deprecated tokens. <a class="cx-link" href="/reference/changelog/">See what changes</a></p>
|
|
116
|
+
</div>
|
|
117
|
+
<button class="cx-alert__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>
|
|
118
|
+
</div>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```html {specimen="Success, warning, danger" wide=true}
|
|
122
|
+
<div class="cx-alert cx-alert--success">
|
|
123
|
+
<svg class="cx-icon cx-alert__icon" aria-hidden="true" focusable="false"><use href="#cx-icon-check"></use></svg>
|
|
124
|
+
<div class="cx-alert__body"><p>Imported 214 readings. 3 were skipped.</p></div>
|
|
125
|
+
</div>
|
|
126
|
+
<div class="cx-alert cx-alert--warning">
|
|
127
|
+
<svg class="cx-icon cx-alert__icon" aria-hidden="true" focusable="false"><use href="#cx-icon-warning"></use></svg>
|
|
128
|
+
<div class="cx-alert__body"><p>No readings from the rain gauge since 13:58.</p></div>
|
|
129
|
+
</div>
|
|
130
|
+
<div class="cx-alert cx-alert--danger">
|
|
131
|
+
<svg class="cx-icon cx-alert__icon" aria-hidden="true" focusable="false"><use href="#cx-icon-danger"></use></svg>
|
|
132
|
+
<div class="cx-alert__body"><p class="cx-alert__title">Storage is down</p><p>New readings are queued and will be saved when it's back.</p></div>
|
|
133
|
+
</div>
|
|
134
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: breadcrumb
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [documentation]
|
|
5
|
+
group: navigation
|
|
6
|
+
tokens:
|
|
7
|
+
- border.width.hairline
|
|
8
|
+
- color.text.muted
|
|
9
|
+
- color.text.primary
|
|
10
|
+
- color.text.secondary
|
|
11
|
+
- font.family.mono
|
|
12
|
+
- font.line-height.ui
|
|
13
|
+
- font.size.label
|
|
14
|
+
- font.tracking.label
|
|
15
|
+
- font.weight.ui
|
|
16
|
+
- size.target.min
|
|
17
|
+
- space.inline.sm
|
|
18
|
+
- space.inline.xs
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Breadcrumb
|
|
22
|
+
|
|
23
|
+
The trail from the home page to the page's section, above its title, so a reader who arrived from search sees where the page sits.
|
|
24
|
+
|
|
25
|
+
## When to use
|
|
26
|
+
|
|
27
|
+
- On every page in the docs shell below a section: a guide page, a component, a reference page.
|
|
28
|
+
|
|
29
|
+
## When not to use
|
|
30
|
+
|
|
31
|
+
- On a section's own page, or a page at the top level; the trail would only be the home page, and the header's wordmark already goes there. `motifspec/breadcrumb.html` writes nothing for these.
|
|
32
|
+
- On the landing page.
|
|
33
|
+
- In a portfolio, whose pages are one level deep; a case study or post has the back link to its list instead (`button-and-link.md`).
|
|
34
|
+
|
|
35
|
+
## Markup
|
|
36
|
+
|
|
37
|
+
```html {preview=true}
|
|
38
|
+
<nav class="cx-breadcrumb" aria-label="Breadcrumb" data-pagefind-ignore>
|
|
39
|
+
<ol class="cx-breadcrumb__list">
|
|
40
|
+
<li><a href="/">MotifSpec</a></li>
|
|
41
|
+
<li><a href="/components/">Components</a></li>
|
|
42
|
+
</ol>
|
|
43
|
+
</nav>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
It goes first in the page head, before the h1 (`docs-shell.md`). In Hugo, `partial "motifspec/breadcrumb.html" .` writes it from the page's ancestors: the home page as `site.Title`, then each section by its link title (`docs/hugo.md`).
|
|
47
|
+
|
|
48
|
+
## Do
|
|
49
|
+
|
|
50
|
+
- End the trail at the page's parent. The h1 straight after it names the page.
|
|
51
|
+
- Use the names the navigation uses, so the trail and the open group in the navigation agree.
|
|
52
|
+
- Keep it to one line on a phone; with sections one or two words long, it is.
|
|
53
|
+
|
|
54
|
+
## Don't
|
|
55
|
+
|
|
56
|
+
- Don't add the current page as a last item; it would repeat the h1.
|
|
57
|
+
- Don't use it for steps in a process; that's steps (`steps.md`).
|
|
58
|
+
- Don't put it in the header or above the docs shell. It belongs to the page, so it's in the main column, marked `data-pagefind-ignore` so search (`search.md`) doesn't index the trail as the page's text.
|
|
59
|
+
|
|
60
|
+
## Accessibility
|
|
61
|
+
|
|
62
|
+
- It's a `nav` named "Breadcrumb", so it's a landmark a screen reader can list, and the trail is an ordered list, so its length is announced.
|
|
63
|
+
- The slashes are drawn by CSS with empty alternative text, so they aren't read out between the links.
|
|
64
|
+
- Each link is at least `size.target.min` tall.
|
|
65
|
+
- Pairs: `color.text.secondary` for the links and `color.text.muted` for the slashes, on `color.surface.base`; `color.text.primary` on hover.
|
|
66
|
+
|
|
67
|
+
## Specimens
|
|
68
|
+
|
|
69
|
+
```html {specimen="To the section"}
|
|
70
|
+
<nav class="cx-breadcrumb" aria-label="Breadcrumb">
|
|
71
|
+
<ol class="cx-breadcrumb__list">
|
|
72
|
+
<li><a href="/">MotifSpec</a></li>
|
|
73
|
+
<li><a href="/components/">Components</a></li>
|
|
74
|
+
</ol>
|
|
75
|
+
</nav>
|
|
76
|
+
```
|
|
@@ -14,10 +14,13 @@ tokens:
|
|
|
14
14
|
- color.focus.ring
|
|
15
15
|
- color.link.hover
|
|
16
16
|
- color.link.rest
|
|
17
|
+
- color.status.danger.fill
|
|
18
|
+
- color.status.danger.fill-hover
|
|
17
19
|
- color.surface.hover
|
|
18
20
|
- color.surface.raised
|
|
19
21
|
- color.text.muted
|
|
20
22
|
- color.text.on-accent
|
|
23
|
+
- color.text.on-danger
|
|
21
24
|
- color.text.primary
|
|
22
25
|
- font.family.body
|
|
23
26
|
- font.family.mono
|
|
@@ -48,6 +51,7 @@ Buttons start actions or journeys; standalone links and back links move between
|
|
|
48
51
|
|
|
49
52
|
- `cx-button--primary`: the one main action in a view ("View work").
|
|
50
53
|
- `cx-button`: a secondary action beside it.
|
|
54
|
+
- `cx-button--danger`: the action that deletes or stops something, in a dialog that asks the reader to confirm it ("Remove service"; `dialog.md`).
|
|
51
55
|
- `cx-link`: a standalone forward link at the end of a section ("All projects" plus a forward arrow).
|
|
52
56
|
- `cx-back`: the return link at the top of a post or case study (back arrow plus "All writing").
|
|
53
57
|
|
|
@@ -55,6 +59,7 @@ Buttons start actions or journeys; standalone links and back links move between
|
|
|
55
59
|
|
|
56
60
|
- For inline links in text; `prose` styles those.
|
|
57
61
|
- Two primary buttons in one view. Make the second one secondary.
|
|
62
|
+
- `cx-button--danger` on a page or in a table row. A destructive action there opens a dialog, and the danger button is in the dialog.
|
|
58
63
|
- For navigation between sibling posts; use `pagination`.
|
|
59
64
|
|
|
60
65
|
## Markup
|
|
@@ -69,6 +74,15 @@ Buttons start actions or journeys; standalone links and back links move between
|
|
|
69
74
|
<a class="cx-back" href="/writing/"><svg class="cx-icon cx-icon--sm cx-button__arrow" aria-hidden="true" focusable="false"><use href="#cx-icon-arrow-back"></use></svg>All writing</a>
|
|
70
75
|
```
|
|
71
76
|
|
|
77
|
+
In a dialog that confirms a destructive action, the danger button takes the primary's place, after Cancel:
|
|
78
|
+
|
|
79
|
+
```html {preview=true}
|
|
80
|
+
<div class="cx-actions">
|
|
81
|
+
<button class="cx-button" type="button">Cancel</button>
|
|
82
|
+
<button class="cx-button cx-button--danger" type="button">Remove service</button>
|
|
83
|
+
</div>
|
|
84
|
+
```
|
|
85
|
+
|
|
72
86
|
Add `cx-button--sm` for a compact button in a table row or a toolbar, where full-size buttons would make every row tall:
|
|
73
87
|
|
|
74
88
|
```html {preview=true}
|
|
@@ -94,7 +108,7 @@ Add `cx-button--sm` for a compact button in a table row or a toolbar, where full
|
|
|
94
108
|
|
|
95
109
|
- Buttons are 40px tall (`size.target.control`); links at least 24px.
|
|
96
110
|
- Focus shows `color.focus.ring` 2px off the element, so it never sits on the green fill.
|
|
97
|
-
- Pairs: `color.text.on-accent` on `color.accent.fill.rest` and `.hover` (4.5:1); `color.accent.fill.rest` against the page (3:1); secondary border `color.border.strong` (3:1); `color.link.rest` (7:1).
|
|
111
|
+
- Pairs: `color.text.on-accent` on `color.accent.fill.rest` and `.hover` (4.5:1); `color.text.on-danger` on `color.status.danger.fill` and `.fill-hover` (4.5:1); `color.accent.fill.rest` against the page (3:1); secondary border `color.border.strong` (3:1); `color.link.rest` (7:1).
|
|
98
112
|
|
|
99
113
|
## Specimens
|
|
100
114
|
|
|
@@ -106,6 +120,10 @@ For the Components page: each variant at a glance. Ids start "sp-"; `wide=true`
|
|
|
106
120
|
<button class="cx-button" type="button" disabled>Not yet published</button>
|
|
107
121
|
```
|
|
108
122
|
|
|
123
|
+
```html {specimen="Danger"}
|
|
124
|
+
<button class="cx-button cx-button--danger" type="button">Remove service</button>
|
|
125
|
+
```
|
|
126
|
+
|
|
109
127
|
```html {specimen="Small"}
|
|
110
128
|
<a class="cx-button cx-button--sm" href="/reference/changelog/">Changelog</a>
|
|
111
129
|
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: callout
|
|
3
3
|
status: stable
|
|
4
4
|
layouts: [shared]
|
|
5
|
-
group:
|
|
5
|
+
group: messages
|
|
6
6
|
tokens:
|
|
7
7
|
- border.width.emphasis
|
|
8
8
|
- border.width.hairline
|
|
@@ -45,6 +45,7 @@ A tinted note set apart from running text, in four kinds: note, tip, warning and
|
|
|
45
45
|
- More than twice per article. Callouts lose force when repeated.
|
|
46
46
|
- For quotations; use `<blockquote>`.
|
|
47
47
|
- For decoration or to make a paragraph "pop".
|
|
48
|
+
- For a message about the page or the system rather than the text around it; use an alert (`alert.md`) at the top of the main column.
|
|
48
49
|
|
|
49
50
|
## Markup
|
|
50
51
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: choice
|
|
3
|
+
status: stable
|
|
4
|
+
layouts: [shared]
|
|
5
|
+
group: forms
|
|
6
|
+
tokens:
|
|
7
|
+
- border.focus.offset
|
|
8
|
+
- border.focus.width
|
|
9
|
+
- border.width.emphasis
|
|
10
|
+
- border.width.hairline
|
|
11
|
+
- color.accent.fill.rest
|
|
12
|
+
- color.border.strong
|
|
13
|
+
- color.focus.ring
|
|
14
|
+
- color.surface.sunken
|
|
15
|
+
- color.text.muted
|
|
16
|
+
- color.text.on-accent
|
|
17
|
+
- color.text.secondary
|
|
18
|
+
- font.line-height.ui
|
|
19
|
+
- font.size.small
|
|
20
|
+
- motion.duration.fast
|
|
21
|
+
- motion.easing.standard
|
|
22
|
+
- radius.pill
|
|
23
|
+
- size.icon.md
|
|
24
|
+
- size.target.min
|
|
25
|
+
- size.target.touch
|
|
26
|
+
- space.inline.sm
|
|
27
|
+
- space.stack.sm
|
|
28
|
+
- space.stack.xs
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Choice
|
|
32
|
+
|
|
33
|
+
A checkbox, radio button or switch, with its label beside it: native inputs in the accent colour.
|
|
34
|
+
|
|
35
|
+
## When to use
|
|
36
|
+
|
|
37
|
+
- A checkbox for one thing that's on or off when the form is sent ("Start when the node starts"), or for each of several that can all be on.
|
|
38
|
+
- Radio buttons for one choice among two to five, all shown at once.
|
|
39
|
+
- A switch for a setting that takes effect as soon as it's changed ("Send alerts").
|
|
40
|
+
|
|
41
|
+
## When not to use
|
|
42
|
+
|
|
43
|
+
- For more than five options, or options that don't need to be seen together; use a select (`field.md`).
|
|
44
|
+
- For switching between views of the same content; that's tabs (`tabs.md`).
|
|
45
|
+
- A switch in a form that waits for Save. Use a checkbox there.
|
|
46
|
+
|
|
47
|
+
## Markup
|
|
48
|
+
|
|
49
|
+
```html {preview=true}
|
|
50
|
+
<fieldset class="cx-fieldset">
|
|
51
|
+
<legend>When it fails</legend>
|
|
52
|
+
<div class="cx-choices">
|
|
53
|
+
<label class="cx-choice"><input type="radio" name="on-failure" value="restart" checked><span class="cx-choice__text">Restart it<span class="cx-field__hint">Up to 3 times, then stop and raise an alert.</span></span></label>
|
|
54
|
+
<label class="cx-choice"><input type="radio" name="on-failure" value="stop"><span class="cx-choice__text">Leave it stopped</span></label>
|
|
55
|
+
</div>
|
|
56
|
+
<label class="cx-choice"><input type="checkbox" name="start-on-boot" checked><span class="cx-choice__text">Start when the node starts</span></label>
|
|
57
|
+
<label class="cx-choice"><input type="checkbox" role="switch" name="alerts" checked><span class="cx-choice__text">Send alerts</span></label>
|
|
58
|
+
</fieldset>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A switch is a checkbox with `role="switch"`. Its label names the setting, and the switch shows whether it's on.
|
|
62
|
+
|
|
63
|
+
## Do
|
|
64
|
+
|
|
65
|
+
- Put radio buttons in a `fieldset` whose `legend` asks the question, and give them one `name`.
|
|
66
|
+
- Write each label as what happens when it's chosen, in a few words. A hint can go under it, inside `cx-choice__text`.
|
|
67
|
+
- Pick a sensible default for radio buttons, so one is always chosen.
|
|
68
|
+
|
|
69
|
+
## Don't
|
|
70
|
+
|
|
71
|
+
- Don't use one checkbox with a negative label ("Don't send alerts").
|
|
72
|
+
- Don't make a switch wait for a Save button.
|
|
73
|
+
- Don't hide a disabled choice's reason; say it in a hint.
|
|
74
|
+
|
|
75
|
+
## Accessibility
|
|
76
|
+
|
|
77
|
+
- Each input is inside its label, so the whole line can be clicked or tapped, and it's at least `size.target.min` tall.
|
|
78
|
+
- Radio buttons in a fieldset are announced as a group, with the legend; the arrow keys move between them.
|
|
79
|
+
- A switch is announced as a switch, on or off.
|
|
80
|
+
- Focus shows `color.focus.ring` around the input.
|
|
81
|
+
- Pairs: `color.accent.fill.rest` against `color.surface.base` (3:1) for a ticked box or an on switch; `color.text.on-accent` for the switch's knob; `color.border.strong` for an off switch.
|
|
82
|
+
|
|
83
|
+
## Specimens
|
|
84
|
+
|
|
85
|
+
```html {specimen="Checkboxes"}
|
|
86
|
+
<div class="cx-choices">
|
|
87
|
+
<label class="cx-choice"><input type="checkbox" checked><span class="cx-choice__text">Start on boot</span></label>
|
|
88
|
+
<label class="cx-choice"><input type="checkbox"><span class="cx-choice__text">Pull a new image nightly</span></label>
|
|
89
|
+
</div>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```html {specimen="Radio buttons"}
|
|
93
|
+
<div class="cx-choices">
|
|
94
|
+
<label class="cx-choice"><input type="radio" name="sp-choice-r" checked><span class="cx-choice__text">Restart it</span></label>
|
|
95
|
+
<label class="cx-choice"><input type="radio" name="sp-choice-r"><span class="cx-choice__text">Leave it stopped</span></label>
|
|
96
|
+
</div>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```html {specimen="Switch, on and off"}
|
|
100
|
+
<div class="cx-choices">
|
|
101
|
+
<label class="cx-choice"><input type="checkbox" role="switch" checked><span class="cx-choice__text">Send alerts</span></label>
|
|
102
|
+
<label class="cx-choice"><input type="checkbox" role="switch"><span class="cx-choice__text">Quiet hours</span></label>
|
|
103
|
+
</div>
|
|
104
|
+
```
|