@aitrien/motifspec 1.26.0 → 1.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
+ ```
@@ -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
+ ```
@@ -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
 
package/docs/hugo.md CHANGED
@@ -144,6 +144,7 @@ Every partial below is called as `partial "motifspec/<name>.html" <context>`.
144
144
  | `back-link.html` | `button-and-link.md` | `dict "href" "…" "label" "All work"`. |
145
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
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. |
147
148
  | `section-heading.html` | `heading-anchor.md` | `dict "id" "work" "title" "Selected work"`, inside a `<section id="work" aria-labelledby="work-title">`. |
148
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. |
149
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 and compact buttons, callouts, data tables with state and action cells, status labels in five tones, 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, the segmented control, form controls and the dialog.
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
 
@@ -23,7 +23,7 @@ Planned: a side navigation column (wordmark, grouped links, the theme toggle and
23
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 fields → actions at the end of the form | The fields | Help text |
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
@@ -9,11 +9,11 @@
9
9
  "icons": {
10
10
  "arrow-forward": {
11
11
  "symbol": "arrow_forward",
12
- "use": "Forward journeys: primary and secondary buttons, standalone links, Next in pagination."
12
+ "use": "Forward journeys: primary and secondary buttons, standalone links, Next in pagination and in a calendar."
13
13
  },
14
14
  "arrow-back": {
15
15
  "symbol": "arrow_back",
16
- "use": "Back links at the top of posts and case studies; Previous in pagination."
16
+ "use": "Back links at the top of posts and case studies; Previous in pagination and in a calendar."
17
17
  },
18
18
  "arrow-upward": {
19
19
  "symbol": "arrow_upward",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "danger": {
55
55
  "symbol": "report",
56
- "use": "Title of a danger callout."
56
+ "use": "Title of a danger callout or alert, and a field’s error message."
57
57
  },
58
58
  "rss": {
59
59
  "symbol": "rss_feed",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "expand": {
63
63
  "symbol": "keyboard_arrow_down",
64
- "use": "Disclosure indicator on <summary>; rotates when open."
64
+ "use": "Disclosure indicator on <summary>, rotating when open; the arrow of a select, and of a calendar’s month and year buttons."
65
65
  },
66
66
  "pause": {
67
67
  "symbol": "pause",
@@ -122,6 +122,10 @@
122
122
  "logs": {
123
123
  "symbol": "terminal",
124
124
  "use": "Logs and consoles: a link or action that opens them."
125
+ },
126
+ "calendar": {
127
+ "symbol": "calendar_today",
128
+ "use": "The button that opens a date field’s calendar, and the native date field’s picker."
125
129
  }
126
130
  }
127
131
  }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M140-100v-694.61h131.54v-70h50.38v70h317.69v-70h49.23v70H820V-100H140Zm45.39-45.39h589.22V-555H185.39v409.61Zm0-454.99h589.22v-148.85H185.39v148.85Zm0 0v-148.85 148.85Z"/></svg>
@@ -0,0 +1,53 @@
1
+ {{- /* field.md (and date-picker.md). Context: dict "id" "…" "label" "…", plus any of:
2
+ "type" ("text" by default; "email", "number", "date"…; "select" with "options" (a slice); "textarea"; "date-picker"),
3
+ "name", "value", "placeholder" (an example, shown once the reader is in the field), "hint", "error",
4
+ "optional" true, "required" true, "disabled" true, "mono" true, "short" true, "inputmode", "autocomplete".
5
+ A date picker takes "choose" too, its button's name ("Choose a date of birth"). */ -}}
6
+ {{- if not (and .id .label) }}{{ errorf "motifspec/field.html: a field needs \"id\" and \"label\"." }}{{ end }}
7
+ {{- $type := .type | default "text" }}
8
+ {{- $describe := slice }}
9
+ {{- if .hint }}{{ $describe = $describe | append (printf "%s-hint" .id) }}{{ end }}
10
+ {{- if .error }}{{ $describe = $describe | append (printf "%s-error" .id) }}{{ end }}
11
+ {{- $class := "cx-field__control" }}
12
+ {{- if or .mono (eq $type "date-picker") }}{{ $class = printf "%s cx-field__control--mono" $class }}{{ end }}
13
+ {{- if .short }}{{ $class = printf "%s cx-field__control--short" $class }}{{ end }}
14
+ {{- $attrs := printf "class=%q id=%q" $class .id }}
15
+ {{- with .name }}{{ $attrs = printf "%s name=%q" $attrs . }}{{ end }}
16
+ {{- if .required }}{{ $attrs = printf "%s required" $attrs }}{{ end }}
17
+ {{- if .disabled }}{{ $attrs = printf "%s disabled" $attrs }}{{ end }}
18
+ {{- if .error }}{{ $attrs = printf "%s aria-invalid=\"true\"" $attrs }}{{ end }}
19
+ {{- with $describe }}{{ $attrs = printf "%s aria-describedby=%q" $attrs (delimit . " ") }}{{ end }}
20
+ {{- $box := "cx-field__box" }}
21
+ {{- if eq $type "textarea" }}{{ $box = printf "%s cx-field__box--area" $box }}{{ end }}
22
+ {{- if eq $type "date-picker" }}{{ $box = printf "%s cx-field__box--date" $box }}{{ end }}
23
+ <div class="cx-field">
24
+ <div class="{{ $box }}"{{ if eq $type "date-picker" }} data-date-picker{{ end }}>
25
+ {{- if eq $type "select" }}
26
+ <select {{ $attrs | safeHTMLAttr }}>
27
+ {{- range .options }}<option{{ if eq . $.value }} selected{{ end }}>{{ . }}</option>{{ end }}
28
+ </select>
29
+ {{- else }}
30
+ {{- $more := printf "placeholder=%q" (.placeholder | default (cond (eq $type "date-picker") "DD/MM/YYYY" " ")) }}
31
+ {{- with .inputmode }}{{ $more = printf "%s inputmode=%q" $more . }}{{ else }}{{ if eq $type "date-picker" }}{{ $more = printf "%s inputmode=\"numeric\"" $more }}{{ end }}{{ end }}
32
+ {{- with .autocomplete }}{{ $more = printf "%s autocomplete=%q" $more . }}{{ end }}
33
+ {{- if eq $type "textarea" }}
34
+ <textarea {{ $attrs | safeHTMLAttr }} {{ $more | safeHTMLAttr }}>{{ .value }}</textarea>
35
+ {{- else }}
36
+ <input {{ $attrs | safeHTMLAttr }} {{ $more | safeHTMLAttr }} type="{{ if eq $type "date-picker" }}text{{ else }}{{ $type }}{{ end }}"{{ with .value }} value="{{ . }}"{{ end }}>
37
+ {{- end }}
38
+ {{- end }}
39
+ <label class="cx-field__label" for="{{ .id }}">{{ .label }}{{ if .optional }} <span class="cx-field__optional">(optional)</span>{{ end }}</label>
40
+ {{- if eq $type "select" }}
41
+ <svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-expand"></use></svg>
42
+ {{- end }}
43
+ {{- if eq $type "date-picker" }}
44
+ <button class="cx-date__button" type="button" aria-label="{{ .choose | default "Choose a date" }}" aria-haspopup="dialog" hidden><svg class="cx-icon" aria-hidden="true" focusable="false"><use href="#cx-icon-calendar"></use></svg></button>
45
+ {{- end }}
46
+ </div>
47
+ {{- with .hint }}
48
+ <p class="cx-field__hint" id="{{ $.id }}-hint">{{ . }}</p>
49
+ {{- end }}
50
+ {{- with .error }}
51
+ <p class="cx-field__error" id="{{ $.id }}-error"><svg class="cx-icon cx-icon--sm" aria-hidden="true" focusable="false"><use href="#cx-icon-danger"></use></svg>{{ . }}</p>
52
+ {{- end }}
53
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aitrien/motifspec",
3
- "version": "1.26.0",
3
+ "version": "1.27.1",
4
4
  "description": "Liam Marshall's design system: DTCG tokens and layered component rules that AI assistants read a layer at a time, with generated CSS, Hugo templates and a rule checker.",
5
5
  "keywords": [
6
6
  "design-system",
package/scripts/lib.mjs CHANGED
@@ -286,4 +286,8 @@ export const DOC_SELECTORS = {
286
286
  'alert': ['.cx-alert'],
287
287
  'toast': ['.cx-toasts', '.cx-toast'],
288
288
  'breadcrumb': ['.cx-breadcrumb'],
289
+ 'field': ['.cx-field', '.cx-fieldset'],
290
+ 'choice': ['.cx-choice', '.cx-choices'],
291
+ 'date-picker': ['.cx-date__button', '.cx-calendar'],
292
+ 'dialog': ['.cx-dialog'],
289
293
  };
package/tokens/color.json CHANGED
@@ -937,6 +937,15 @@
937
937
  "dark": "{primitive.color.sap.800}"
938
938
  }
939
939
  }
940
+ },
941
+ "selected": {
942
+ "$value": "{primitive.color.sap.100}",
943
+ "$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.",
944
+ "$extensions": {
945
+ "codex.modes": {
946
+ "dark": "{primitive.color.sap.800}"
947
+ }
948
+ }
940
949
  }
941
950
  },
