@aitrien/motifspec 1.26.0 → 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 +18 -0
- package/dist/codex.css +165 -2
- package/dist/codex.js +239 -3
- package/dist/contrast.md +9 -1
- package/dist/icons.svg +1 -0
- package/dist/tokens.css +5 -1
- package/dist/tokens.js +83 -1
- package/dist/tokens.json +83 -1
- package/docs/components/_groups.json +1 -0
- package/docs/components/button-and-link.md +19 -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/field.md +181 -0
- package/docs/components/icon.md +3 -0
- package/docs/hugo.md +1 -0
- package/docs/layouts/dashboard.md +3 -3
- package/icons/manifest.json +8 -4
- package/icons/svg/calendar_today.svg +1 -0
- package/layouts/_partials/motifspec/field.html +53 -0
- package/package.json +1 -1
- package/scripts/lib.mjs +4 -0
- package/tokens/color.json +74 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of MotifSpec (named brand-codex until 1.10.0), newest first. Entries before 1.10.0 keep the names they were released under. Versions follow the rules in `CONVENTIONS.md`: renaming or removing a semantic token is major, adding tokens, components or icons is minor, and changing a value or fixing a description is a patch. `npm run build` fails if the version in `package.json` has no entry here.
|
|
4
4
|
|
|
5
|
+
## [1.27.0] - 2026-11-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Field (`field.md`, shared): a text field, select or text area with its label on the top border. The label rests where the text goes and moves to the border when the field has focus or a value, with no script. Focus doubles the field's border in `color.accent.border`, with no ring outside it. Hints, errors, "(optional)", disabled fields, `--mono` and `--short` controls, and fieldsets. In Hugo, `motifspec/field.html` writes one.
|
|
9
|
+
- Choice (`choice.md`, shared): checkboxes, radio buttons and switches (a checkbox with `role="switch"`), as native inputs in the accent colour.
|
|
10
|
+
- Date picker (`date-picker.md`, shared): a date field with a calendar, opened from a button `codex.js` shows. The month and the year open grids of their own (twenty years at a time), the keyboard moves through each, and the calendar is a fixed size, opening above the field when there's more room there and scrolling with it.
|
|
11
|
+
- Dialog (`dialog.md`, shared): a native `<dialog>` with a head, a close button and the actions in a recessed band; `--wide` for a form. `[data-dialog-open]` and `[data-dialog-close]` open and close it, and a click outside closes it unless it has `data-dialog-keep`. On a phone it docks to the bottom, and a form fills the screen.
|
|
12
|
+
- A danger button (`cx-button--danger`) for confirming a destructive action in a dialog, on the new `color.status.danger.fill`, `color.status.danger.fill-hover` and `color.text.on-danger`.
|
|
13
|
+
- `color.surface.selected` for the chosen item among options, such as a calendar's date, and the `calendar` icon.
|
|
14
|
+
- A Forms group on the Components page, and the dialog in Messages.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- The dashboard layout's form controls and dialog are available.
|
|
18
|
+
- A component preview grows while a dialog or calendar is open in it.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- An alert no longer takes the full height of a flex column, such as a dashboard's main region.
|
|
22
|
+
|
|
5
23
|
## [1.26.0] - 2026-11-18
|
|
6
24
|
|
|
7
25
|
### Added
|
package/dist/codex.css
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@font-face { font-family: "Geist Mono"; src: url("../fonts/geist-mono-latin-wght.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
3
3
|
@font-face { font-family: "Yarndings 12"; src: url("../fonts/yarndings-12-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
|
|
4
4
|
|
|
5
|
-
/* MotifSpec 1.
|
|
5
|
+
/* MotifSpec 1.27.0 — generated from tokens/*.json. Do not edit.
|
|
6
6
|
Themes: semantic colours use light-dark(); color-scheme follows the system unless
|
|
7
7
|
<html data-theme="light|dark"> pins it. --cx-primitive-* are for this file only. */
|
|
8
8
|
:root {
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
--cx-color-surface-hover: light-dark(var(--cx-primitive-color-ash-100), var(--cx-primitive-color-ash-800));
|
|
105
105
|
--cx-color-surface-inverse: light-dark(var(--cx-primitive-color-ash-900), var(--cx-primitive-color-ash-100));
|
|
106
106
|
--cx-color-surface-highlight: light-dark(var(--cx-primitive-color-sap-100), var(--cx-primitive-color-sap-800));
|
|
107
|
+
--cx-color-surface-selected: light-dark(var(--cx-primitive-color-sap-100), var(--cx-primitive-color-sap-800));
|
|
107
108
|
|
|
108
109
|
/* color.text */
|
|
109
110
|
--cx-color-text-primary: light-dark(var(--cx-primitive-color-ash-950), var(--cx-primitive-color-ash-100));
|
|
@@ -112,6 +113,7 @@
|
|
|
112
113
|
--cx-color-text-accent: light-dark(var(--cx-primitive-color-sap-700), var(--cx-primitive-color-sap-300));
|
|
113
114
|
--cx-color-text-inverse: light-dark(var(--cx-primitive-color-ash-50), var(--cx-primitive-color-ash-900));
|
|
114
115
|
--cx-color-text-on-accent: light-dark(var(--cx-primitive-color-ash-0), var(--cx-primitive-color-ash-1000));
|
|
116
|
+
--cx-color-text-on-danger: light-dark(var(--cx-primitive-color-ash-0), var(--cx-primitive-color-ash-1000));
|
|
115
117
|
|
|
116
118
|
/* color.link */
|
|
117
119
|
--cx-color-link-rest: light-dark(var(--cx-primitive-color-sap-800), var(--cx-primitive-color-sap-300));
|
|
@@ -145,6 +147,8 @@
|
|
|
145
147
|
--cx-color-status-danger-text: light-dark(var(--cx-primitive-color-madder-700), var(--cx-primitive-color-madder-300));
|
|
146
148
|
--cx-color-status-danger-surface: light-dark(var(--cx-primitive-color-madder-50), var(--cx-primitive-color-madder-950));
|
|
147
149
|
--cx-color-status-danger-border: light-dark(var(--cx-primitive-color-madder-600), var(--cx-primitive-color-madder-400));
|
|
150
|
+
--cx-color-status-danger-fill: light-dark(var(--cx-primitive-color-madder-700), var(--cx-primitive-color-madder-300));
|
|
151
|
+
--cx-color-status-danger-fill-hover: light-dark(var(--cx-primitive-color-madder-800), var(--cx-primitive-color-madder-200));
|
|
148
152
|
--cx-color-status-info-text: light-dark(var(--cx-primitive-color-woad-700), var(--cx-primitive-color-woad-300));
|
|
149
153
|
--cx-color-status-info-surface: light-dark(var(--cx-primitive-color-woad-50), var(--cx-primitive-color-woad-950));
|
|
150
154
|
--cx-color-status-info-border: light-dark(var(--cx-primitive-color-woad-600), var(--cx-primitive-color-woad-400));
|
|
@@ -1007,6 +1011,8 @@ a.cx-tag:hover { border-color: var(--cx-color-accent-border); color: var(--cx-co
|
|
|
1007
1011
|
.cx-button:hover { background: var(--cx-color-surface-hover); }
|
|
1008
1012
|
.cx-button--primary { border-color: var(--cx-color-accent-fill-rest); background: var(--cx-color-accent-fill-rest); color: var(--cx-color-text-on-accent); }
|
|
1009
1013
|
.cx-button--primary:hover { border-color: var(--cx-color-accent-fill-hover); background: var(--cx-color-accent-fill-hover); }
|
|
1014
|
+
.cx-button--danger { border-color: var(--cx-color-status-danger-fill); background: var(--cx-color-status-danger-fill); color: var(--cx-color-text-on-danger); }
|
|
1015
|
+
.cx-button--danger:hover { border-color: var(--cx-color-status-danger-fill-hover); background: var(--cx-color-status-danger-fill-hover); }
|
|
1010
1016
|
.cx-button[disabled], .cx-button[aria-disabled="true"] { cursor: not-allowed; border-style: dashed; background: transparent; color: var(--cx-color-text-muted); }
|
|
1011
1017
|
.cx-button--sm { min-height: var(--cx-size-target-min); padding-inline: var(--cx-space-inset-md); }
|
|
1012
1018
|
.cx-button__arrow { display: inline-block; transition: transform var(--cx-motion-duration-fast) var(--cx-motion-easing-standard); }
|
|
@@ -1186,7 +1192,7 @@ a.cx-tag:hover { border-color: var(--cx-color-accent-border); color: var(--cx-co
|
|
|
1186
1192
|
display: flex; align-items: flex-start; gap: var(--cx-space-inline-md); padding: var(--cx-space-inset-md);
|
|
1187
1193
|
border: var(--cx-border-width-hairline) solid var(--_border); border-block-start-width: var(--cx-border-width-emphasis);
|
|
1188
1194
|
background: var(--_bg); color: var(--cx-color-text-primary); line-height: var(--cx-font-line-height-ui);
|
|
1189
|
-
|
|
1195
|
+
width: 100%; /* a whole row in a flex row too; flex-basis would take the full height in a flex column */
|
|
1190
1196
|
}
|
|
1191
1197
|
.cx-alert[hidden] { display: none; }
|
|
1192
1198
|
:where(main) > .cx-alert { margin-block-end: var(--cx-space-stack-lg); }
|
|
@@ -1229,6 +1235,163 @@ a.cx-tag:hover { border-color: var(--cx-color-accent-border); color: var(--cx-co
|
|
|
1229
1235
|
.cx-toasts .cx-toast.is-shown { opacity: 1; transform: none; }
|
|
1230
1236
|
.cx-toasts .cx-toast.is-leaving { transition-timing-function: var(--cx-motion-easing-exit); }
|
|
1231
1237
|
|
|
1238
|
+
/* ------------------------------------------------------------ field (field.md) */
|
|
1239
|
+
/* A text field, select or text area with its label on the top border. The label rests where the text goes and moves
|
|
1240
|
+
up to the border when the field has focus or a value: the control's placeholder is " " (or an example), so
|
|
1241
|
+
:placeholder-shown means empty. The label's lower half is the field's own surface, hiding the border behind it,
|
|
1242
|
+
and its upper half is clear, so it sits on whatever the field is on. */
|
|
1243
|
+
.cx-field { display: flex; flex-direction: column; gap: var(--cx-space-stack-xs); width: 100%; min-width: 0; } /* fills its container, in a flex row too */
|
|
1244
|
+
.cx-field__box { position: relative; display: flex; margin-block-start: var(--cx-space-inset-xs); --_field: var(--cx-color-surface-raised); }
|
|
1245
|
+
.cx-field__control {
|
|
1246
|
+
flex: 1; min-width: 0; width: 100%; margin: 0; min-height: calc(var(--cx-size-target-control) + var(--cx-space-inset-xs) * 2);
|
|
1247
|
+
padding: var(--cx-space-inset-xs) var(--cx-space-inset-sm); border: var(--cx-border-width-hairline) solid var(--cx-color-border-strong); border-radius: var(--cx-radius-control);
|
|
1248
|
+
background: var(--_field); color: var(--cx-color-text-primary); font: inherit; font-size: var(--cx-font-size-body); line-height: var(--cx-font-line-height-ui);
|
|
1249
|
+
}
|
|
1250
|
+
.cx-field__control--mono { font-family: var(--cx-font-family-mono); font-size: var(--cx-font-size-small); }
|
|
1251
|
+
.cx-field__control--short { flex: none; max-width: var(--cx-size-column-sidebar); }
|
|
1252
|
+
textarea.cx-field__control { min-height: calc(var(--cx-size-target-control) * 2.5); resize: vertical; }
|
|
1253
|
+
select.cx-field__control { appearance: none; padding-inline-end: calc(var(--cx-space-inset-sm) * 2 + var(--cx-size-icon-md)); cursor: pointer; }
|
|
1254
|
+
.cx-field__box > .cx-icon { position: absolute; inset-inline-end: var(--cx-space-inset-sm); top: 50%; translate: 0 -50%; color: var(--cx-color-text-secondary); pointer-events: none; }
|
|
1255
|
+
.cx-field__control::placeholder { color: transparent; }
|
|
1256
|
+
.cx-field__control:focus::placeholder { color: var(--cx-color-text-muted); }
|
|
1257
|
+
.cx-field__control:hover:not(:disabled, :focus-visible) { border-color: var(--cx-color-text-secondary); }
|
|
1258
|
+
/* focus: the field's own border turns accent and doubles, with no ring outside it; the inner line changes from the
|
|
1259
|
+
field's surface to accent, so the change shows without colour vision too */
|
|
1260
|
+
.cx-field__control:focus-visible { outline: none; border-color: var(--cx-color-accent-border); box-shadow: inset 0 0 0 var(--cx-border-width-hairline) var(--cx-color-accent-border); }
|
|
1261
|
+
.cx-field__control[aria-invalid="true"]:not(:focus-visible) { border-color: var(--cx-color-status-danger-border); box-shadow: inset 0 0 0 var(--cx-border-width-hairline) var(--cx-color-status-danger-border); }
|
|
1262
|
+
.cx-field__control:disabled { --_field: var(--cx-color-surface-sunken); color: var(--cx-color-text-muted); border-style: dashed; cursor: not-allowed; }
|
|
1263
|
+
.cx-field__box:has(.cx-field__control:disabled) { --_field: var(--cx-color-surface-sunken); }
|
|
1264
|
+
.cx-field__label {
|
|
1265
|
+
position: absolute; inset-inline-start: calc(var(--cx-space-inset-sm) + var(--cx-border-width-hairline)); top: 50%; translate: 0 -50%;
|
|
1266
|
+
max-width: calc(100% - var(--cx-space-inset-sm) * 2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; pointer-events: none;
|
|
1267
|
+
color: var(--cx-color-text-secondary); font-size: var(--cx-font-size-body); line-height: var(--cx-font-line-height-ui);
|
|
1268
|
+
transition-property: top, translate, font-size, color, padding, margin; transition-duration: var(--cx-motion-duration-base); transition-timing-function: var(--cx-motion-easing-standard);
|
|
1269
|
+
}
|
|
1270
|
+
.cx-field__box--area > .cx-field__label { top: var(--cx-space-inset-sm); translate: 0 0; }
|
|
1271
|
+
.cx-field__control:is(:focus, :not(:placeholder-shown), :autofill, :disabled) + .cx-field__label, select.cx-field__control + .cx-field__label {
|
|
1272
|
+
top: 0; translate: 0 -50%; font-size: var(--cx-font-size-label); padding-inline: var(--cx-space-inset-xs); margin-inline-start: calc(var(--cx-space-inset-xs) * -1);
|
|
1273
|
+
background: linear-gradient(to bottom, transparent 50%, var(--_field) 50%);
|
|
1274
|
+
}
|
|
1275
|
+
.cx-field__control:focus + .cx-field__label { color: var(--cx-color-text-accent); font-weight: var(--cx-font-weight-strong); }
|
|
1276
|
+
.cx-field__control[aria-invalid="true"] + .cx-field__label { color: var(--cx-color-status-danger-text); }
|
|
1277
|
+
.cx-field__optional { color: var(--cx-color-text-muted); }
|
|
1278
|
+
.cx-field__hint { margin: 0; font-size: var(--cx-font-size-small); color: var(--cx-color-text-secondary); line-height: var(--cx-font-line-height-ui); }
|
|
1279
|
+
.cx-field__error { margin: 0; display: flex; align-items: center; gap: var(--cx-space-inline-xs); font-size: var(--cx-font-size-small); font-weight: var(--cx-font-weight-strong); color: var(--cx-color-status-danger-text); line-height: var(--cx-font-line-height-ui); }
|
|
1280
|
+
.cx-field__error[hidden] { display: none; }
|
|
1281
|
+
.cx-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--cx-space-stack-md); }
|
|
1282
|
+
.cx-fieldset > legend { padding: 0; margin-block-end: var(--cx-space-stack-sm); font-size: var(--cx-font-size-body); font-weight: var(--cx-font-weight-strong); line-height: var(--cx-font-line-height-ui); }
|
|
1283
|
+
@media (prefers-reduced-motion: reduce) { .cx-field__label { transition: none; } }
|
|
1284
|
+
|
|
1285
|
+
/* ------------------------------------------------------------ choice (choice.md) */
|
|
1286
|
+
/* A checkbox, radio button or switch with its label beside it: native inputs, in the accent colour */
|
|
1287
|
+
.cx-choices { display: flex; flex-direction: column; gap: var(--cx-space-stack-sm); }
|
|
1288
|
+
.cx-choice { display: flex; align-items: flex-start; gap: var(--cx-space-inline-sm); min-height: var(--cx-size-target-min); font-size: var(--cx-font-size-small); line-height: var(--cx-font-line-height-ui); cursor: pointer; }
|
|
1289
|
+
.cx-choice:has(input:disabled) { color: var(--cx-color-text-muted); cursor: not-allowed; }
|
|
1290
|
+
.cx-choice__text { display: flex; flex-direction: column; gap: var(--cx-space-stack-xs); padding-block-start: var(--cx-border-width-emphasis); }
|
|
1291
|
+
.cx-choice input { flex: none; margin: 0; cursor: inherit; }
|
|
1292
|
+
.cx-choice input:is([type="checkbox"]:not([role="switch"]), [type="radio"]) { width: var(--cx-size-icon-md); height: var(--cx-size-icon-md); accent-color: var(--cx-color-accent-fill-rest); }
|
|
1293
|
+
.cx-choice input[role="switch"] {
|
|
1294
|
+
appearance: none; width: var(--cx-size-target-touch); height: var(--cx-size-target-min); border-radius: var(--cx-radius-pill);
|
|
1295
|
+
border: var(--cx-border-width-hairline) solid var(--cx-color-border-strong); background-color: var(--cx-color-surface-sunken);
|
|
1296
|
+
background-image: radial-gradient(circle closest-side, var(--cx-color-text-secondary) 70%, transparent 74%);
|
|
1297
|
+
background-size: var(--cx-size-target-min) 100%; background-repeat: no-repeat; background-position: left center;
|
|
1298
|
+
transition: background-position var(--cx-motion-duration-fast) var(--cx-motion-easing-standard);
|
|
1299
|
+
}
|
|
1300
|
+
.cx-choice input[role="switch"]:checked { border-color: var(--cx-color-accent-fill-rest); background-color: var(--cx-color-accent-fill-rest); background-image: radial-gradient(circle closest-side, var(--cx-color-text-on-accent) 70%, transparent 74%); background-position: right center; }
|
|
1301
|
+
.cx-choice input[role="switch"]:disabled { border-style: dashed; }
|
|
1302
|
+
.cx-choice input:focus-visible { outline: var(--cx-border-focus-width) solid var(--cx-color-focus-ring); outline-offset: var(--cx-border-focus-offset); }
|
|
1303
|
+
|
|
1304
|
+
/* ------------------------------------------------------------ date picker (date-picker.md) */
|
|
1305
|
+
/* A date field with a button that opens a calendar: codex.js shows the button and builds one calendar for the page.
|
|
1306
|
+
The calendar is a fixed size (seven touch-size days), so neither arrow nor either button moves as months change. */
|
|
1307
|
+
.cx-field__box--date > .cx-field__control { border-inline-end: 0; }
|
|
1308
|
+
.cx-date__button {
|
|
1309
|
+
flex: none; display: grid; place-items: center; width: calc(var(--cx-size-target-control) + var(--cx-space-inset-xs) * 2); padding: 0;
|
|
1310
|
+
border: var(--cx-border-width-hairline) solid var(--cx-color-border-strong); background: var(--_field); color: var(--cx-color-text-secondary); cursor: pointer;
|
|
1311
|
+
}
|
|
1312
|
+
.cx-date__button[hidden] { display: none; }
|
|
1313
|
+
.cx-field__box--date:has(.cx-date__button[hidden]) > .cx-field__control { border-inline-end: var(--cx-border-width-hairline) solid var(--cx-color-border-strong); }
|
|
1314
|
+
.cx-date__button:hover { background: var(--cx-color-surface-hover); color: var(--cx-color-text-primary); }
|
|
1315
|
+
.cx-date__button:focus-visible { outline: none; border-color: var(--cx-color-accent-border); box-shadow: inset 0 0 0 var(--cx-border-width-hairline) var(--cx-color-accent-border); color: var(--cx-color-text-primary); }
|
|
1316
|
+
.cx-calendar {
|
|
1317
|
+
position: absolute; inset: auto; box-sizing: content-box; width: calc(var(--cx-size-target-touch) * 7); margin: 0; padding: var(--cx-space-inset-sm);
|
|
1318
|
+
border: var(--cx-border-width-hairline) solid var(--cx-color-border-strong); background: var(--cx-color-surface-raised); color: var(--cx-color-text-primary);
|
|
1319
|
+
}
|
|
1320
|
+
.cx-calendar__head { display: grid; grid-template-columns: var(--cx-size-target-control) minmax(0, 1fr) var(--cx-size-target-control); align-items: center; padding-block-end: var(--cx-space-inset-xs); }
|
|
1321
|
+
.cx-calendar__pickers { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--cx-space-inline-xs); }
|
|
1322
|
+
.cx-calendar__nav, .cx-calendar__pick, .cx-calendar__day, .cx-calendar__cell, .cx-calendar__foot button {
|
|
1323
|
+
margin: 0; padding: 0; border: 0; border-radius: var(--cx-radius-pill); background: transparent; color: var(--cx-color-text-primary); font: inherit; cursor: pointer;
|
|
1324
|
+
}
|
|
1325
|
+
.cx-calendar__nav { display: grid; place-items: center; width: var(--cx-size-target-control); height: var(--cx-size-target-control); color: var(--cx-color-text-secondary); }
|
|
1326
|
+
.cx-calendar__pick { display: inline-flex; align-items: center; justify-content: center; gap: var(--cx-space-inline-xs); width: 100%; min-height: var(--cx-size-target-control); white-space: nowrap; font-weight: var(--cx-font-weight-strong); font-variant-numeric: tabular-nums; }
|
|
1327
|
+
.cx-calendar__pick .cx-icon { color: var(--cx-color-text-secondary); transition: transform var(--cx-motion-duration-fast) var(--cx-motion-easing-standard); }
|
|
1328
|
+
.cx-calendar__pick[aria-expanded="true"] { background: var(--cx-color-surface-selected); }
|
|
1329
|
+
.cx-calendar__pick[aria-expanded="true"] .cx-icon { transform: rotate(180deg); }
|
|
1330
|
+
.cx-calendar__grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
|
|
1331
|
+
.cx-calendar__grid th { padding-block: var(--cx-space-inset-xs); font-family: var(--cx-font-family-mono); font-size: var(--cx-font-size-label); font-weight: var(--cx-font-weight-ui); letter-spacing: var(--cx-font-tracking-label); text-transform: uppercase; color: var(--cx-color-text-muted); }
|
|
1332
|
+
.cx-calendar__grid td { padding: 0; }
|
|
1333
|
+
.cx-calendar__day { display: grid; place-items: center; width: var(--cx-size-target-touch); height: var(--cx-size-target-touch); font-size: var(--cx-font-size-small); font-variant-numeric: tabular-nums; }
|
|
1334
|
+
.cx-calendar__day.is-other { color: var(--cx-color-text-muted); }
|
|
1335
|
+
.cx-calendar__list { display: grid; gap: var(--cx-space-inset-xs); align-content: center; min-height: calc(var(--cx-size-target-touch) * 6 + var(--cx-font-size-label) * 1.6 + var(--cx-space-inset-xs) * 2); }
|
|
1336
|
+
.cx-calendar__list[hidden], .cx-calendar__grid[hidden] { display: none; }
|
|
1337
|
+
.cx-calendar__list--months { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1338
|
+
.cx-calendar__list--years { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1339
|
+
.cx-calendar__cell { min-height: var(--cx-size-target-control); font-size: var(--cx-font-size-small); font-variant-numeric: tabular-nums; }
|
|
1340
|
+
.cx-calendar__nav:hover, .cx-calendar__pick:hover, .cx-calendar__day:hover, .cx-calendar__cell:hover { background: var(--cx-color-surface-hover); color: var(--cx-color-text-primary); }
|
|
1341
|
+
.cx-calendar :is(.cx-calendar__day, .cx-calendar__cell)[aria-current="date"] { box-shadow: inset 0 0 0 var(--cx-border-width-hairline) var(--cx-color-border-strong); font-weight: var(--cx-font-weight-strong); }
|
|
1342
|
+
.cx-calendar :is(.cx-calendar__day, .cx-calendar__cell)[aria-pressed="true"] { background: var(--cx-color-surface-selected); font-weight: var(--cx-font-weight-strong); }
|
|
1343
|
+
.cx-calendar__foot { display: flex; justify-content: space-between; gap: var(--cx-space-inline-sm); margin-block-start: var(--cx-space-inset-xs); padding-block-start: var(--cx-space-inset-xs); border-block-start: var(--cx-border-width-hairline) solid var(--cx-color-border-subtle); }
|
|
1344
|
+
.cx-calendar__foot button { min-height: var(--cx-size-target-control); padding-inline: var(--cx-space-inset-sm); border-radius: 0; color: var(--cx-color-text-accent); font-size: var(--cx-font-size-small); font-weight: var(--cx-font-weight-strong); }
|
|
1345
|
+
.cx-calendar__foot button:hover { text-decoration: underline; }
|
|
1346
|
+
.cx-calendar button:focus-visible { outline: var(--cx-border-focus-width) solid var(--cx-color-focus-ring); outline-offset: calc(var(--cx-border-focus-width) * -1); }
|
|
1347
|
+
@media (prefers-reduced-motion: reduce) { .cx-calendar__pick .cx-icon { transition: none; } }
|
|
1348
|
+
|
|
1349
|
+
/* ------------------------------------------------------------ dialog (dialog.md) */
|
|
1350
|
+
/* A native <dialog> opened with showModal(): a head with the title and a close button, the body, and the actions in a
|
|
1351
|
+
recessed band. It fades and rises in; on a phone it docks to the bottom, and a wide one (a form) fills the screen. */
|
|
1352
|
+
.cx-dialog {
|
|
1353
|
+
width: min(100% - 2 * var(--cx-space-gutter-page), var(--cx-size-measure-caption));
|
|
1354
|
+
padding: 0; border: var(--cx-border-width-hairline) solid var(--cx-color-border-strong); background: var(--cx-color-surface-raised); color: var(--cx-color-text-primary);
|
|
1355
|
+
flex-direction: column;
|
|
1356
|
+
}
|
|
1357
|
+
.cx-dialog:modal { max-height: calc(100% - 2 * var(--cx-space-gutter-page)); overflow: hidden; } /* the window's height, only when open */
|
|
1358
|
+
.cx-dialog--wide { width: min(100% - 2 * var(--cx-space-gutter-page), 1.6 * var(--cx-size-column-card)); }
|
|
1359
|
+
.cx-dialog[open] { display: flex; }
|
|
1360
|
+
.cx-dialog > form { display: contents; }
|
|
1361
|
+
.cx-dialog::backdrop { background: color-mix(in srgb, var(--cx-color-scrim) var(--cx-color-wash-scrim), transparent); }
|
|
1362
|
+
.cx-dialog__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--cx-space-inline-sm); padding: var(--cx-space-inset-md) var(--cx-space-inset-lg); border-block-end: var(--cx-border-width-hairline) solid var(--cx-color-border-subtle); }
|
|
1363
|
+
/* two classes, so an article's heading styles (.cx-prose h2) don't reach into a dialog placed in one */
|
|
1364
|
+
.cx-dialog .cx-dialog__title { margin: 0; padding: 0; border: 0; font-size: var(--cx-font-size-heading-4); font-weight: var(--cx-font-weight-heading); line-height: var(--cx-font-line-height-heading); letter-spacing: normal; text-wrap: balance; }
|
|
1365
|
+
.cx-dialog .cx-dialog__head > * { margin-block: 0; }
|
|
1366
|
+
.cx-dialog__close {
|
|
1367
|
+
flex: none; display: grid; place-items: center; width: var(--cx-size-target-control); height: var(--cx-size-target-control); margin-inline-end: calc(var(--cx-space-inset-sm) * -1);
|
|
1368
|
+
padding: 0; border: 0; border-radius: var(--cx-radius-pill); background: transparent; color: var(--cx-color-text-secondary); cursor: pointer;
|
|
1369
|
+
}
|
|
1370
|
+
.cx-dialog__close:hover { background: var(--cx-color-surface-hover); color: var(--cx-color-text-primary); }
|
|
1371
|
+
.cx-dialog__close:focus-visible { outline: var(--cx-border-focus-width) solid var(--cx-color-focus-ring); outline-offset: calc(var(--cx-border-focus-width) * -1); }
|
|
1372
|
+
.cx-dialog__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--cx-space-stack-md); padding: var(--cx-space-inset-lg); }
|
|
1373
|
+
.cx-dialog .cx-dialog__body > p { margin: 0; color: var(--cx-color-text-secondary); max-width: var(--cx-size-measure-prose); }
|
|
1374
|
+
.cx-dialog__actions { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--cx-space-inline-sm); padding: var(--cx-space-inset-md) var(--cx-space-inset-lg); border-block-start: var(--cx-border-width-hairline) solid var(--cx-color-border-subtle); background: var(--cx-color-surface-sunken); }
|
|
1375
|
+
.cx-dialog, .cx-dialog::backdrop {
|
|
1376
|
+
transition: opacity var(--cx-motion-duration-base) var(--cx-motion-easing-enter), translate var(--cx-motion-duration-base) var(--cx-motion-easing-enter),
|
|
1377
|
+
overlay var(--cx-motion-duration-base) allow-discrete, display var(--cx-motion-duration-base) allow-discrete;
|
|
1378
|
+
}
|
|
1379
|
+
dialog.cx-dialog:not([open]), dialog.cx-dialog:not([open])::backdrop { opacity: 0; transition-timing-function: var(--cx-motion-easing-exit); }
|
|
1380
|
+
dialog.cx-dialog:not([open]) { translate: 0 calc(6 * var(--cx-motion-distance-nudge)); }
|
|
1381
|
+
@starting-style {
|
|
1382
|
+
.cx-dialog[open], .cx-dialog[open]::backdrop { opacity: 0; }
|
|
1383
|
+
.cx-dialog[open] { translate: 0 calc(6 * var(--cx-motion-distance-nudge)); }
|
|
1384
|
+
}
|
|
1385
|
+
@media (prefers-reduced-motion: reduce) { .cx-dialog, .cx-dialog::backdrop { transition: none; } }
|
|
1386
|
+
html:has(.cx-dialog[open]) { overflow: hidden; }
|
|
1387
|
+
@media (width < 48rem) {
|
|
1388
|
+
.cx-dialog:not(.cx-dialog--wide) { width: 100%; max-width: none; margin: auto 0 0; border-width: var(--cx-border-width-hairline) 0 0; }
|
|
1389
|
+
.cx-dialog:not(.cx-dialog--wide) .cx-dialog__actions { flex-direction: column-reverse; }
|
|
1390
|
+
.cx-dialog:not(.cx-dialog--wide) .cx-dialog__actions .cx-button { width: 100%; justify-content: center; }
|
|
1391
|
+
.cx-dialog--wide { width: 100%; max-width: none; margin: 0; border-width: 0; }
|
|
1392
|
+
.cx-dialog--wide:modal { height: 100%; max-height: none; }
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1232
1395
|
/* ------------------------------------------------------------ data table */
|
|
1233
1396
|
.cx-table { position: relative; min-width: 0; overflow-x: auto; border: var(--cx-border-width-hairline) solid var(--cx-color-border-default); background: var(--cx-color-surface-raised); }
|
|
1234
1397
|
.cx-table table { width: 100%; border-collapse: collapse; font-size: var(--cx-font-size-small); line-height: var(--cx-font-line-height-ui); }
|
package/dist/codex.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// MotifSpec behaviour: theme toggle, the backdrop header's scroll state, tooltip dismissal, code copy buttons,
|
|
2
|
-
// TOC docking and active section, alert dismissal and
|
|
2
|
+
// TOC docking and active section, alert dismissal, toasts, date pickers and dialogs.
|
|
3
3
|
// Shipped as dist/codex.js (@aitrien/motifspec/codex.js).
|
|
4
4
|
// Enhancement only. Without this script: themes follow the system, code is selectable, the TOC is a plain open list,
|
|
5
5
|
// and every control that needs script stays hidden. Load it with `defer`; it also works inline at the end of <body>.
|
|
@@ -31,8 +31,17 @@
|
|
|
31
31
|
function ms(name) {
|
|
32
32
|
var v = getComputedStyle(root).getPropertyValue(name).trim();
|
|
33
33
|
return v.endsWith('ms') ? parseFloat(v) : parseFloat(v) * 1000;
|
|
34
|
+
} // A length token in pixels, measured by the browser, so rem, clamp() and calc() values all resolve.
|
|
35
|
+
function px(name) {
|
|
36
|
+
var probe = document.createElement('div');
|
|
37
|
+
probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;inline-size:var(' + name + ')';
|
|
38
|
+
(document.body || document.documentElement).appendChild(probe);
|
|
39
|
+
var w = probe.getBoundingClientRect().width;
|
|
40
|
+
probe.remove();
|
|
41
|
+
return w;
|
|
34
42
|
}
|
|
35
43
|
|
|
44
|
+
|
|
36
45
|
var theme = read();
|
|
37
46
|
apply(theme);
|
|
38
47
|
if (system && system.addEventListener) system.addEventListener('change', function () { apply(theme); });
|
|
@@ -128,14 +137,34 @@
|
|
|
128
137
|
});
|
|
129
138
|
|
|
130
139
|
// Component previews: size each frame to its document's body (the root is never shorter than the frame), and keep
|
|
131
|
-
// its theme.
|
|
140
|
+
// its theme. An open dialog or popover (a calendar) sits above the body, so while one is open the frame also grows
|
|
141
|
+
// to hold it, and shrinks back when it closes. Inside a preview, links don't navigate.
|
|
132
142
|
document.querySelectorAll('.cx-preview__frame').forEach(function (f) {
|
|
133
143
|
var fit = function () {
|
|
134
|
-
try {
|
|
144
|
+
try {
|
|
145
|
+
var d = f.contentDocument; if (!d || !d.body) return;
|
|
146
|
+
var need = d.body.offsetHeight, room = px('--cx-space-section-sm');
|
|
147
|
+
d.querySelectorAll('dialog[open], [popover]').forEach(function (o) {
|
|
148
|
+
if (o.matches('dialog[open]')) {
|
|
149
|
+
// its parts' full heights, since a dialog with too little room scrolls its body and reports less
|
|
150
|
+
var h = 0;
|
|
151
|
+
o.querySelectorAll(':scope > :not(form), :scope > form > *').forEach(function (c) { h += c.scrollHeight; });
|
|
152
|
+
need = Math.max(need, h + 2 * room);
|
|
153
|
+
}
|
|
154
|
+
else if (o.matches(':popover-open')) need = Math.max(need, o.offsetTop + o.offsetHeight + room);
|
|
155
|
+
});
|
|
156
|
+
f.style.setProperty('--_frame-height', need + 'px');
|
|
157
|
+
} catch (e) { /* cross-origin: keep the default height */ }
|
|
135
158
|
};
|
|
136
159
|
var start = function () {
|
|
137
160
|
apply(theme); fit();
|
|
138
161
|
try { if ('ResizeObserver' in window) new ResizeObserver(fit).observe(f.contentDocument.body); } catch (e) { /* keep the measured height */ }
|
|
162
|
+
try {
|
|
163
|
+
var d = f.contentDocument, later = function () { window.requestAnimationFrame(fit); };
|
|
164
|
+
d.addEventListener('toggle', later, true);
|
|
165
|
+
d.addEventListener('close', later, true);
|
|
166
|
+
if ('MutationObserver' in window) new MutationObserver(later).observe(d.body, { subtree: true, attributes: true, attributeFilter: ['open'] });
|
|
167
|
+
} catch (e) { /* keep the measured height */ }
|
|
139
168
|
};
|
|
140
169
|
f.addEventListener('load', start);
|
|
141
170
|
try { if (f.contentDocument && f.contentDocument.readyState === 'complete' && f.contentDocument.body && f.contentDocument.body.childNodes.length) start(); } catch (e) { /* wait for load */ }
|
|
@@ -344,6 +373,213 @@
|
|
|
344
373
|
wait();
|
|
345
374
|
});
|
|
346
375
|
|
|
376
|
+
// Dialogs (dialog.md): [data-dialog-open="id"] opens a .cx-dialog with showModal(), which moves focus in, closes on
|
|
377
|
+
// Escape and returns focus when closed. [data-dialog-close] inside one closes it, and so does a click on the
|
|
378
|
+
// backdrop, unless the dialog has data-dialog-keep (a form, whose typing a stray click would lose).
|
|
379
|
+
document.addEventListener('click', function (e) {
|
|
380
|
+
var t = e.target.closest ? e.target : null;
|
|
381
|
+
if (!t) return;
|
|
382
|
+
var opener = t.closest('[data-dialog-open]');
|
|
383
|
+
if (opener) {
|
|
384
|
+
var d = document.getElementById(opener.dataset.dialogOpen);
|
|
385
|
+
if (d && d.showModal && !d.open) d.showModal();
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
var dialog = t.closest('dialog.cx-dialog');
|
|
389
|
+
if (!dialog) return;
|
|
390
|
+
if (t.closest('[data-dialog-close]')) { dialog.close(); return; }
|
|
391
|
+
if (t === dialog && !dialog.hasAttribute('data-dialog-keep')) {
|
|
392
|
+
var r = dialog.getBoundingClientRect();
|
|
393
|
+
if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) dialog.close();
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// Date pickers (date-picker.md): each [data-date-picker] box gets its calendar button, and the page gets one
|
|
398
|
+
// calendar, made the first time it's opened. Dates are day first (DD/MM/YYYY) and weeks start on Monday. The
|
|
399
|
+
// calendar sits under its field, or above it when there's more room there, in page coordinates so it scrolls
|
|
400
|
+
// with the field. Days, months and years are each a grid with one tab stop, moved by the arrow keys.
|
|
401
|
+
var pickers = document.querySelectorAll('[data-date-picker]');
|
|
402
|
+
if (pickers.length) {
|
|
403
|
+
var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
404
|
+
var DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
405
|
+
var PAGE = 20;
|
|
406
|
+
var cal = null, calBody, calDays, calList, calTitle, monthBtn, yearBtn, navs;
|
|
407
|
+
var field = null, opener = null, selected = null, focusDay = null, view = 'days';
|
|
408
|
+
var today = function () { var n = new Date(); return new Date(n.getFullYear(), n.getMonth(), n.getDate()); };
|
|
409
|
+
var same = function (a, b) { return a && b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate(); };
|
|
410
|
+
var pad = function (n) { return String(n).padStart(2, '0'); };
|
|
411
|
+
var parse = function (v) {
|
|
412
|
+
var m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(v.trim());
|
|
413
|
+
if (!m) return null;
|
|
414
|
+
var d = new Date(+m[3], +m[2] - 1, +m[1]);
|
|
415
|
+
return d.getMonth() === +m[2] - 1 ? d : null;
|
|
416
|
+
};
|
|
417
|
+
var clampDay = function (y, m, d) { return new Date(y, m, Math.min(d, new Date(y, m + 1, 0).getDate())); };
|
|
418
|
+
var icon = function (id) {
|
|
419
|
+
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
420
|
+
svg.setAttribute('class', 'cx-icon'); svg.setAttribute('aria-hidden', 'true'); svg.setAttribute('focusable', 'false');
|
|
421
|
+
var use = document.createElementNS('http://www.w3.org/2000/svg', 'use'); use.setAttribute('href', '#cx-icon-' + id);
|
|
422
|
+
svg.appendChild(use); return svg;
|
|
423
|
+
};
|
|
424
|
+
var el = function (tag, cls, attrs) {
|
|
425
|
+
var n = document.createElement(tag); if (cls) n.className = cls;
|
|
426
|
+
Object.keys(attrs || {}).forEach(function (k) { n.setAttribute(k, attrs[k]); });
|
|
427
|
+
return n;
|
|
428
|
+
};
|
|
429
|
+
var build = function () {
|
|
430
|
+
cal = el('div', 'cx-calendar', { popover: '', role: 'dialog', 'aria-label': 'Choose a date' });
|
|
431
|
+
var head = el('div', 'cx-calendar__head');
|
|
432
|
+
var prev = el('button', 'cx-calendar__nav', { type: 'button', 'data-step': '-1' }); prev.appendChild(icon('arrow-back'));
|
|
433
|
+
var next = el('button', 'cx-calendar__nav', { type: 'button', 'data-step': '1' }); next.appendChild(icon('arrow-forward'));
|
|
434
|
+
var pick = el('div', 'cx-calendar__pickers');
|
|
435
|
+
monthBtn = el('button', 'cx-calendar__pick', { type: 'button', 'aria-expanded': 'false' });
|
|
436
|
+
yearBtn = el('button', 'cx-calendar__pick', { type: 'button', 'aria-expanded': 'false' });
|
|
437
|
+
[monthBtn, yearBtn].forEach(function (b) { b.appendChild(document.createElement('span')); b.appendChild(icon('expand')); pick.appendChild(b); });
|
|
438
|
+
head.appendChild(prev); head.appendChild(pick); head.appendChild(next);
|
|
439
|
+
calTitle = el('p', 'cx-visually-hidden', { 'aria-live': 'polite' });
|
|
440
|
+
calDays = el('table', 'cx-calendar__grid', { role: 'grid' });
|
|
441
|
+
var thead = el('thead'), tr = el('tr');
|
|
442
|
+
[1, 2, 3, 4, 5, 6, 0].forEach(function (i) { var th = el('th', '', { scope: 'col', abbr: DAYS[i] }); th.textContent = DAYS[i].slice(0, 2); tr.appendChild(th); });
|
|
443
|
+
thead.appendChild(tr); calDays.appendChild(thead); calBody = el('tbody'); calDays.appendChild(calBody);
|
|
444
|
+
calList = el('div', 'cx-calendar__list'); calList.hidden = true;
|
|
445
|
+
var foot = el('div', 'cx-calendar__foot');
|
|
446
|
+
var todayBtn = el('button', '', { type: 'button' }); todayBtn.textContent = 'Today';
|
|
447
|
+
var closeBtn = el('button', '', { type: 'button' }); closeBtn.textContent = 'Close';
|
|
448
|
+
foot.appendChild(todayBtn); foot.appendChild(closeBtn);
|
|
449
|
+
[head, calTitle, calDays, calList, foot].forEach(function (n) { cal.appendChild(n); });
|
|
450
|
+
document.body.appendChild(cal);
|
|
451
|
+
navs = [prev, next];
|
|
452
|
+
var labelId = 'cx-calendar-title'; calTitle.id = labelId; calDays.setAttribute('aria-labelledby', labelId);
|
|
453
|
+
monthBtn.setAttribute('aria-controls', 'cx-calendar-list'); yearBtn.setAttribute('aria-controls', 'cx-calendar-list'); calList.id = 'cx-calendar-list';
|
|
454
|
+
|
|
455
|
+
calBody.addEventListener('click', function (e) {
|
|
456
|
+
var b = e.target.closest('.cx-calendar__day'); if (!b) return;
|
|
457
|
+
var v = b.dataset.value.split('-'); choose(new Date(+v[0], +v[1], +v[2]));
|
|
458
|
+
});
|
|
459
|
+
calList.addEventListener('click', function (e) {
|
|
460
|
+
var b = e.target.closest('.cx-calendar__cell'); if (!b) return;
|
|
461
|
+
var v = +b.dataset.value;
|
|
462
|
+
if (view === 'years') { focusDay = clampDay(v, focusDay.getMonth(), focusDay.getDate()); setView('months'); }
|
|
463
|
+
else { focusDay = clampDay(focusDay.getFullYear(), v, focusDay.getDate()); setView('days'); }
|
|
464
|
+
});
|
|
465
|
+
monthBtn.addEventListener('click', function () { setView(view === 'months' ? 'days' : 'months'); });
|
|
466
|
+
yearBtn.addEventListener('click', function () { setView(view === 'years' ? 'days' : 'years'); });
|
|
467
|
+
navs.forEach(function (n) {
|
|
468
|
+
n.addEventListener('click', function () {
|
|
469
|
+
var st = +n.dataset.step, y = focusDay.getFullYear(), m = focusDay.getMonth(), d = focusDay.getDate();
|
|
470
|
+
focusDay = view === 'days' ? clampDay(y, m + st, d) : view === 'months' ? clampDay(y + st, m, d) : clampDay(y + st * PAGE, m, d);
|
|
471
|
+
render(false);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
todayBtn.addEventListener('click', function () { view = 'days'; focusDay = today(); render(true); });
|
|
475
|
+
closeBtn.addEventListener('click', close);
|
|
476
|
+
cal.addEventListener('toggle', function (e) { if (e.newState !== 'open') view = 'days'; });
|
|
477
|
+
calBody.addEventListener('keydown', function (e) {
|
|
478
|
+
var d = new Date(focusDay), k = e.key;
|
|
479
|
+
if (k === 'ArrowLeft') d.setDate(d.getDate() - 1);
|
|
480
|
+
else if (k === 'ArrowRight') d.setDate(d.getDate() + 1);
|
|
481
|
+
else if (k === 'ArrowUp') d.setDate(d.getDate() - 7);
|
|
482
|
+
else if (k === 'ArrowDown') d.setDate(d.getDate() + 7);
|
|
483
|
+
else if (k === 'PageUp') d = clampDay(d.getFullYear(), d.getMonth() - 1, d.getDate());
|
|
484
|
+
else if (k === 'PageDown') d = clampDay(d.getFullYear(), d.getMonth() + 1, d.getDate());
|
|
485
|
+
else if (k === 'Home') d.setDate(d.getDate() - ((d.getDay() + 6) % 7));
|
|
486
|
+
else if (k === 'End') d.setDate(d.getDate() + (6 - (d.getDay() + 6) % 7));
|
|
487
|
+
else return;
|
|
488
|
+
e.preventDefault(); focusDay = d; render(true);
|
|
489
|
+
});
|
|
490
|
+
calList.addEventListener('keydown', function (e) {
|
|
491
|
+
var cols = view === 'years' ? 4 : 3, k = e.key, y = focusDay.getFullYear(), m = focusDay.getMonth(), dd = focusDay.getDate(), delta = 0;
|
|
492
|
+
if (k === 'ArrowLeft') delta = -1; else if (k === 'ArrowRight') delta = 1;
|
|
493
|
+
else if (k === 'ArrowUp') delta = -cols; else if (k === 'ArrowDown') delta = cols;
|
|
494
|
+
else if (k === 'PageUp') delta = view === 'years' ? -PAGE : -12; else if (k === 'PageDown') delta = view === 'years' ? PAGE : 12;
|
|
495
|
+
else return;
|
|
496
|
+
e.preventDefault();
|
|
497
|
+
if (view === 'months' && Math.abs(delta) < 12) { if (m + delta < 0 || m + delta > 11) return; focusDay = clampDay(y, m + delta, dd); }
|
|
498
|
+
else focusDay = view === 'years' ? clampDay(y + delta, m, dd) : clampDay(y + delta / 12, m, dd);
|
|
499
|
+
render(true);
|
|
500
|
+
});
|
|
501
|
+
window.addEventListener('resize', place);
|
|
502
|
+
document.addEventListener('scroll', place, true);
|
|
503
|
+
};
|
|
504
|
+
var cell = function (cls, text, label, o) {
|
|
505
|
+
var b = el('button', cls, { type: 'button', 'aria-label': label, 'aria-pressed': o.pressed ? 'true' : 'false' });
|
|
506
|
+
if (o.current) b.setAttribute('aria-current', 'date');
|
|
507
|
+
b.textContent = text; b.tabIndex = o.focus ? 0 : -1; b.dataset.value = o.value;
|
|
508
|
+
return b;
|
|
509
|
+
};
|
|
510
|
+
var render = function (moveFocus) {
|
|
511
|
+
var y = focusDay.getFullYear(), m = focusDay.getMonth(), now = today();
|
|
512
|
+
monthBtn.firstChild.textContent = MONTHS[m]; yearBtn.firstChild.textContent = y;
|
|
513
|
+
monthBtn.setAttribute('aria-expanded', String(view === 'months')); yearBtn.setAttribute('aria-expanded', String(view === 'years'));
|
|
514
|
+
monthBtn.setAttribute('aria-label', 'Choose the month, ' + MONTHS[m]); yearBtn.setAttribute('aria-label', 'Choose the year, ' + y);
|
|
515
|
+
calDays.hidden = view !== 'days'; calList.hidden = view === 'days';
|
|
516
|
+
var labels = { days: ['Previous month', 'Next month'], months: ['Previous year', 'Next year'], years: ['Previous ' + PAGE + ' years', 'Next ' + PAGE + ' years'] }[view];
|
|
517
|
+
navs[0].setAttribute('aria-label', labels[0]); navs[1].setAttribute('aria-label', labels[1]);
|
|
518
|
+
if (view === 'days') {
|
|
519
|
+
calTitle.textContent = MONTHS[m] + ' ' + y;
|
|
520
|
+
var first = new Date(y, m, 1), start = new Date(y, m, 1 - ((first.getDay() + 6) % 7));
|
|
521
|
+
calBody.textContent = '';
|
|
522
|
+
for (var w = 0; w < 6; w++) {
|
|
523
|
+
var row = el('tr');
|
|
524
|
+
for (var i = 0; i < 7; i++) {
|
|
525
|
+
var d = new Date(start.getFullYear(), start.getMonth(), start.getDate() + w * 7 + i), td = el('td');
|
|
526
|
+
td.appendChild(cell('cx-calendar__day' + (d.getMonth() !== m ? ' is-other' : ''), d.getDate(),
|
|
527
|
+
DAYS[d.getDay()] + ' ' + d.getDate() + ' ' + MONTHS[d.getMonth()] + ' ' + d.getFullYear(),
|
|
528
|
+
{ pressed: same(d, selected), current: same(d, now), focus: same(d, focusDay), value: d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate() }));
|
|
529
|
+
row.appendChild(td);
|
|
530
|
+
}
|
|
531
|
+
calBody.appendChild(row);
|
|
532
|
+
}
|
|
533
|
+
} else if (view === 'months') {
|
|
534
|
+
calTitle.textContent = 'Months of ' + y; calList.className = 'cx-calendar__list cx-calendar__list--months'; calList.textContent = '';
|
|
535
|
+
MONTHS.forEach(function (name, i) {
|
|
536
|
+
calList.appendChild(cell('cx-calendar__cell', name.slice(0, 3), name + ' ' + y,
|
|
537
|
+
{ pressed: selected && selected.getFullYear() === y && selected.getMonth() === i, current: now.getFullYear() === y && now.getMonth() === i, focus: i === m, value: i }));
|
|
538
|
+
});
|
|
539
|
+
} else {
|
|
540
|
+
var from = Math.floor(y / PAGE) * PAGE;
|
|
541
|
+
calTitle.textContent = from + ' to ' + (from + PAGE - 1); calList.className = 'cx-calendar__list cx-calendar__list--years'; calList.textContent = '';
|
|
542
|
+
for (var k = from; k < from + PAGE; k++) {
|
|
543
|
+
calList.appendChild(cell('cx-calendar__cell', k, String(k), { pressed: selected && selected.getFullYear() === k, current: now.getFullYear() === k, focus: k === y, value: k }));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
place();
|
|
547
|
+
if (moveFocus) { var f = (view === 'days' ? calBody : calList).querySelector('[tabindex="0"]'); if (f) f.focus(); }
|
|
548
|
+
};
|
|
549
|
+
var setView = function (v) { view = v; render(true); };
|
|
550
|
+
var place = function () {
|
|
551
|
+
if (!cal || !field || !cal.matches(':popover-open')) return;
|
|
552
|
+
var r = field.getBoundingClientRect(), vw = document.documentElement.clientWidth, h = cal.offsetHeight, w = cal.offsetWidth, gap = px('--cx-space-inline-xs'), edge = px('--cx-space-inline-sm');
|
|
553
|
+
var below = window.innerHeight - r.bottom - gap, above = r.top - gap;
|
|
554
|
+
var top = (below < h && above > below) ? r.top - h - gap : r.bottom + gap;
|
|
555
|
+
cal.style.top = (top + window.scrollY) + 'px';
|
|
556
|
+
cal.style.left = (Math.max(edge, Math.min(r.left, vw - w - edge)) + window.scrollX) + 'px';
|
|
557
|
+
};
|
|
558
|
+
var close = function () { cal.hidePopover(); if (opener) opener.focus(); };
|
|
559
|
+
var choose = function (d) {
|
|
560
|
+
selected = d;
|
|
561
|
+
var input = field.querySelector('.cx-field__control');
|
|
562
|
+
input.value = pad(d.getDate()) + '/' + pad(d.getMonth() + 1) + '/' + d.getFullYear();
|
|
563
|
+
input.dispatchEvent(new Event('input', { bubbles: true })); input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
564
|
+
close();
|
|
565
|
+
};
|
|
566
|
+
pickers.forEach(function (box) {
|
|
567
|
+
var btn = box.querySelector('.cx-date__button');
|
|
568
|
+
if (!btn || !HTMLElement.prototype.hasOwnProperty('popover')) return;
|
|
569
|
+
btn.hidden = false;
|
|
570
|
+
btn.addEventListener('click', function () {
|
|
571
|
+
if (!cal) build();
|
|
572
|
+
if (cal.matches(':popover-open') && opener === btn) { cal.hidePopover(); return; }
|
|
573
|
+
if (cal.matches(':popover-open')) cal.hidePopover();
|
|
574
|
+
opener = btn; field = box;
|
|
575
|
+
selected = parse(box.querySelector('.cx-field__control').value);
|
|
576
|
+
focusDay = new Date(selected || today()); view = 'days';
|
|
577
|
+
cal.setAttribute('aria-label', btn.getAttribute('aria-label') || 'Choose a date');
|
|
578
|
+
cal.showPopover(); render(true);
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
|
|
347
583
|
// Docs navigation: dock it (sticky, scrolling on its own) while it sits beside the main column, as the TOC does.
|
|
348
584
|
document.querySelectorAll('.cx-docs').forEach(function (docs) {
|
|
349
585
|
var nav = docs.querySelector('.cx-docs-nav');
|
package/dist/contrast.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Contrast report (generated)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
107 declared pairs, each measured in both themes. Target is the pair's `min`.
|
|
4
4
|
|
|
5
5
|
| Foreground | Background | Min | Light | Dark | Result |
|
|
6
6
|
|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
| `color.text.primary` | `color.surface.sunken` | 7 | 15.28 | 15.28 | pass |
|
|
10
10
|
| `color.text.primary` | `color.surface.hover` | 7 | 15.28 | 10.21 | pass |
|
|
11
11
|
| `color.text.primary` | `color.surface.highlight` | 7 | 15.47 | 9.91 | pass |
|
|
12
|
+
| `color.text.primary` | `color.surface.selected` | 7 | 15.47 | 9.91 | pass |
|
|
12
13
|
| `color.text.primary` | `color.status.success.surface` | 7 | 16.48 | 15.12 | pass |
|
|
13
14
|
| `color.text.primary` | `color.status.warning.surface` | 7 | 16.29 | 15.28 | pass |
|
|
14
15
|
| `color.text.primary` | `color.status.danger.surface` | 7 | 16.23 | 15.57 | pass |
|
|
@@ -26,6 +27,8 @@
|
|
|
26
27
|
| `color.text.inverse` | `color.surface.inverse` | 7 | 13.61 | 12.71 | pass |
|
|
27
28
|
| `color.text.on-accent` | `color.accent.fill.rest` | 4.5 | 6.77 | 12.02 | pass |
|
|
28
29
|
| `color.text.on-accent` | `color.accent.fill.hover` | 4.5 | 11.20 | 15.03 | pass |
|
|
30
|
+
| `color.text.on-danger` | `color.status.danger.fill` | 4.5 | 7.67 | 11.29 | pass |
|
|
31
|
+
| `color.text.on-danger` | `color.status.danger.fill-hover` | 4.5 | 12.15 | 14.36 | pass |
|
|
29
32
|
| `color.link.rest` | `color.surface.base` | 7 | 10.61 | 9.18 | pass |
|
|
30
33
|
| `color.link.rest` | `color.surface.raised` | 7 | 11.20 | 8.12 | pass |
|
|
31
34
|
| `color.link.rest` | `color.surface.sunken` | 7 | 9.91 | 11.03 | pass |
|
|
@@ -58,6 +61,11 @@
|
|
|
58
61
|
| `color.status.danger.text` | `color.surface.raised` | 4.5 | 7.67 | 7.63 | pass |
|
|
59
62
|
| `color.status.danger.text` | `color.surface.hover` | 4.5 | 6.79 | 6.92 | pass |
|
|
60
63
|
| `color.status.danger.border` | `color.status.danger.surface` | 3 | 5.04 | 7.39 | pass |
|
|
64
|
+
| `color.status.danger.fill` | `color.surface.base` | 3 | 7.27 | 8.62 | pass |
|
|
65
|
+
| `color.status.danger.fill` | `color.surface.raised` | 3 | 7.67 | 7.63 | pass |
|
|
66
|
+
| `color.status.danger.fill` | `color.surface.sunken` | 3 | 6.79 | 10.36 | pass |
|
|
67
|
+
| `color.status.danger.fill-hover` | `color.surface.raised` | 3 | 12.15 | 9.70 | pass |
|
|
68
|
+
| `color.status.danger.fill-hover` | `color.surface.sunken` | 3 | 10.75 | 13.18 | pass |
|
|
61
69
|
| `color.status.info.text` | `color.status.info.surface` | 4.5 | 6.72 | 10.74 | pass |
|
|
62
70
|
| `color.status.info.text` | `color.surface.base` | 4.5 | 6.76 | 8.95 | pass |
|
|
63
71
|
| `color.status.info.text` | `color.surface.raised` | 4.5 | 7.13 | 7.92 | pass |
|
package/dist/icons.svg
CHANGED
|
@@ -28,4 +28,5 @@
|
|
|
28
28
|
<symbol id="cx-icon-settings" viewBox="0 -960 960 960"><path d="m400.69-100-18.07-120.23q-20.54-7-44.23-20.35-23.7-13.34-40.85-28.27l-111.85 50.93-79.92-141.31 101.08-74.38q-2-10.54-2.89-23.01-.88-12.46-.88-23 0-10.15.88-22.61.89-12.46 2.89-24.16l-101.08-74.76 79.92-140.16 111.46 50.16q18.31-14.93 41.24-28.08 22.92-13.15 43.84-19.54L400.69-860h158.62l18.07 120.62q22.08 8.15 44.16 20.23 22.07 12.07 39.77 28l113.38-50.16 79.54 140.16-102.62 74.3q2.77 11.93 3.47 24 .69 12.08.69 22.85 0 10.38-.89 22.15-.88 11.77-3.27 24.47l102.23 74.15-79.92 141.31-112.61-51.31q-18.7 15.69-40.35 28.96-21.65 13.27-43.58 19.65L559.31-100H400.69Zm36.46-45.39h85.31L536.85-257q31.84-8 59.42-23.85 27.58-15.84 52.73-40.23l104.46 45.23 40-70.84L701-414.92q4-17.77 6.31-33.5 2.3-15.73 2.3-31.58 0-16.62-2-31.96-2-15.35-6.61-32.35l93.23-69-40-70.84-105.62 45.23q-21.07-23.69-50.84-41.77Q568-698.77 536.46-703l-13.61-111.61h-85.7l-13.23 111.23q-33.23 6.61-61.19 22.65t-52.11 41.42l-104.85-44.84-40 70.84 92.46 67.85q-4.38 15.84-6.69 32.15-2.31 16.31-2.31 33.69 0 16.62 2.31 32.54 2.31 15.93 6.31 32.16l-92.08 68.23 40 70.84 104.46-44.84q24 24.38 52.15 40.23 28.16 15.84 61.16 23.84l13.61 111.23Zm41.7-221.92q47.07 0 79.88-32.81 32.81-32.8 32.81-79.88t-32.81-79.88q-32.81-32.81-79.88-32.81-46.7 0-79.7 32.81-32.99 32.8-32.99 79.88t32.99 79.88q33 32.81 79.7 32.81ZM480-480Z"/></symbol>
|
|
29
29
|
<symbol id="cx-icon-restart" viewBox="0 -960 960 960"><path d="M447.92-142.77q-113.77-11.15-190.84-96Q180-323.62 180-439.38q0-68.93 31.08-130.2 31.07-61.26 86.23-102.34l32.23 32.61q-49.85 33-77 86.46-27.15 53.47-27.15 113.47 0 96.92 63.49 167.99 63.5 71.08 159.04 83.24v45.38Zm65.39.77v-45.39q96.15-14.3 159.04-84.88 62.88-70.58 62.88-167.11 0-106.7-73.96-180.66T480.62-694h-26.54l65.77 65.77-32.62 32.61-121.07-121.07 121.07-121.08 32.62 32.62-65.77 65.77h26.54q125.53 0 212.76 87.73 87.23 87.73 87.23 212.27 0 115.76-76.76 200.42-76.77 84.65-190.54 96.96Z"/></symbol>
|
|
30
30
|
<symbol id="cx-icon-logs" viewBox="0 -960 960 960"><path d="M100-180v-600h760v600H100Zm45.39-45.39h669.22v-426.38H145.39v426.38ZM300-303.15l-31.61-31.23 103-104-104-104L300-574l135.61 135.62L300-303.15Zm197.31 7.46v-45.39h205.38v45.39H497.31Z"/></symbol>
|
|
31
|
+
<symbol id="cx-icon-calendar" 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"/></symbol>
|
|
31
32
|
</svg>
|
package/dist/tokens.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* MotifSpec 1.
|
|
1
|
+
/* MotifSpec 1.27.0 — generated from tokens/*.json. Do not edit.
|
|
2
2
|
Themes: semantic colours use light-dark(); color-scheme follows the system unless
|
|
3
3
|
<html data-theme="light|dark"> pins it. --cx-primitive-* are for this file only. */
|
|
4
4
|
:root {
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
--cx-color-surface-hover: light-dark(var(--cx-primitive-color-ash-100), var(--cx-primitive-color-ash-800));
|
|
101
101
|
--cx-color-surface-inverse: light-dark(var(--cx-primitive-color-ash-900), var(--cx-primitive-color-ash-100));
|
|
102
102
|
--cx-color-surface-highlight: light-dark(var(--cx-primitive-color-sap-100), var(--cx-primitive-color-sap-800));
|
|
103
|
+
--cx-color-surface-selected: light-dark(var(--cx-primitive-color-sap-100), var(--cx-primitive-color-sap-800));
|
|
103
104
|
|
|
104
105
|
/* color.text */
|
|
105
106
|
--cx-color-text-primary: light-dark(var(--cx-primitive-color-ash-950), var(--cx-primitive-color-ash-100));
|
|
@@ -108,6 +109,7 @@
|
|
|
108
109
|
--cx-color-text-accent: light-dark(var(--cx-primitive-color-sap-700), var(--cx-primitive-color-sap-300));
|
|
109
110
|
--cx-color-text-inverse: light-dark(var(--cx-primitive-color-ash-50), var(--cx-primitive-color-ash-900));
|
|
110
111
|
--cx-color-text-on-accent: light-dark(var(--cx-primitive-color-ash-0), var(--cx-primitive-color-ash-1000));
|
|
112
|
+
--cx-color-text-on-danger: light-dark(var(--cx-primitive-color-ash-0), var(--cx-primitive-color-ash-1000));
|
|
111
113
|
|
|
112
114
|
/* color.link */
|
|
113
115
|
--cx-color-link-rest: light-dark(var(--cx-primitive-color-sap-800), var(--cx-primitive-color-sap-300));
|
|
@@ -141,6 +143,8 @@
|
|
|
141
143
|
--cx-color-status-danger-text: light-dark(var(--cx-primitive-color-madder-700), var(--cx-primitive-color-madder-300));
|
|
142
144
|
--cx-color-status-danger-surface: light-dark(var(--cx-primitive-color-madder-50), var(--cx-primitive-color-madder-950));
|
|
143
145
|
--cx-color-status-danger-border: light-dark(var(--cx-primitive-color-madder-600), var(--cx-primitive-color-madder-400));
|
|
146
|
+
--cx-color-status-danger-fill: light-dark(var(--cx-primitive-color-madder-700), var(--cx-primitive-color-madder-300));
|
|
147
|
+
--cx-color-status-danger-fill-hover: light-dark(var(--cx-primitive-color-madder-800), var(--cx-primitive-color-madder-200));
|
|
144
148
|
--cx-color-status-info-text: light-dark(var(--cx-primitive-color-woad-700), var(--cx-primitive-color-woad-300));
|
|
145
149
|
--cx-color-status-info-surface: light-dark(var(--cx-primitive-color-woad-50), var(--cx-primitive-color-woad-950));
|
|
146
150
|
--cx-color-status-info-border: light-dark(var(--cx-primitive-color-woad-600), var(--cx-primitive-color-woad-400));
|