@mdbase-dev/ui 0.1.2 → 0.1.5
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/README.md +65 -6
- package/css/controls.css +336 -55
- package/css/motion.css +39 -7
- package/css/palette.css +1 -3
- package/css/toast.css +135 -11
- package/css/tokens.css +45 -124
- package/dist/ConfirmDialog.d.ts +8 -3
- package/dist/ConfirmDialog.js +11 -1
- package/dist/Dialog.d.ts +11 -2
- package/dist/Dialog.js +55 -35
- package/dist/SaveNotice.js +2 -1
- package/dist/Segmented.d.ts +22 -0
- package/dist/Segmented.js +74 -0
- package/dist/Switch.d.ts +14 -0
- package/dist/Switch.js +35 -0
- package/dist/ThemeSelect.d.ts +4 -3
- package/dist/ThemeSelect.js +9 -9
- package/dist/Toaster.d.ts +20 -3
- package/dist/Toaster.js +87 -33
- package/dist/Tooltip.d.ts +9 -4
- package/dist/Tooltip.js +87 -43
- package/dist/popover.js +4 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -21,7 +21,15 @@ applyThemePreference(loadThemePreference());
|
|
|
21
21
|
themes. Style components with roles, not palette values. Short aliases such
|
|
22
22
|
as `--ink` belong to each app.
|
|
23
23
|
`--color-current` and `--color-on-current` mark the keyboard/pointer current
|
|
24
|
-
choice in
|
|
24
|
+
choice in completion lists and diagnostics; `--color-selected` stays subtle for persistent selections.
|
|
25
|
+
Each colour that differs by theme is one `light-dark()` value, and `:root`
|
|
26
|
+
uses one scheme at a time. In CSS, `var(--color-text)` resolves as before. In
|
|
27
|
+
script, read a resolved colour from an element (`getComputedStyle(element).color`),
|
|
28
|
+
not the raw property, which is the `light-dark()` expression. An element that
|
|
29
|
+
sets its own `color-scheme` gets that scheme's colours.
|
|
30
|
+
- Corners come in three sizes: `--radius-sm` (6px) for controls and rows,
|
|
31
|
+
`--radius-md` (8px) for content blocks and toasts, `--radius-lg` (10px) for
|
|
32
|
+
menus and dialogs.
|
|
25
33
|
- `theme` stores the System, Light or Dark choice as `mdbase:theme`.
|
|
26
34
|
- `brand` draws the Frontmatter mark, each app's inverted mark, and the
|
|
27
35
|
`mdbase <app>` wordmark. Add `motion.css` to animate the mark: loops
|
|
@@ -85,10 +93,44 @@ plugins: [react(), mdbaseOpeningPage({
|
|
|
85
93
|
again. `layout="panel"` renders a `div` without the reload hint, for a
|
|
86
94
|
screen inside the app's own chrome.
|
|
87
95
|
|
|
96
|
+
## Switch and segmented control
|
|
97
|
+
|
|
98
|
+
Both need `controls.css`.
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { Switch } from "@mdbase-dev/ui/switch";
|
|
102
|
+
import { Segmented } from "@mdbase-dev/ui/segmented";
|
|
103
|
+
|
|
104
|
+
<Switch checked={wrap} onChange={setWrap}>Wrap long lines</Switch>
|
|
105
|
+
<Segmented aria-label="View" value={view} onChange={setView} options={[
|
|
106
|
+
{ value: "day", label: "Day" },
|
|
107
|
+
{ value: "week", label: "Week" },
|
|
108
|
+
]} />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- `Switch` is for a setting that takes effect at once; use `Checkbox` for a
|
|
112
|
+
choice that waits for a Save. Its children are its label. Without children it
|
|
113
|
+
renders the control alone, for a row that lays out its own text: name it
|
|
114
|
+
with `aria-label` or `aria-labelledby`. Other button props pass through.
|
|
115
|
+
- `Segmented` is one choice among two to four short options that stay in
|
|
116
|
+
view. It is a group of native radios, so arrow keys move the choice. Use
|
|
117
|
+
`Select` for more options or long labels.
|
|
118
|
+
- `ThemeSelect` from `@mdbase-dev/ui/theme-select` is the segmented control
|
|
119
|
+
for System, Light and Dark.
|
|
120
|
+
|
|
121
|
+
## Motion
|
|
122
|
+
|
|
123
|
+
`motion.css` (which `controls.css` imports) defines the durations and curves.
|
|
124
|
+
Something a hand just moved, such as a released button, a switch thumb or a
|
|
125
|
+
segmented thumb, settles on `--motion-spring` with `--ease-spring`, a spring
|
|
126
|
+
with about 2% overshoot; the press itself takes `--motion-press`. Menus, lists
|
|
127
|
+
and dialogs open on the same spring, from the corner beside their trigger.
|
|
128
|
+
Reduced motion sets every duration to zero, so nothing needs its own override.
|
|
129
|
+
|
|
88
130
|
## Icon-button tooltips
|
|
89
131
|
|
|
90
132
|
Import `Tooltip` from `@mdbase-dev/ui/tooltip` and include `controls.css`.
|
|
91
|
-
Wrap one
|
|
133
|
+
Wrap one icon button or link in `<Tooltip label="Search" shortcut="mod+k">…</Tooltip>`.
|
|
92
134
|
Localize the label in the caller. The optional shortcut uses the same notation and
|
|
93
135
|
platform labels as the command palette and sets `aria-keyshortcuts` on the button.
|
|
94
136
|
The button keeps its ref and handlers; a native manual popover adds no layout box
|
|
@@ -103,10 +145,27 @@ press, or an unavailable trigger cancels pending and visible hints.
|
|
|
103
145
|
## Toasts
|
|
104
146
|
|
|
105
147
|
Mount one `Toaster` from `@mdbase-dev/ui/toast` inside the app's locale provider
|
|
106
|
-
and import `@mdbase-dev/ui/toast.css
|
|
107
|
-
copy and, when applicable, a real inverse
|
|
108
|
-
seconds (eight with Undo), pauses on hover
|
|
109
|
-
more messages. Unmounting the owner clears the
|
|
148
|
+
and import `@mdbase-dev/ui/toast.css` after `controls.css`. Call
|
|
149
|
+
`toast(message, undo?)` with localized copy and, when applicable, a real inverse
|
|
150
|
+
mutation. The toast stays for five seconds (eight with Undo), pauses on hover
|
|
151
|
+
or focus, and queues up to three more messages. Unmounting the owner clears the
|
|
152
|
+
queue.
|
|
153
|
+
|
|
154
|
+
For anything else, pass options in place of the undo function:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
toast("Collection shared", { tone: "success" });
|
|
158
|
+
const dismiss = toast("Could not save", {
|
|
159
|
+
tone: "error",
|
|
160
|
+
sticky: true,
|
|
161
|
+
action: { label: retryLabel, onAction: retry, dismiss: true },
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`tone` puts a tick or an exclamation mark before the message, `sticky` keeps
|
|
166
|
+
the toast until it is dismissed, `durationMs` sets another time, and
|
|
167
|
+
`dismissible: false` removes the close button. `toast` returns a function that
|
|
168
|
+
dismisses that toast.
|
|
110
169
|
|
|
111
170
|
## Languages
|
|
112
171
|
|
package/css/controls.css
CHANGED
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
--control-radius: var(--radius-sm);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
@media (pointer: coarse) {
|
|
17
|
-
:root { --control-height: 40px; }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
/* The negative margin keeps the box inside its static position: left in normal
|
|
21
17
|
flow at the end of a full-height shell, it made the document 1px taller. */
|
|
22
18
|
.mdbase-visually-hidden {
|
|
@@ -58,7 +54,6 @@
|
|
|
58
54
|
}
|
|
59
55
|
.mdbase-tooltip kbd { flex-shrink: 0; color: var(--color-text-muted); font: inherit; }
|
|
60
56
|
@starting-style { .mdbase-tooltip:popover-open { opacity: 0; } }
|
|
61
|
-
@media (prefers-reduced-motion: reduce) { .mdbase-tooltip { transition: none; } }
|
|
62
57
|
|
|
63
58
|
.mdbase-message {
|
|
64
59
|
margin: 1.2rem 0 0;
|
|
@@ -102,7 +97,9 @@
|
|
|
102
97
|
background: transparent;
|
|
103
98
|
font: inherit;
|
|
104
99
|
font-size: var(--control-font-size);
|
|
105
|
-
transition:
|
|
100
|
+
transition:
|
|
101
|
+
border-color var(--motion-quick) var(--ease-standard),
|
|
102
|
+
background var(--motion-quick) var(--ease-standard);
|
|
106
103
|
}
|
|
107
104
|
|
|
108
105
|
.mdbase-field {
|
|
@@ -176,7 +173,7 @@ textarea.mdbase-field {
|
|
|
176
173
|
stroke-width: 2;
|
|
177
174
|
stroke-linecap: round;
|
|
178
175
|
stroke-linejoin: round;
|
|
179
|
-
transition: transform var(--motion-
|
|
176
|
+
transition: transform var(--motion-spring) var(--ease-spring);
|
|
180
177
|
}
|
|
181
178
|
|
|
182
179
|
.mdbase-select[aria-expanded="true"] .mdbase-select-chevron {
|
|
@@ -222,7 +219,8 @@ textarea.mdbase-field {
|
|
|
222
219
|
overflow: auto;
|
|
223
220
|
padding: 4px;
|
|
224
221
|
border: 1px solid var(--color-border-strong);
|
|
225
|
-
|
|
222
|
+
/* Row radius plus the padding, so the corners stay concentric. */
|
|
223
|
+
border-radius: calc(var(--control-radius) + 4px);
|
|
226
224
|
outline: 0;
|
|
227
225
|
color: var(--color-text-soft);
|
|
228
226
|
background: var(--color-surface);
|
|
@@ -293,7 +291,7 @@ textarea.mdbase-field {
|
|
|
293
291
|
overflow: auto;
|
|
294
292
|
padding: 5px;
|
|
295
293
|
border: 1px solid var(--color-border-strong);
|
|
296
|
-
border-radius: var(--control-radius);
|
|
294
|
+
border-radius: calc(var(--control-radius) + 5px);
|
|
297
295
|
outline: 0;
|
|
298
296
|
color: var(--color-text-soft);
|
|
299
297
|
background: var(--color-surface-overlay);
|
|
@@ -351,14 +349,51 @@ textarea.mdbase-field {
|
|
|
351
349
|
.mdbase-menu-item.is-danger:hover:not(:disabled, [aria-disabled="true"]),
|
|
352
350
|
.mdbase-menu .mdbase-menu-item.is-danger:focus-visible { color: var(--color-danger); }
|
|
353
351
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
.mdbase-disclosure
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
.mdbase-disclosure
|
|
361
|
-
|
|
352
|
+
/* Disclosure: a native <details>. Its content grows where the browser can animate to
|
|
353
|
+
height: auto (interpolate-size); elsewhere it opens at once. */
|
|
354
|
+
.mdbase-disclosure {
|
|
355
|
+
interpolate-size: allow-keywords;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.mdbase-disclosure > summary {
|
|
359
|
+
display: flex;
|
|
360
|
+
align-items: center;
|
|
361
|
+
gap: var(--space-2);
|
|
362
|
+
list-style: none;
|
|
363
|
+
cursor: pointer;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.mdbase-disclosure > summary::-webkit-details-marker {
|
|
367
|
+
display: none;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.mdbase-disclosure > summary::after {
|
|
371
|
+
width: 6px;
|
|
372
|
+
height: 6px;
|
|
373
|
+
flex: none;
|
|
374
|
+
margin-left: auto;
|
|
375
|
+
border-right: 1.5px solid currentColor;
|
|
376
|
+
border-bottom: 1.5px solid currentColor;
|
|
377
|
+
content: "";
|
|
378
|
+
rotate: -45deg;
|
|
379
|
+
transition: rotate var(--motion-spring) var(--ease-spring);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.mdbase-disclosure[open] > summary::after {
|
|
383
|
+
rotate: 45deg;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.mdbase-disclosure::details-content {
|
|
387
|
+
height: 0;
|
|
388
|
+
overflow: hidden;
|
|
389
|
+
transition:
|
|
390
|
+
height var(--motion-enter) var(--ease-out),
|
|
391
|
+
content-visibility var(--motion-enter) allow-discrete;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.mdbase-disclosure[open]::details-content {
|
|
395
|
+
height: auto;
|
|
396
|
+
}
|
|
362
397
|
|
|
363
398
|
.mdbase-menu-copy {
|
|
364
399
|
min-width: 0;
|
|
@@ -422,7 +457,7 @@ textarea.mdbase-field {
|
|
|
422
457
|
fill: none;
|
|
423
458
|
stroke: var(--color-text-muted);
|
|
424
459
|
stroke-width: 1.6;
|
|
425
|
-
transition: transform var(--motion-
|
|
460
|
+
transition: transform var(--motion-spring) var(--ease-spring);
|
|
426
461
|
}
|
|
427
462
|
|
|
428
463
|
.mdbase-app-switcher[aria-expanded="true"] .mdbase-app-switcher-chevron {
|
|
@@ -497,7 +532,11 @@ textarea.mdbase-field {
|
|
|
497
532
|
text-decoration: none;
|
|
498
533
|
white-space: nowrap;
|
|
499
534
|
cursor: pointer;
|
|
500
|
-
transition:
|
|
535
|
+
transition:
|
|
536
|
+
color var(--motion-quick) var(--ease-standard),
|
|
537
|
+
border-color var(--motion-quick) var(--ease-standard),
|
|
538
|
+
background var(--motion-quick) var(--ease-standard),
|
|
539
|
+
scale var(--motion-spring) var(--ease-spring);
|
|
501
540
|
}
|
|
502
541
|
|
|
503
542
|
.mdbase-button:hover:not(:disabled) {
|
|
@@ -505,11 +544,37 @@ textarea.mdbase-field {
|
|
|
505
544
|
background: var(--color-surface-subtle);
|
|
506
545
|
}
|
|
507
546
|
|
|
547
|
+
/* A press goes down fast and comes back on the spring. */
|
|
508
548
|
.mdbase-button:active:not(:disabled) {
|
|
509
|
-
|
|
510
|
-
transition-duration:
|
|
549
|
+
scale: 0.97;
|
|
550
|
+
transition-duration: var(--motion-press);
|
|
551
|
+
transition-timing-function: var(--ease-out);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/* A label that changes while the button works (see ConfirmDialog). The other label lies
|
|
555
|
+
underneath at no height, so the button is as wide as the wider of the two throughout. */
|
|
556
|
+
.mdbase-button-label {
|
|
557
|
+
display: inline-grid;
|
|
558
|
+
justify-items: center;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.mdbase-button-label::after {
|
|
562
|
+
height: 0;
|
|
563
|
+
overflow: hidden;
|
|
564
|
+
content: attr(data-other);
|
|
565
|
+
visibility: hidden;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.mdbase-button[aria-busy="true"] > .mdbase-button-label {
|
|
569
|
+
animation: mdbase-label-in var(--motion-base) var(--ease-out);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
@keyframes mdbase-label-in {
|
|
573
|
+
from {
|
|
574
|
+
opacity: 0;
|
|
575
|
+
translate: 0 3px;
|
|
576
|
+
}
|
|
511
577
|
}
|
|
512
|
-
@media (prefers-reduced-motion: reduce) { .mdbase-button:active:not(:disabled) { transform: none; } }
|
|
513
578
|
|
|
514
579
|
.mdbase-button.is-primary {
|
|
515
580
|
border-color: var(--color-accent);
|
|
@@ -581,7 +646,16 @@ textarea.mdbase-field {
|
|
|
581
646
|
color: var(--color-text-soft);
|
|
582
647
|
background: transparent;
|
|
583
648
|
cursor: pointer;
|
|
584
|
-
transition:
|
|
649
|
+
transition:
|
|
650
|
+
color var(--motion-quick) var(--ease-standard),
|
|
651
|
+
background var(--motion-quick) var(--ease-standard),
|
|
652
|
+
scale var(--motion-spring) var(--ease-spring);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.mdbase-icon-button:active:not(:disabled) {
|
|
656
|
+
scale: 0.92;
|
|
657
|
+
transition-duration: var(--motion-press);
|
|
658
|
+
transition-timing-function: var(--ease-out);
|
|
585
659
|
}
|
|
586
660
|
|
|
587
661
|
.mdbase-icon-button:hover:not(:disabled),
|
|
@@ -607,7 +681,9 @@ textarea.mdbase-field {
|
|
|
607
681
|
outline-offset: var(--focus-offset);
|
|
608
682
|
}
|
|
609
683
|
|
|
610
|
-
/* Switch: native button semantics (role="switch", aria-checked), one track and thumb
|
|
684
|
+
/* Switch: native button semantics (role="switch", aria-checked), one track and thumb; the
|
|
685
|
+
Switch component from ./switch renders it. The thumb stretches while held and springs
|
|
686
|
+
across when released. */
|
|
611
687
|
.mdbase-switch {
|
|
612
688
|
position: relative;
|
|
613
689
|
width: 36px;
|
|
@@ -617,19 +693,28 @@ textarea.mdbase-field {
|
|
|
617
693
|
align-items: center;
|
|
618
694
|
padding: 2px;
|
|
619
695
|
border: 1px solid var(--color-border-strong);
|
|
620
|
-
border-radius:
|
|
696
|
+
border-radius: 11px;
|
|
621
697
|
background: var(--color-surface-subtle);
|
|
622
698
|
cursor: pointer;
|
|
623
|
-
transition:
|
|
699
|
+
transition:
|
|
700
|
+
background var(--motion-base) var(--ease-out),
|
|
701
|
+
border-color var(--motion-base) var(--ease-out);
|
|
624
702
|
}
|
|
625
703
|
|
|
626
704
|
.mdbase-switch > span {
|
|
627
705
|
width: 16px;
|
|
628
706
|
height: 16px;
|
|
629
|
-
border-radius:
|
|
707
|
+
border-radius: 8px;
|
|
630
708
|
background: var(--color-text-muted);
|
|
631
709
|
pointer-events: none;
|
|
632
|
-
transition:
|
|
710
|
+
transition:
|
|
711
|
+
translate var(--motion-spring) var(--ease-spring),
|
|
712
|
+
width var(--motion-spring) var(--ease-spring),
|
|
713
|
+
background var(--motion-base) var(--ease-out);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
.mdbase-switch:active:not(:disabled) > span {
|
|
717
|
+
width: 20px;
|
|
633
718
|
}
|
|
634
719
|
|
|
635
720
|
.mdbase-switch[aria-checked="true"] {
|
|
@@ -637,9 +722,22 @@ textarea.mdbase-field {
|
|
|
637
722
|
background: var(--color-accent);
|
|
638
723
|
}
|
|
639
724
|
|
|
725
|
+
/* The track's 30px inside, less the thumb. */
|
|
640
726
|
.mdbase-switch[aria-checked="true"] > span {
|
|
641
|
-
transform: translateX(14px);
|
|
642
727
|
background: var(--color-on-accent);
|
|
728
|
+
translate: 14px;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
.mdbase-switch[aria-checked="true"]:active:not(:disabled) > span {
|
|
732
|
+
translate: 10px;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.mdbase-switch[aria-checked="true"]:dir(rtl) > span {
|
|
736
|
+
translate: -14px;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.mdbase-switch[aria-checked="true"]:dir(rtl):active:not(:disabled) > span {
|
|
740
|
+
translate: -10px;
|
|
643
741
|
}
|
|
644
742
|
|
|
645
743
|
.mdbase-switch:disabled {
|
|
@@ -649,6 +747,110 @@ textarea.mdbase-field {
|
|
|
649
747
|
opacity: 0.5;
|
|
650
748
|
}
|
|
651
749
|
|
|
750
|
+
/* A switch and its text in one label, as Checkbox does for a checkbox. */
|
|
751
|
+
.mdbase-switch-row {
|
|
752
|
+
display: flex;
|
|
753
|
+
align-items: center;
|
|
754
|
+
justify-content: space-between;
|
|
755
|
+
gap: var(--space-3);
|
|
756
|
+
cursor: pointer;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
.mdbase-switch-row:has(.mdbase-switch:disabled) {
|
|
760
|
+
cursor: not-allowed;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/* Segmented control (./segmented): a few exclusive choices, all in view. Native radios keep
|
|
764
|
+
the arrow keys and form state; one thumb glides to the checked option, its leading edge
|
|
765
|
+
first, so it stretches on the way. */
|
|
766
|
+
.mdbase-segmented {
|
|
767
|
+
position: relative;
|
|
768
|
+
/* Equal segments, each as wide as the longest label; a stretched control shares the room. */
|
|
769
|
+
display: inline-grid;
|
|
770
|
+
grid-auto-flow: column;
|
|
771
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
772
|
+
padding: 2px;
|
|
773
|
+
border: 1px solid var(--color-border);
|
|
774
|
+
border-radius: var(--control-radius);
|
|
775
|
+
background: var(--color-surface-subtle);
|
|
776
|
+
font-size: var(--control-font-size);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
.mdbase-segmented-thumb {
|
|
780
|
+
position: absolute;
|
|
781
|
+
top: 2px;
|
|
782
|
+
bottom: 2px;
|
|
783
|
+
border: 1px solid var(--color-border-strong);
|
|
784
|
+
border-radius: calc(var(--control-radius) - 2px);
|
|
785
|
+
/* Raised reads as lighter than the track in both themes. */
|
|
786
|
+
background: light-dark(var(--color-surface), var(--color-border-strong));
|
|
787
|
+
box-shadow: 0 1px 2px var(--color-shadow);
|
|
788
|
+
pointer-events: none;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
.mdbase-segmented[data-moving="end"] > .mdbase-segmented-thumb {
|
|
792
|
+
transition:
|
|
793
|
+
right var(--motion-base) var(--ease-out),
|
|
794
|
+
left var(--motion-spring) var(--ease-spring);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
.mdbase-segmented[data-moving="start"] > .mdbase-segmented-thumb {
|
|
798
|
+
transition:
|
|
799
|
+
left var(--motion-base) var(--ease-out),
|
|
800
|
+
right var(--motion-spring) var(--ease-spring);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
.mdbase-segmented-option {
|
|
804
|
+
position: relative;
|
|
805
|
+
min-height: calc(var(--control-height) - 6px);
|
|
806
|
+
display: inline-flex;
|
|
807
|
+
align-items: center;
|
|
808
|
+
justify-content: center;
|
|
809
|
+
padding: 0 10px;
|
|
810
|
+
border-radius: calc(var(--control-radius) - 2px);
|
|
811
|
+
color: var(--color-text-muted);
|
|
812
|
+
font-weight: var(--font-weight-medium);
|
|
813
|
+
white-space: nowrap;
|
|
814
|
+
cursor: pointer;
|
|
815
|
+
user-select: none;
|
|
816
|
+
transition:
|
|
817
|
+
color var(--motion-quick) var(--ease-standard),
|
|
818
|
+
scale var(--motion-spring) var(--ease-spring);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/* The radio covers its option, so the whole option is the target. */
|
|
822
|
+
.mdbase-segmented-option > input {
|
|
823
|
+
position: absolute;
|
|
824
|
+
inset: 0;
|
|
825
|
+
margin: 0;
|
|
826
|
+
opacity: 0;
|
|
827
|
+
cursor: inherit;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
.mdbase-segmented-option:hover {
|
|
831
|
+
color: var(--color-text-soft);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
.mdbase-segmented-option:active:not(:has(:disabled)) {
|
|
835
|
+
scale: 0.97;
|
|
836
|
+
transition-duration: var(--motion-press);
|
|
837
|
+
transition-timing-function: var(--ease-out);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.mdbase-segmented-option:has(:checked) {
|
|
841
|
+
color: var(--color-text);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
.mdbase-segmented-option:has(:disabled) {
|
|
845
|
+
color: var(--color-text-faint);
|
|
846
|
+
cursor: not-allowed;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
.mdbase-segmented-option:has(:focus-visible) {
|
|
850
|
+
outline: var(--focus-ring);
|
|
851
|
+
outline-offset: 1px;
|
|
852
|
+
}
|
|
853
|
+
|
|
652
854
|
/* Checkbox: native inputs keep Space, label activation, form state and indeterminate support.
|
|
653
855
|
Writer's Markdown checkbox button uses the same appearance with aria-checked. */
|
|
654
856
|
.mdbase-checkbox {
|
|
@@ -667,7 +869,16 @@ textarea.mdbase-field {
|
|
|
667
869
|
color: var(--color-on-accent);
|
|
668
870
|
vertical-align: middle;
|
|
669
871
|
cursor: pointer;
|
|
670
|
-
transition:
|
|
872
|
+
transition:
|
|
873
|
+
background var(--motion-quick) var(--ease-out),
|
|
874
|
+
border-color var(--motion-quick) var(--ease-out),
|
|
875
|
+
scale var(--motion-spring) var(--ease-spring);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.mdbase-checkbox:active:not(:disabled) {
|
|
879
|
+
scale: 0.9;
|
|
880
|
+
transition-duration: var(--motion-press);
|
|
881
|
+
transition-timing-function: var(--ease-out);
|
|
671
882
|
}
|
|
672
883
|
|
|
673
884
|
.mdbase-checkbox:checked,
|
|
@@ -677,21 +888,35 @@ textarea.mdbase-field {
|
|
|
677
888
|
background: var(--color-accent);
|
|
678
889
|
}
|
|
679
890
|
|
|
680
|
-
.
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
891
|
+
/* The tick is two borders of a rotated box. It is wiped in from the left: the clip is a
|
|
892
|
+
half-plane whose edge runs along the box's diagonal, which the rotation stands upright. */
|
|
893
|
+
.mdbase-checkbox::after {
|
|
894
|
+
box-sizing: border-box;
|
|
895
|
+
width: 6px;
|
|
896
|
+
height: 10px;
|
|
684
897
|
margin-top: -2px;
|
|
685
898
|
border-right: 2px solid currentColor;
|
|
686
899
|
border-bottom: 2px solid currentColor;
|
|
687
900
|
content: "";
|
|
688
901
|
transform: rotate(45deg);
|
|
902
|
+
clip-path: polygon(-30px -18px, 30px 42px, -30px 90px);
|
|
903
|
+
transition: clip-path var(--motion-press) var(--ease-exit);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
.mdbase-checkbox:checked::after,
|
|
907
|
+
.mdbase-checkbox[aria-checked="true"]::after {
|
|
908
|
+
clip-path: polygon(-30px -38px, 30px 22px, -30px 90px);
|
|
909
|
+
transition: clip-path var(--motion-slow) var(--ease-out) var(--motion-press);
|
|
689
910
|
}
|
|
690
911
|
|
|
691
912
|
.mdbase-checkbox:indeterminate::after {
|
|
692
913
|
width: 8px;
|
|
693
|
-
|
|
694
|
-
|
|
914
|
+
height: 2px;
|
|
915
|
+
margin: 0;
|
|
916
|
+
border: 0;
|
|
917
|
+
background: currentColor;
|
|
918
|
+
transform: none;
|
|
919
|
+
clip-path: none;
|
|
695
920
|
}
|
|
696
921
|
|
|
697
922
|
.mdbase-checkbox:hover:not(:disabled) {
|
|
@@ -760,6 +985,8 @@ textarea.mdbase-field {
|
|
|
760
985
|
}
|
|
761
986
|
.mdbase-switch > span { background: ButtonText; }
|
|
762
987
|
.mdbase-switch[aria-checked="true"] > span { background: HighlightText; }
|
|
988
|
+
.mdbase-segmented-thumb { border-color: Highlight; background: Highlight; }
|
|
989
|
+
.mdbase-segmented-option:has(:checked) { color: HighlightText; forced-color-adjust: none; }
|
|
763
990
|
}
|
|
764
991
|
|
|
765
992
|
/* Dialogs: a native <dialog> in the top layer, drawn like a popover. */
|
|
@@ -768,10 +995,12 @@ textarea.mdbase-field {
|
|
|
768
995
|
max-height: calc(100dvh - 48px);
|
|
769
996
|
padding: 0;
|
|
770
997
|
border: 1px solid var(--color-border-strong);
|
|
771
|
-
border-radius: var(--
|
|
998
|
+
border-radius: var(--radius-lg);
|
|
772
999
|
color: var(--color-text);
|
|
773
1000
|
background: var(--color-surface-overlay);
|
|
774
1001
|
box-shadow: var(--elevation-high);
|
|
1002
|
+
/* It settles into place from just below, on the spring. */
|
|
1003
|
+
--overlay-from: translateY(8px) scale(0.98);
|
|
775
1004
|
}
|
|
776
1005
|
|
|
777
1006
|
.mdbase-dialog::backdrop {
|
|
@@ -800,6 +1029,17 @@ textarea.mdbase-field {
|
|
|
800
1029
|
text-transform: none;
|
|
801
1030
|
}
|
|
802
1031
|
|
|
1032
|
+
.mdbase-dialog-actions {
|
|
1033
|
+
display: flex;
|
|
1034
|
+
justify-content: flex-end;
|
|
1035
|
+
gap: var(--space-2);
|
|
1036
|
+
margin-top: var(--space-6);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
.mdbase-confirm-dialog {
|
|
1040
|
+
width: min(440px, calc(100vw - 32px));
|
|
1041
|
+
}
|
|
1042
|
+
|
|
803
1043
|
/* Save notices: small, quiet, and gone once there is nothing to act on. */
|
|
804
1044
|
.mdbase-save-notice {
|
|
805
1045
|
display: inline-flex;
|
|
@@ -820,6 +1060,16 @@ textarea.mdbase-field {
|
|
|
820
1060
|
stroke-linejoin: round;
|
|
821
1061
|
}
|
|
822
1062
|
|
|
1063
|
+
/* The saved tick draws itself. A drawn path has pathLength 1 (toast.css draws its marks too). */
|
|
1064
|
+
.mdbase-save-notice svg path {
|
|
1065
|
+
stroke-dasharray: 1;
|
|
1066
|
+
animation: mdbase-draw var(--motion-slow) var(--ease-out) backwards;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
@keyframes mdbase-draw {
|
|
1070
|
+
from { stroke-dashoffset: 1; }
|
|
1071
|
+
}
|
|
1072
|
+
|
|
823
1073
|
.mdbase-save-notice.is-attention {
|
|
824
1074
|
color: var(--color-danger);
|
|
825
1075
|
}
|
|
@@ -854,37 +1104,68 @@ textarea.mdbase-field {
|
|
|
854
1104
|
}
|
|
855
1105
|
}
|
|
856
1106
|
|
|
1107
|
+
/* Durations are zeroed at the tokens (motion.css). What is left is movement that a zero
|
|
1108
|
+
duration still shows. */
|
|
857
1109
|
@media (prefers-reduced-motion: reduce) {
|
|
858
1110
|
/* Without the fade, a confirmation still shows for the same time, then goes. */
|
|
859
1111
|
.mdbase-settle {
|
|
860
1112
|
animation-timing-function: steps(1, end);
|
|
861
1113
|
}
|
|
862
1114
|
|
|
863
|
-
.mdbase-
|
|
864
|
-
.mdbase-icon-button,
|
|
865
|
-
.mdbase-field,
|
|
866
|
-
.mdbase-select,
|
|
867
|
-
.mdbase-select-chevron,
|
|
868
|
-
.mdbase-app-switcher,
|
|
869
|
-
.mdbase-app-switcher-chevron,
|
|
870
|
-
.mdbase-checkbox,
|
|
871
|
-
.mdbase-switch,
|
|
872
|
-
.mdbase-switch > span {
|
|
1115
|
+
.mdbase-tooltip {
|
|
873
1116
|
transition: none;
|
|
874
1117
|
}
|
|
1118
|
+
|
|
1119
|
+
/* A press changes colour only; nothing shrinks or stretches under it. */
|
|
1120
|
+
:is(.mdbase-button, .mdbase-icon-button, .mdbase-checkbox):active:not(:disabled),
|
|
1121
|
+
.mdbase-segmented-option:active:not(:has(:disabled)) {
|
|
1122
|
+
scale: none;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
.mdbase-switch:active:not(:disabled) > span {
|
|
1126
|
+
width: 16px;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
.mdbase-switch[aria-checked="true"]:active:not(:disabled) > span {
|
|
1130
|
+
translate: 14px;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
.mdbase-switch[aria-checked="true"]:dir(rtl):active:not(:disabled) > span {
|
|
1134
|
+
translate: -14px;
|
|
1135
|
+
}
|
|
875
1136
|
}
|
|
876
1137
|
|
|
877
1138
|
/* Mode changes stay inline; progress is text, never an optimistic toggle. */
|
|
878
|
-
.mdbase-collection-mode {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1139
|
+
.mdbase-collection-mode {
|
|
1140
|
+
display: grid;
|
|
1141
|
+
gap: var(--space-3);
|
|
1142
|
+
min-inline-size: 0;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
.mdbase-collection-mode :is(h3, p, ul) {
|
|
1146
|
+
margin-block: 0;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
.mdbase-collection-mode h3 {
|
|
1150
|
+
font-size: var(--font-size-section);
|
|
1151
|
+
font-weight: var(--font-weight-medium);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
.mdbase-collection-mode > div:last-child {
|
|
1155
|
+
display: flex;
|
|
1156
|
+
flex-wrap: wrap;
|
|
1157
|
+
gap: var(--space-2);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.mdbase-collection-mode code {
|
|
1161
|
+
overflow-wrap: anywhere;
|
|
1162
|
+
}
|
|
883
1163
|
|
|
884
1164
|
:focus-visible {
|
|
885
1165
|
outline: var(--focus-ring);
|
|
886
1166
|
outline-offset: var(--focus-offset);
|
|
887
1167
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1168
|
+
|
|
1169
|
+
[role="radio"][aria-checked="true"]:focus-visible {
|
|
1170
|
+
outline: var(--focus-ring);
|
|
1171
|
+
}
|