@scalewing/react 1.64.0 → 1.66.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +24 -1
  3. package/dist/components/Checkbox.d.ts +13 -1
  4. package/dist/components/Checkbox.js +6 -2
  5. package/dist/components/Field.js +1 -0
  6. package/dist/components/RadioGroup.d.ts +12 -1
  7. package/dist/components/RadioGroup.js +6 -2
  8. package/dist/components/SiteHeader.d.ts +8 -4
  9. package/dist/components/SiteHeader.js +10 -5
  10. package/dist/components/TaskList.d.ts +21 -2
  11. package/dist/components/TaskList.js +11 -6
  12. package/dist/components/checkbox/checkbox-appearance.d.ts +12 -0
  13. package/dist/components/checkbox/checkbox-appearance.js +16 -0
  14. package/dist/components/field/field-checks.d.ts +1 -1
  15. package/dist/components/field/field-checks.js +18 -1
  16. package/dist/components/field/field-props.d.ts +8 -0
  17. package/dist/components/radio-group/radio-group-description-layout.d.ts +9 -0
  18. package/dist/components/radio-group/radio-group-description-layout.js +11 -0
  19. package/dist/components/site-header/SiteHeaderSearch.d.ts +16 -0
  20. package/dist/components/site-header/SiteHeaderSearch.js +19 -0
  21. package/dist/components/site-header/types.d.ts +24 -0
  22. package/dist/components/site-header/validate.d.ts +1 -1
  23. package/dist/components/site-header/validate.js +22 -1
  24. package/dist/components/task-list/assert-task-list.d.ts +3 -0
  25. package/dist/components/task-list/assert-task-list.js +7 -0
  26. package/dist/css/css-checkbox-tile.d.ts +2 -0
  27. package/dist/css/css-checkbox-tile.js +67 -0
  28. package/dist/css/css-checkbox.js +4 -0
  29. package/dist/css/css-field-read-only.d.ts +2 -0
  30. package/dist/css/css-field-read-only.js +26 -0
  31. package/dist/css/css-field.js +4 -0
  32. package/dist/css/css-radio-group.js +5 -1
  33. package/dist/css/css-site-header-search.d.ts +2 -0
  34. package/dist/css/css-site-header-search.js +336 -0
  35. package/dist/css/css-site-header.js +6 -1
  36. package/dist/css/css-task-list-layout.d.ts +6 -0
  37. package/dist/css/css-task-list-layout.js +67 -0
  38. package/dist/css/css-task-list.js +5 -1
  39. package/dist/index.d.ts +3 -3
  40. package/dist/index.js +2 -2
  41. package/dist/styles.css +378 -0
  42. package/package.json +1 -1
@@ -5,7 +5,7 @@ import { assertNavItems } from '../nav-items.js';
5
5
  * button name, and a skip link with blank words or an address that is not
6
6
  * a fragment on the page.
7
7
  */