942
951
  "text": {
@@ -968,6 +977,10 @@
968
977
  "token": "color.surface.highlight",
969
978
  "min": 7
970
979
  },
980
+ {
981
+ "token": "color.surface.selected",
982
+ "min": 7
983
+ },
971
984
  {
972
985
  "token": "color.status.success.surface",
973
986
  "min": 7
@@ -1093,6 +1106,25 @@
1093
1106
  }
1094
1107
  ]
1095
1108
  }
1109
+ },
1110
+ "on-danger": {
1111
+ "$value": "{primitive.color.ash.0}",
1112
+ "$description": "Text and icons on color.status.danger.fill and its hover, such as a danger button’s label. Only there.",
1113
+ "$extensions": {
1114
+ "codex.modes": {
1115
+ "dark": "{primitive.color.ash.1000}"
1116
+ },
1117
+ "codex.pairsWith": [
1118
+ {
1119
+ "token": "color.status.danger.fill",
1120
+ "min": 4.5
1121
+ },
1122
+ {
1123
+ "token": "color.status.danger.fill-hover",
1124
+ "min": 4.5
1125
+ }
1126
+ ]
1127
+ }
1096
1128
  }
1097
1129
  },
1098
1130
  "link": {
@@ -1457,6 +1489,48 @@
1457
1489
  }
1458
1490
  ]
1459
1491
  }
1492
+ },
1493
+ "fill": {
1494
+ "$value": "{primitive.color.madder.700}",
1495
+ "$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.",
1496
+ "$extensions": {
1497
+ "codex.modes": {
1498
+ "dark": "{primitive.color.madder.300}"
1499
+ },
1500
+ "codex.pairsWith": [
1501
+ {
1502
+ "token": "color.surface.base",
1503
+ "min": 3
1504
+ },
1505
+ {
1506
+ "token": "color.surface.raised",
1507
+ "min": 3
1508
+ },
1509
+ {
1510
+ "token": "color.surface.sunken",
1511
+ "min": 3
1512
+ }
1513
+ ]
1514
+ }
1515
+ },
1516
+ "fill-hover": {
1517
+ "$value": "{primitive.color.madder.800}",
1518
+ "$description": "Fill of a danger button while hovered or pressed.",
1519
+ "$extensions": {
1520
+ "codex.modes": {
1521
+ "dark": "{primitive.color.madder.200}"
1522
+ },
1523
+ "codex.pairsWith": [
1524
+ {
1525
+ "token": "color.surface.raised",
1526
+ "min": 3
1527
+ },
1528
+ {
1529
+ "token": "color.surface.sunken",
1530
+ "min": 3
1531
+ }
1532
+ ]
1533
+ }
1460
1534
  }
1461
1535
  },
1462
1536
  "info": {