8
- export function assertSiteHeaderProps({ items, labels, navLabel, skipLink, }) {
8
+ export function assertSiteHeaderProps({ items, labels, navLabel, search, skipLink, }) {
9
9
  if (items.length === 0)
10
10
  throw new RangeError('SiteHeader needs at least one item');
11
11
  assertNavItems('SiteHeader', items);
@@ -17,6 +17,27 @@ export function assertSiteHeaderProps({ items, labels, navLabel, skipLink, }) {
17
17
  throw new RangeError('SiteHeader labels need nonempty openMenu and closeMenu');
18
18
  if (skipLink)
19
19
  assertSkipLink(skipLink);
20
+ if (search)
21
+ assertSearch(search);
22
+ }
23
+ function assertSearch(search) {
24
+ if (typeof search.labels !== 'object' || search.labels === null)
25
+ throw new RangeError('SiteHeader search needs a nonempty action, label, placeholder and open and close labels');
26
+ const words = [
27
+ search.action,
28
+ search.label,
29
+ search.placeholder,
30
+ search.labels.open,
31
+ search.labels.close,
32
+ ];
33
+ if (words.some((word) => !word.trim()))
34
+ throw new RangeError('SiteHeader search needs a nonempty action, label, placeholder and open and close labels');
35
+ if (search.name !== undefined && !/^[\w-]+$/.test(search.name))
36
+ throw new RangeError('SiteHeader search name must be a plain parameter name');
37
+ if (search.icon === null ||
38
+ search.icon === undefined ||
39
+ search.icon === false)
40
+ throw new RangeError('SiteHeader search needs an icon');
20
41
  }
21
42
  function assertSkipLink({ href, label }) {
22
43
  if (!label.trim())
@@ -1,5 +1,8 @@
1
+ import { type Breakpoint } from '../../css/breakpoints.js';
1
2
  import { type TaskListLabels } from './task-list-status.js';
2
3
  import type { TaskListItem } from './task-list-item.js';
4
+ /** Fails closed on an `actionBelow` that is not a layout breakpoint. */
5
+ export declare function assertActionBelow(actionBelow: Breakpoint | undefined): void;
3
6
  /**
4
7
  * Fails closed on what would leave a task unnamed or unread: a blank list
5
8
  * label or status word, a blank or repeated id, a blank title or detail,
@@ -1,4 +1,11 @@
1
+ import { breakpoints } from '../../css/breakpoints.js';
1
2
  import { isTaskListStatus, taskListStatuses, } from './task-list-status.js';
3
+ /** Fails closed on an `actionBelow` that is not a layout breakpoint. */
4
+ export function assertActionBelow(actionBelow) {
5
+ if (actionBelow !== undefined &&
6
+ !breakpoints.includes(actionBelow))
7
+ throw new RangeError(`TaskList actionBelow must be one of ${breakpoints.join(', ')}`);
8
+ }
2
9
  function isBlank(value) {
3
10
  return typeof value !== 'string' || !value.trim();
4
11
  }
@@ -0,0 +1,2 @@
1
+ export declare function cssCheckboxTileClasses(): string;
2
+ export declare function checkboxTileClassCatalog(): string[];
@@ -0,0 +1,67 @@
1
+ /** Where a tile's description and error start: under the label's words. */
2
+ const besideBox = 'calc(var(--sw-space-5) + var(--sw-space-2))';
3
+ /** A tile's chosen or invalid edge: its border plus an inset hairline, so nothing moves. */
4
+ function edge(color) {
5
+ return `border-color: ${color};
6
+ box-shadow: inset 0 0 0 1px ${color};`;
7
+ }
8
+ /*
9
+ * A tile Checkbox: the box, the label and the description inside one
10
+ * bordered tile as wide as its column, at least the 44 px target plus its
11
+ * padding. The label's `::after` stretches over the whole tile, so a press
12
+ * anywhere on it (the description included) toggles the box. A chosen or
13
+ * mixed tile takes the accent edge, an invalid one the danger edge (which
14
+ * wins), twice the hairline through an inset shadow. The description and
15
+ * the error start under the label's words. Forced colours keep the edges
16
+ * as CanvasText, Highlight and Mark.
17
+ */
18
+ export function cssCheckboxTileClasses() {
19
+ return `.sw-checkbox-tile {
20
+ border: 1px solid var(--sw-color-border);
21
+ border-radius: var(--sw-radius-md);
22
+ box-sizing: border-box;
23
+ gap: 0;
24
+ padding: var(--sw-space-2) var(--sw-space-3);
25
+ position: relative;
26
+ width: 100%;
27
+ }
28
+
29
+ .sw-checkbox-tile .sw-checkbox-label {
30
+ min-height: var(--sw-control-sm-min-height);
31
+ width: 100%;
32
+ }
33
+
34
+ .sw-checkbox-tile .sw-checkbox-label::after {
35
+ border-radius: inherit;
36
+ content: '';
37
+ inset: 0;
38
+ position: absolute;
39
+ }
40
+
41
+ .sw-checkbox-tile :is(.sw-checkbox-description, .sw-checkbox-error) {
42
+ padding-inline-start: ${besideBox};
43
+ }
44
+
45
+ .sw-checkbox-tile-checked {
46
+ ${edge('var(--sw-color-accent)')}
47
+ }
48
+
49
+ .sw-checkbox-tile-invalid {
50
+ ${edge('var(--sw-color-danger)')}
51
+ }
52
+
53
+ .sw-checkbox-tile:has(.sw-checkbox-input:disabled) { cursor: not-allowed; }
54
+
55
+ @media (forced-colors: active) {
56
+ .sw-checkbox-tile { border-color: CanvasText; }
57
+ .sw-checkbox-tile-checked { border-color: Highlight; box-shadow: inset 0 0 0 1px Highlight; }
58
+ .sw-checkbox-tile-invalid { border-color: Mark; box-shadow: inset 0 0 0 1px Mark; }
59
+ }`;
60
+ }
61
+ export function checkboxTileClassCatalog() {
62
+ return [
63
+ 'sw-checkbox-tile',
64
+ 'sw-checkbox-tile-checked',
65
+ 'sw-checkbox-tile-invalid',
66
+ ];
67
+ }
@@ -1,5 +1,6 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
2
  import { checkStrokeIn } from './chevron.js';
3
+ import { checkboxTileClassCatalog, cssCheckboxTileClasses, } from './css-checkbox-tile.js';
3
4
  import { coarsePointerQuery, touchTarget } from './touch-target.js';
4
5
  const label = typographyVariants.label;
5
6
  const caption = typographyVariants.caption;
@@ -135,6 +136,8 @@ export function cssCheckboxClasses() {
135
136
  .sw-checkbox-error { color: var(--sw-color-danger); }
136
137
  .sw-checkbox-error:empty { position: absolute; }
137
138
 
139
+ ${cssCheckboxTileClasses()}
140
+
138
141
  @media (prefers-reduced-transparency: reduce) {
139
142
  .sw-checkbox-mark { background: var(--sw-color-surface); }
140
143
  .sw-checkbox-input:is(:checked, :indeterminate) + .sw-checkbox-mark { background: var(--sw-color-accent); }
@@ -158,5 +161,6 @@ export function checkboxClassCatalog() {
158
161
  'sw-checkbox-text',
159
162
  'sw-checkbox-description',
160
163
  'sw-checkbox-error',
164
+ ...checkboxTileClassCatalog(),
161
165
  ];
162
166
  }
@@ -0,0 +1,2 @@
1
+ export declare function cssFieldReadOnlyClasses(): string;
2
+ export declare function fieldReadOnlyClassCatalog(): string[];
@@ -0,0 +1,26 @@
1
+ /*
2
+ * A read-only Field: a value shown, not typed. The control keeps its size
3
+ * and padding but drops the edge for the subtle fill, in the text colour
4
+ * with a plain cursor, so it reads apart from an editable field (an edge
5
+ * on the glass fill) and a disabled one (a dashed edge). Focus keeps the
6
+ * canvas ring. Forced colours drop the fill, so the edge stays, dotted, in
7
+ * CanvasText.
8
+ */
9
+ export function cssFieldReadOnlyClasses() {
10
+ return `[data-theme] .sw-field-read-only > :is(input, textarea) {
11
+ background-color: var(--sw-color-subtle);
12
+ border-color: transparent;
13
+ color: var(--sw-color-text);
14
+ cursor: default;
15
+ }
16
+
17
+ @media (forced-colors: active) {
18
+ [data-theme] .sw-field-read-only > :is(input, textarea) {
19
+ border-color: CanvasText;
20
+ border-style: dotted;
21
+ }
22
+ }`;
23
+ }
24
+ export function fieldReadOnlyClassCatalog() {
25
+ return ['sw-field-read-only'];
26
+ }
@@ -2,6 +2,7 @@ import { typographyVariants } from '@scalewing/tokens';
2
2
  import { controlSurface, disabledControlForcedColors, disabledControlSurface, } from './css-document.js';
3
3
  import { cssFieldChangedClasses } from './css-field-changed.js';
4
4
  import { cssFieldDescriptionClasses, fieldDescriptionClassCatalog, } from './css-field-description.js';
5
+ import { cssFieldReadOnlyClasses, fieldReadOnlyClassCatalog, } from './css-field-read-only.js';
5
6
  import { cssFieldWidthClasses, fieldWidthClassCatalog, } from './css-field-width.js';
6
7
  import { cssFieldSearchClasses, fieldSearchClassCatalog, } from './css-field-search.js';
7
8
  const caption = typographyVariants.caption;
@@ -88,6 +89,8 @@ ${cssFieldDescriptionClasses()}
88
89
 
89
90
  ${adornmentRules()}
90
91
 
92
+ ${cssFieldReadOnlyClasses()}
93
+
91
94
  ${cssFieldSearchClasses()}
92
95
 
93
96
  ${cssFieldChangedClasses()}
@@ -117,6 +120,7 @@ export function fieldClassCatalog() {
117
120
  'sw-field-prefix',
118
121
  'sw-field-suffix',
119
122
  ...fieldSearchClassCatalog(),
123
+ ...fieldReadOnlyClassCatalog(),
120
124
  ...fieldWidthClassCatalog(),
121
125
  ];
122
126
  }
@@ -193,11 +193,15 @@ function optionDescriptionRules() {
193
193
 
194
194
  @media ${breakpointQuery('below', 'md')} {
195
195
  .sw-radio-group-option-description { flex-basis: 100%; }
196
- }`;
196
+ }
197
+
198
+ /* Stacked: every description on its own line under its label, at any width. */
199
+ .sw-radio-group-stacked .sw-radio-group-option-description { flex-basis: 100%; }`;
197
200
  }
198
201
  export function radioGroupClassCatalog() {
199
202
  return [
200
203
  'sw-radio-group',
204
+ 'sw-radio-group-stacked',
201
205
  'sw-radio-group-legend',
202
206
  'sw-radio-group-options',
203
207
  'sw-radio-group-option',
@@ -0,0 +1,2 @@
1
+ export declare function cssSiteHeaderSearchRules(): string;
2
+ export declare function siteHeaderSearchClassCatalog(): string[];
@@ -0,0 +1,336 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { quietFill } from './quiet-fill.js';
3
+ import { siteHeaderCompactHeight as compactHeight, siteHeaderGutter, siteHeaderWideQuery as wide, } from './site-header-geometry.js';
4
+ import { zIndex } from './stacking.js';
5
+ import { coarsePointerQuery, touchTarget } from './touch-target.js';
6
+ const body = typographyVariants.body;
7
+ const caption = typographyVariants.caption;
8
+ const label = typographyVariants.label;
9
+ const search = '.sw-site-header-search';
10
+ const results = '.sw-site-header-search-results';
11
+ const result = '[data-theme] .sw-site-header-search-result';
12
+ /*
13
+ * Below `lg`: a round quiet search button in the bar, before the compact
14
+ * actions, and the search itself a native popover over the whole window
15
+ * (the browser's top layer): a bar the compact header's height holding the
16
+ * filled field and a close button, the results under it scrolling on their
17
+ * own, each a row with a hairline. The field's words are the body size, so
18
+ * an iPhone does not zoom into it.
19
+ */
20
+ function compactRules() {
21
+ return `.sw-site-header-search-button,
22
+ .sw-site-header-search-close {
23
+ align-items: center;
24
+ appearance: none;
25
+ background: transparent;
26
+ border: 0;
27
+ border-radius: var(--sw-radius-pill);
28
+ box-sizing: border-box;
29
+ color: var(--sw-color-text);
30
+ cursor: pointer;
31
+ display: inline-flex;
32
+ flex: none;
33
+ height: var(--sw-control-md-min-height);
34
+ justify-content: center;
35
+ margin: 0;
36
+ padding: 0;
37
+ width: var(--sw-control-md-min-height);
38
+ }
39
+
40
+ .sw-site-header-search-button {
41
+ margin-inline-start: auto;
42
+ margin-inline-end: calc(-1 * var(--sw-space-4));
43
+ }
44
+
45
+ .sw-site-header-search-button:hover,
46
+ .sw-site-header-search-close:hover {
47
+ background: ${quietFill};
48
+ }
49
+
50
+ .sw-site-header-search-button:focus-visible,
51
+ .sw-site-header-search-close:focus-visible {
52
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
53
+ outline-offset: calc(-1 * var(--sw-focus-ring-width));
54
+ }
55
+
56
+ .sw-site-header-bar:has(.sw-site-header-menu[open]) > .sw-site-header-search-button {
57
+ display: none;
58
+ }
59
+
60
+ /*
61
+ * With no popover support the closed search would show in the bar below
62
+ * \`lg\`, so only the field from \`lg\` is drawn there.
63
+ */
64
+ @supports not selector(:popover-open) {
65
+ .sw-site-header-search-button,
66
+ ${search} {
67
+ display: none;
68
+ }
69
+
70
+ @media ${wide} {
71
+ ${search} {
72
+ display: block;
73
+ flex: 0 1 16rem;
74
+ margin-inline: auto 0;
75
+ min-width: 10rem;
76
+ position: relative;
77
+ }
78
+ }
79
+ }
80
+
81
+ ${search}:popover-open {
82
+ background: var(--sw-color-surface);
83
+ border: 0;
84
+ box-sizing: border-box;
85
+ color: var(--sw-color-text);
86
+ display: flex;
87
+ flex-direction: column;
88
+ font-family: var(--sw-font-sans);
89
+ height: 100dvh;
90
+ inset: 0;
91
+ margin: 0;
92
+ max-height: none;
93
+ max-width: none;
94
+ overflow: hidden;
95
+ padding: env(safe-area-inset-top, 0px) 0 0;
96
+ width: 100%;
97
+ }
98
+
99
+ .sw-site-header-search-form {
100
+ align-items: center;
101
+ border-bottom: 1px solid var(--sw-color-border);
102
+ box-sizing: border-box;
103
+ display: flex;
104
+ flex: none;
105
+ gap: var(--sw-space-2);
106
+ margin: 0;
107
+ min-height: ${compactHeight};
108
+ padding-inline: ${siteHeaderGutter.compact} var(--sw-space-2);
109
+ }
110
+
111
+ .sw-site-header-search-field {
112
+ align-items: center;
113
+ background: ${quietFill};
114
+ border: 1px solid transparent;
115
+ border-radius: var(--sw-radius-pill);
116
+ box-sizing: border-box;
117
+ color: var(--sw-color-muted);
118
+ display: flex;
119
+ flex: 1 1 auto;
120
+ gap: var(--sw-space-2);
121
+ min-height: var(--sw-control-md-min-height);
122
+ min-width: 0;
123
+ padding-inline: var(--sw-space-3);
124
+ }
125
+
126
+ .sw-site-header-search-field:focus-within {
127
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
128
+ outline-offset: var(--sw-focus-ring-offset);
129
+ }
130
+
131
+ .sw-site-header-search-icon {
132
+ display: inline-flex;
133
+ flex: none;
134
+ }
135
+
136
+ [data-theme] input.sw-site-header-search-input {
137
+ appearance: none;
138
+ background: transparent;
139
+ border: 0;
140
+ color: var(--sw-color-text);
141
+ flex: 1 1 auto;
142
+ font-family: inherit;
143
+ font-size: ${body.fontSize}px;
144
+ line-height: ${body.lineHeight}px;
145
+ margin: 0;
146
+ min-width: 0;
147
+ outline: none;
148
+ padding: 0;
149
+ }
150
+
151
+ [data-theme] input.sw-site-header-search-input:focus-visible {
152
+ outline: none;
153
+ }
154
+
155
+ [data-theme] input.sw-site-header-search-input::placeholder {
156
+ color: var(--sw-color-muted);
157
+ opacity: 1;
158
+ }
159
+
160
+ ${results}:not([hidden]) {
161
+ box-sizing: border-box;
162
+ display: flex;
163
+ flex: 1 1 auto;
164
+ flex-direction: column;
165
+ min-height: 0;
166
+ overflow-y: auto;
167
+ padding: var(--sw-space-2) ${siteHeaderGutter.compact} var(--sw-space-6);
168
+ }
169
+
170
+ .sw-site-header-search-status {
171
+ color: var(--sw-color-muted);
172
+ font-size: ${caption.fontSize}px;
173
+ line-height: ${caption.lineHeight}px;
174
+ margin: 0;
175
+ padding-block: var(--sw-space-2);
176
+ }
177
+
178
+ .sw-site-header-search-status:empty {
179
+ padding: 0;
180
+ }
181
+
182
+ .sw-site-header-search-list {
183
+ list-style: none;
184
+ margin: 0;
185
+ padding: 0;
186
+ }
187
+
188
+ ${result} {
189
+ border-bottom: 1px solid var(--sw-color-border);
190
+ color: var(--sw-color-text);
191
+ display: flex;
192
+ flex-direction: column;
193
+ gap: var(--sw-space-1);
194
+ min-height: ${touchTarget};
195
+ padding-block: var(--sw-space-3);
196
+ text-decoration: none;
197
+ }
198
+
199
+ ${result}:focus-visible {
200
+ outline: var(--sw-focus-ring-width) solid var(--sw-color-accent);
201
+ outline-offset: calc(-1 * var(--sw-focus-ring-width));
202
+ }
203
+
204
+ .sw-site-header-search-result-title {
205
+ font-size: ${label.fontSize}px;
206
+ font-weight: ${label.fontWeight};
207
+ letter-spacing: ${label.letterSpacing}px;
208
+ line-height: ${label.lineHeight}px;
209
+ }
210
+
211
+ .sw-site-header-search-result-text {
212
+ color: var(--sw-color-muted);
213
+ font-size: ${caption.fontSize}px;
214
+ line-height: ${caption.lineHeight}px;
215
+ }`;
216
+ }
217
+ /*
218
+ * From \`lg\`: the popover is laid out in the bar as a plain box, after the
219
+ * destinations and before the actions, pushed to the end with them; the
220
+ * buttons are gone, and the field is an sm pill with a hairline. The
221
+ * results drop down under the field's end as a raised panel over the page,
222
+ * each a row that takes the quiet fill on hover.
223
+ */
224
+ function wideRules() {
225
+ return `@media ${wide} {
226
+ .sw-site-header-search-button,
227
+ .sw-site-header-search-close {
228
+ display: none;
229
+ }
230
+
231
+ ${search}[popover]:not(:popover-open) {
232
+ background: transparent;
233
+ border: 0;
234
+ color: inherit;
235
+ display: block;
236
+ flex: 0 1 16rem;
237
+ height: auto;
238
+ min-width: 10rem;
239
+ inset: auto;
240
+ margin-inline: auto 0;
241
+ max-height: none;
242
+ max-width: none;
243
+ overflow: visible;
244
+ padding: 0;
245
+ position: relative;
246
+ width: auto;
247
+ }
248
+
249
+ .sw-site-header-search-form {
250
+ border: 0;
251
+ min-height: 0;
252
+ padding: 0;
253
+ }
254
+
255
+ .sw-site-header-search-field {
256
+ background: var(--sw-color-surface);
257
+ border-color: var(--sw-color-border);
258
+ min-height: var(--sw-control-sm-min-height);
259
+ }
260
+
261
+ [data-theme] input.sw-site-header-search-input {
262
+ font-size: ${label.fontSize}px;
263
+ line-height: ${label.lineHeight}px;
264
+ }
265
+
266
+ ${results}:not([hidden]) {
267
+ background: var(--sw-color-surface);
268
+ border: 1px solid var(--sw-color-border);
269
+ border-radius: var(--sw-radius-lg);
270
+ box-shadow: var(--sw-elevation-md);
271
+ inset-inline-end: 0;
272
+ max-height: min(70vh, 32rem);
273
+ padding: var(--sw-space-2);
274
+ position: absolute;
275
+ top: calc(100% + var(--sw-space-2));
276
+ width: min(28rem, calc(100vw - 2 * ${siteHeaderGutter.wide}));
277
+ ${zIndex('popup')}
278
+ }
279
+
280
+ .sw-site-header-search-status {
281
+ padding-inline: var(--sw-space-3);
282
+ }
283
+
284
+ ${result} {
285
+ border: 0;
286
+ border-radius: var(--sw-radius-md);
287
+ min-height: 0;
288
+ padding: var(--sw-space-2) var(--sw-space-3);
289
+ }
290
+
291
+ ${result}:hover {
292
+ background: ${quietFill};
293
+ }
294
+ }
295
+
296
+ @media ${wide} and ${coarsePointerQuery} {
297
+ .sw-site-header-search-field { min-height: ${touchTarget}; }
298
+ }`;
299
+ }
300
+ export function cssSiteHeaderSearchRules() {
301
+ return `${compactRules()}
302
+
303
+ ${wideRules()}
304
+
305
+ @media (forced-colors: active) {
306
+ .sw-site-header-search-field,
307
+ ${results}:not([hidden]) {
308
+ border: 1px solid CanvasText;
309
+ }
310
+
311
+ .sw-site-header-search-button,
312
+ .sw-site-header-search-close {
313
+ border: 1px solid ButtonText;
314
+ }
315
+
316
+ ${result} { color: LinkText; }
317
+ }`;
318
+ }
319
+ export function siteHeaderSearchClassCatalog() {
320
+ return [
321
+ 'sw-site-header-search-button',
322
+ 'sw-site-header-search',
323
+ 'sw-site-header-search-form',
324
+ 'sw-site-header-search-field',
325
+ 'sw-site-header-search-icon',
326
+ 'sw-site-header-search-input',
327
+ 'sw-site-header-search-close',
328
+ 'sw-site-header-search-results',
329
+ 'sw-site-header-search-status',
330
+ 'sw-site-header-search-list',
331
+ 'sw-site-header-search-row',
332
+ 'sw-site-header-search-result',
333
+ 'sw-site-header-search-result-title',
334
+ 'sw-site-header-search-result-text',
335
+ ];
336
+ }
@@ -1,5 +1,6 @@
1
1
  import { typographyVariants } from '@scalewing/tokens';
2
2
  import { cssSiteHeaderAnchorRules } from './css-site-header-anchors.js';
3
+ import { cssSiteHeaderSearchRules, siteHeaderSearchClassCatalog, } from './css-site-header-search.js';
3
4
  import { cssSiteHeaderSkipLinkRules } from './css-site-header-skip-link.js';
4
5
  import { quietFill } from './quiet-fill.js';
5
6
  import { siteHeaderBarMaxWidth, siteHeaderCompactHeight as compactHeight, siteHeaderGutter, siteHeaderGutterQuery, siteHeaderWideHeight as wideHeight, siteHeaderWideQuery as wide, } from './site-header-geometry.js';
@@ -123,7 +124,8 @@ function barRules() {
123
124
  * rows with hairlines and the menu's actions at the panel's foot. It
124
125
  * scrolls on its own when the window is short. While it is open the bar's
125
126
  * compact actions step aside, since the menu holds its own actions, so the
126
- * bar shows only the brand and the close button.
127
+ * bar shows only the brand and the close button (the search button
128
+ * steps aside too).
127
129
  */
128
130
  function menuRules() {
129
131
  return `.sw-site-header-menu > summary {
@@ -227,6 +229,8 @@ ${cssSiteHeaderSkipLinkRules()}
227
229
 
228
230
  ${cssSiteHeaderAnchorRules()}
229
231
 
232
+ ${cssSiteHeaderSearchRules()}
233
+
230
234
  /*
231
235
  * Forced colours drop box shadows, so the current destination's bar is a
232
236
  * thick underline there.
@@ -273,5 +277,6 @@ export function siteHeaderClassCatalog() {
273
277
  'sw-site-header-panel',
274
278
  'sw-site-header-menu-nav',
275
279
  'sw-site-header-menu-actions',
280
+ ...siteHeaderSearchClassCatalog(),
276
281
  ];
277
282
  }
@@ -0,0 +1,6 @@
1
+ import { type Breakpoint } from './breakpoints.js';
2
+ /** The class that puts a TaskList's actions under the words below `breakpoint`. */
3
+ export declare function taskListActionBelowClass(breakpoint: Breakpoint): string;
4
+ /** A TaskList's optional layouts: numbered open tasks, actions under the words. */
5
+ export declare function cssTaskListLayoutClasses(): string;
6
+ export declare function taskListLayoutClassCatalog(): string[];
@@ -0,0 +1,67 @@
1
+ import { typographyVariants } from '@scalewing/tokens';
2
+ import { breakpointQuery, breakpoints, } from './breakpoints.js';
3
+ const label = typographyVariants.label;
4
+ const caption = typographyVariants.caption;
5
+ /** Where the words start: the marker's side (space 5) and the row's gap (space 3). */
6
+ const wordsStart = 'calc(var(--sw-space-5) + var(--sw-space-3))';
7
+ const openMarker = ':is(.sw-task-list-item-todo, .sw-task-list-item-next) .sw-task-list-marker';
8
+ /** The class that puts a TaskList's actions under the words below `breakpoint`. */
9
+ export function taskListActionBelowClass(breakpoint) {
10
+ return `sw-task-list-action-below-${breakpoint}`;
11
+ }
12
+ /*
13
+ * A numbered list draws an open task's place inside its ring, at the
14
+ * caption size and the label weight: a todo task's number in the muted
15
+ * colour on the hairline ring, the next task's in the accent on the accent
16
+ * ring, its dot dropped. Forced colours draw the numbers in CanvasText.
17
+ */
18
+ function numberedRules() {
19
+ return `.sw-task-list-numbered ${openMarker} {
20
+ font-family: var(--sw-font-sans);
21
+ font-size: ${caption.fontSize}px;
22
+ font-weight: ${label.fontWeight};
23
+ line-height: 1;
24
+ }
25
+
26
+ .sw-task-list-numbered .sw-task-list-item-todo .sw-task-list-marker {
27
+ color: var(--sw-color-muted);
28
+ }
29
+
30
+ .sw-task-list-numbered .sw-task-list-item-next .sw-task-list-marker {
31
+ color: var(--sw-color-accent);
32
+ }
33
+
34
+ .sw-task-list-numbered .sw-task-list-item-next .sw-task-list-marker::after {
35
+ content: none;
36
+ }
37
+
38
+ @media (forced-colors: active) {
39
+ .sw-task-list-numbered ${openMarker} { color: CanvasText; }
40
+ }`;
41
+ }
42
+ /*
43
+ * Below the breakpoint each action takes a line of its own under the
44
+ * words, starting where they start and as wide as them, and its control
45
+ * stretches to fill that line.
46
+ */
47
+ function actionBelowRules(breakpoint) {
48
+ const list = `.${taskListActionBelowClass(breakpoint)}`;
49
+ return `@media ${breakpointQuery('below', breakpoint)} {
50
+ ${list} .sw-task-list-action {
51
+ display: flex;
52
+ flex-basis: calc(100% - ${wordsStart});
53
+ margin-inline-start: ${wordsStart};
54
+ }
55
+ ${list} .sw-task-list-action > * { flex: 1 1 auto; }
56
+ }`;
57
+ }
58
+ /** A TaskList's optional layouts: numbered open tasks, actions under the words. */
59
+ export function cssTaskListLayoutClasses() {
60
+ return [numberedRules(), ...breakpoints.map(actionBelowRules)].join('\n\n');
61
+ }
62
+ export function taskListLayoutClassCatalog() {
63
+ return [
64
+ 'sw-task-list-numbered',
65
+ ...breakpoints.map(taskListActionBelowClass),
66
+ ];
67
+ }