actual-css 0.20.1 → 0.21.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 +105 -0
- package/README.md +6 -6
- package/components.json +29 -7
- package/dist/actual.full.css +542 -135
- package/dist/actual.full.js +2 -2
- package/dist/actual.full.min.css +1 -1
- package/dist/types/data-flag.d.ts +1 -0
- package/dist/types/enhancement-loader-state.d.ts +6 -0
- package/dist/types/enhancement-loader.d.ts +0 -2
- package/dist/types/parse-config.d.ts +0 -1
- package/dist/types/popover-transport.d.ts +2 -0
- package/dist/types/status.d.ts +0 -1
- package/dist/types/tooltip.d.ts +4 -0
- package/dist/types/validation.d.ts +6 -2
- package/docs/pages/components/app-navigation.md +67 -0
- package/docs/pages/components/button.md +3 -0
- package/docs/pages/components/dialog.md +3 -0
- package/docs/pages/components/list.md +13 -0
- package/docs/pages/components/meter.md +1 -0
- package/docs/pages/components/progress.md +1 -0
- package/docs/pages/components/segmented.md +7 -4
- package/docs/pages/components/table.md +4 -1
- package/docs/pages/components/timeline.md +32 -0
- package/docs/pages/enhancements/flyout.md +12 -3
- package/docs/pages/enhancements/tooltip.md +6 -1
- package/docs/pages/examples/overview.md +30 -1
- package/docs/pages/forms/combobox.md +14 -10
- package/docs/pages/forms/labels.md +7 -0
- package/docs/pages/forms/overview.md +13 -10
- package/docs/pages/forms/range.md +3 -1
- package/docs/pages/forms/validation.md +3 -3
- package/docs/pages/foundations/philosophy.md +26 -0
- package/docs/pages/foundations/theming.md +80 -7
- package/docs/pages/foundations/tokens.md +39 -2
- package/docs/pages/guides/coding-agents.md +11 -0
- package/docs/pages/guides/introduction.md +1 -1
- package/docs/pages/guides/progressive-enhancement.md +109 -19
- package/docs/pages/guides/tailwind.md +12 -6
- package/docs/pages/guides/upgrading.md +52 -0
- package/docs/pages/layout/app-layout.md +50 -1
- package/docs/pages/patterns/empty-state.md +48 -10
- package/forms.json +325 -0
- package/llms.txt +2 -1
- package/package.json +3 -1
- package/reserved-classes.json +2 -0
- package/skills/actual-css/SKILL.md +1 -1
- package/skills/actual-css/references/api-and-vocabulary.md +2 -1
- package/src/cli/actual-css.js +8 -2
- package/src/css/components/app-nav.css +75 -18
- package/src/css/components/avatar.css +1 -0
- package/src/css/components/badge.css +7 -1
- package/src/css/components/button.css +20 -3
- package/src/css/components/flyout.css +8 -2
- package/src/css/components/list.css +28 -13
- package/src/css/components/menu.css +18 -0
- package/src/css/components/meter.css +11 -6
- package/src/css/components/progress.css +14 -6
- package/src/css/components/rating.css +2 -0
- package/src/css/components/segmented.css +22 -12
- package/src/css/components/table.css +21 -2
- package/src/css/components/timeline.css +50 -1
- package/src/css/core/theme.css +11 -1
- package/src/css/core/tokens.css +20 -2
- package/src/css/forms/choice-card.css +6 -4
- package/src/css/forms/choice.css +28 -16
- package/src/css/forms/control.css +23 -16
- package/src/css/forms/custom-select.css +3 -1
- package/src/css/forms/form.css +8 -5
- package/src/css/forms/otp.css +7 -1
- package/src/css/forms/range.css +31 -11
- package/src/css/forms/select.css +13 -4
- package/src/css/forms/switch.css +11 -5
- package/src/css/layout/app-layout.css +104 -5
- package/src/js/data-flag.js +4 -0
- package/src/js/dialog.js +24 -8
- package/src/js/enhancement-loader-state.js +7 -0
- package/src/js/enhancement-loader.js +4 -21
- package/src/js/keys.js +5 -7
- package/src/js/parse-config.js +0 -2
- package/src/js/popover-transport.js +18 -0
- package/src/js/status.js +0 -2
- package/src/js/surface.js +35 -41
- package/src/js/tooltip.js +70 -36
- package/src/js/validation.js +24 -10
- package/src/tooling/css-bundle.js +5 -0
- package/src/tooling/design-tokens.js +9 -2
- package/src/tooling/theme-contrast.js +45 -17
- package/tokens.json +5 -0
|
@@ -18,9 +18,12 @@
|
|
|
18
18
|
* underline-style lower edge instead of a uniform border.
|
|
19
19
|
*
|
|
20
20
|
* --control-default-border is the inherited resting edge, the twin of
|
|
21
|
-
* --control-default-bg:
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* --control-default-bg: theme.css sets both (the quiet --border, and
|
|
22
|
+
* --border-control under increased contrast), and a theme sets them on its
|
|
23
|
+
* root, where --control-border itself is owned by the state rules below.
|
|
24
|
+
* --border-control there is strong field identification; paired with the
|
|
25
|
+
* lower-edge hook it puts the 3:1 cue on the bottom alone. The fallback below
|
|
26
|
+
* is the strong edge, for a page that unsets the token.
|
|
24
27
|
* readonly and disabled reset the lower edge, so an inherited accent or 3:1
|
|
25
28
|
* underline never marks a field the user cannot edit.
|
|
26
29
|
*
|
|
@@ -34,8 +37,8 @@
|
|
|
34
37
|
* --control-shadow
|
|
35
38
|
* --control-border-block-end-color
|
|
36
39
|
* --control-border-block-end-width
|
|
37
|
-
* --control-hover-border
|
|
38
|
-
* --control-hover-bg
|
|
40
|
+
* --control-hover-border
|
|
41
|
+
* --control-hover-bg
|
|
39
42
|
*/
|
|
40
43
|
.input,
|
|
41
44
|
.textarea,
|
|
@@ -60,10 +63,11 @@
|
|
|
60
63
|
background: var(--control-bg);
|
|
61
64
|
color: var(--control-fg);
|
|
62
65
|
/* why: an unset hook, so a theme can give every field a resting elevation
|
|
63
|
-
that focus keeps (see the focus rule)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
that focus keeps (see the focus rule); --shadow-inset recesses fields and
|
|
67
|
+
rails alike. The fallback is none, the same as the focus rule's: a
|
|
68
|
+
transparent 0 0 shadow here made focus transition between two values and
|
|
69
|
+
expose a phantom shadow mid-way. */
|
|
70
|
+
box-shadow: var(--control-shadow, var(--shadow-inset, none));
|
|
67
71
|
font-size: var(--control-font-size);
|
|
68
72
|
cursor: var(--control-cursor);
|
|
69
73
|
/* No outline: none here — the core :focus fallback must survive for browsers
|
|
@@ -83,13 +87,16 @@
|
|
|
83
87
|
resize: vertical;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
/* One hover for every field, so a select never answers differently from the
|
|
91
|
+
input beside it: the edge darkens, and the fill changes once a theme sets
|
|
92
|
+
--control-hover-bg (a theme that clears the hover edge, such as an
|
|
93
|
+
underline or a borderless well, needs one). A readonly field is not
|
|
94
|
+
editable, so it keeps its rest state. */
|
|
95
|
+
.input:hover:not(:disabled, [readonly]),
|
|
96
|
+
.textarea:hover:not(:disabled, [readonly]),
|
|
91
97
|
.select:hover:not(:disabled) {
|
|
92
|
-
--control-
|
|
98
|
+
--control-border: var(--control-hover-border, var(--text-subtle));
|
|
99
|
+
--control-bg: var(--control-hover-bg, var(--control-default-bg, var(--surface)));
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
/* Field focus is an inset outline: offset = -width keeps every pixel inside
|
|
@@ -104,7 +111,7 @@
|
|
|
104
111
|
.select:focus-visible:not(:disabled) {
|
|
105
112
|
outline: var(--focus-ring-width) solid var(--form-invalid-border, var(--focus));
|
|
106
113
|
outline-offset: calc(var(--focus-ring-width) * -1);
|
|
107
|
-
box-shadow: var(--control-shadow, none);
|
|
114
|
+
box-shadow: var(--control-shadow, var(--shadow-inset, none));
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
.input[readonly],
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Customizable select — appearance: base-select picker enhancement.
|
|
3
3
|
*
|
|
4
|
+
* Docs: docs/pages/forms/overview.md
|
|
5
|
+
*
|
|
4
6
|
* Progressive enhancement on top of the native .select baseline in select.css.
|
|
5
7
|
* Wrapped in @supports and gated on fine pointer devices so it never blocks a
|
|
6
8
|
* layout. Add .native to a specific select to opt out.
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
--control-bg: var(--surface-raised);
|
|
49
51
|
outline: var(--focus-ring-width) solid var(--form-invalid-border, var(--focus));
|
|
50
52
|
outline-offset: calc(var(--focus-ring-width) * -1);
|
|
51
|
-
box-shadow: var(--control-shadow, none);
|
|
53
|
+
box-shadow: var(--control-shadow, var(--shadow-inset, none));
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
&::picker-icon {
|
package/src/css/forms/form.css
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* .field-group.flush, .required-mark.
|
|
15
15
|
*
|
|
16
16
|
* Public hooks:
|
|
17
|
+
* --field-label-scale
|
|
17
18
|
* --fieldset-legend-padding-inline
|
|
18
19
|
*/
|
|
19
20
|
.field {
|
|
@@ -41,12 +42,14 @@
|
|
|
41
42
|
own size the hierarchy rested on weight alone, and a stack of medium
|
|
42
43
|
labels read louder than the fields. Medium and the full ink keep it a
|
|
43
44
|
clear read. A fraction of --control-font-size, not a fixed step, so it
|
|
44
|
-
follows .sm/.lg on the .field whatever element holds the label.
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
follows .sm/.lg on the .field whatever element holds the label.
|
|
46
|
+
--field-label-scale is the author hook for that fraction (1 sets labels at
|
|
47
|
+
the field text size); its fallback stays here, not on :root, so the hook
|
|
48
|
+
can be set on any container. The legend titles a group, one level up, and
|
|
49
|
+
is set small inside the frame, so it keeps the heavier weight. */
|
|
47
50
|
.field-label {
|
|
48
51
|
color: var(--text);
|
|
49
|
-
font-size: calc(var(--control-font-size) * 0.875);
|
|
52
|
+
font-size: calc(var(--control-font-size) * var(--field-label-scale, 0.875));
|
|
50
53
|
font-weight: var(--font-weight-medium);
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -72,7 +75,7 @@
|
|
|
72
75
|
.field-group.flush > legend {
|
|
73
76
|
margin-block-end: var(--space-10);
|
|
74
77
|
padding-inline: 0;
|
|
75
|
-
font-size: calc(var(--control-font-size) * 0.875);
|
|
78
|
+
font-size: calc(var(--control-font-size) * var(--field-label-scale, 0.875));
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
.field-help {
|
package/src/css/forms/otp.css
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
--otp-cell-size: var(--control-size);
|
|
22
22
|
--otp-gap: var(--space-10);
|
|
23
23
|
--otp-font-size: 1.5em;
|
|
24
|
-
|
|
24
|
+
/* A text field per cell: the same resting edge as .input. */
|
|
25
|
+
--otp-cell-border: var(--control-default-border, var(--border-control));
|
|
25
26
|
--otp-cell-bg: var(--surface);
|
|
26
27
|
--otp-caret-space: calc((var(--otp-cell-size) - 1ch) / 2 + var(--otp-gap) + 1px);
|
|
27
28
|
|
|
@@ -71,6 +72,11 @@
|
|
|
71
72
|
font-family: var(--font-mono);
|
|
72
73
|
font-size: var(--otp-font-size);
|
|
73
74
|
font-variant-numeric: tabular-nums;
|
|
75
|
+
/* why: one glyph per cell. A code font (JetBrains Mono, Fira Code) joins
|
|
76
|
+
`+++` or `->` through ligatures and contextual alternates; Chromium drops
|
|
77
|
+
them under letter-spacing, Safari keeps them and the glyphs leave their
|
|
78
|
+
cells. */
|
|
79
|
+
font-variant-ligatures: none;
|
|
74
80
|
line-height: var(--otp-cell-size);
|
|
75
81
|
letter-spacing: calc(var(--otp-cell-size) + var(--otp-gap) - 1ch);
|
|
76
82
|
text-align: start;
|
package/src/css/forms/range.css
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* are not reliably applied across browsers.
|
|
10
10
|
*
|
|
11
11
|
* Public hooks:
|
|
12
|
-
* --range-thumb-size
|
|
12
|
+
* --range-thumb-size (the thumb's block size, and the control's)
|
|
13
|
+
* --range-thumb-inline-size
|
|
14
|
+
* --range-thumb-radius
|
|
13
15
|
* --range-track-height
|
|
14
16
|
* --range-thumb-bg
|
|
15
17
|
* --range-track-bg
|
|
@@ -27,6 +29,10 @@
|
|
|
27
29
|
|
|
28
30
|
.range {
|
|
29
31
|
--range-thumb-size: 1.125rem;
|
|
32
|
+
/* The thumb's shape, on vendor pseudo-elements a theme cannot reach in one
|
|
33
|
+
rule. The focus ring is a box-shadow, so it follows both. */
|
|
34
|
+
--range-thumb-inline-size: var(--range-thumb-size);
|
|
35
|
+
--range-thumb-radius: var(--radius-full);
|
|
30
36
|
--range-track-height: 0.625rem;
|
|
31
37
|
--range-thumb-bg: var(--intent, var(--primary));
|
|
32
38
|
--range-track-bg: var(--border);
|
|
@@ -61,6 +67,7 @@
|
|
|
61
67
|
--range-fill-from: to left;
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
/* A rail, recessed with the fields when a theme sets --shadow-inset. */
|
|
64
71
|
.range::-webkit-slider-runnable-track {
|
|
65
72
|
block-size: var(--range-track-height);
|
|
66
73
|
border-radius: var(--radius-full);
|
|
@@ -69,6 +76,7 @@
|
|
|
69
76
|
var(--range-fill-bg) var(--range-progress),
|
|
70
77
|
var(--range-track-bg) var(--range-progress)
|
|
71
78
|
);
|
|
79
|
+
box-shadow: var(--shadow-inset, none);
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
.range::-moz-range-track {
|
|
@@ -79,33 +87,39 @@
|
|
|
79
87
|
var(--range-fill-bg) var(--range-progress),
|
|
80
88
|
var(--range-track-bg) var(--range-progress)
|
|
81
89
|
);
|
|
90
|
+
box-shadow: var(--shadow-inset, none);
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
.range::-webkit-slider-thumb {
|
|
85
94
|
appearance: none;
|
|
86
95
|
-webkit-appearance: none;
|
|
87
|
-
inline-size: var(--range-thumb-size);
|
|
96
|
+
inline-size: var(--range-thumb-inline-size);
|
|
88
97
|
block-size: var(--range-thumb-size);
|
|
89
|
-
border-radius: var(--radius
|
|
98
|
+
border-radius: var(--range-thumb-radius);
|
|
90
99
|
border: 0;
|
|
91
100
|
background: var(--range-thumb-bg);
|
|
92
101
|
margin-block-start: calc((var(--range-track-height) - var(--range-thumb-size)) / 2);
|
|
93
102
|
cursor: inherit;
|
|
94
103
|
/* Permanent surface separator: the fill defaults to the thumb color, so
|
|
95
104
|
without this the thumb would melt into the filled part of the track.
|
|
96
|
-
Focus-visible keeps this ring and adds the --focus ring outside it.
|
|
97
|
-
|
|
105
|
+
Focus-visible keeps this ring and adds the --focus ring outside it. A
|
|
106
|
+
theme's --shadow-control comes last, under both rings. */
|
|
107
|
+
box-shadow:
|
|
108
|
+
0 0 0 2px var(--surface-opaque),
|
|
109
|
+
var(--shadow-control, 0 0 #0000);
|
|
98
110
|
transition: box-shadow var(--duration);
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
.range::-moz-range-thumb {
|
|
102
|
-
inline-size: var(--range-thumb-size);
|
|
114
|
+
inline-size: var(--range-thumb-inline-size);
|
|
103
115
|
block-size: var(--range-thumb-size);
|
|
104
|
-
border-radius: var(--radius
|
|
116
|
+
border-radius: var(--range-thumb-radius);
|
|
105
117
|
border: 0;
|
|
106
118
|
background: var(--range-thumb-bg);
|
|
107
119
|
cursor: inherit;
|
|
108
|
-
box-shadow:
|
|
120
|
+
box-shadow:
|
|
121
|
+
0 0 0 2px var(--surface-opaque),
|
|
122
|
+
var(--shadow-control, 0 0 #0000);
|
|
109
123
|
transition: box-shadow var(--duration);
|
|
110
124
|
}
|
|
111
125
|
|
|
@@ -124,13 +138,15 @@
|
|
|
124
138
|
.range:focus-visible::-webkit-slider-thumb {
|
|
125
139
|
box-shadow:
|
|
126
140
|
0 0 0 2px var(--surface-opaque),
|
|
127
|
-
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus)
|
|
141
|
+
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus),
|
|
142
|
+
var(--shadow-control, 0 0 #0000);
|
|
128
143
|
}
|
|
129
144
|
|
|
130
145
|
.range:focus-visible::-moz-range-thumb {
|
|
131
146
|
box-shadow:
|
|
132
147
|
0 0 0 2px var(--surface-opaque),
|
|
133
|
-
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus)
|
|
148
|
+
0 0 0 calc(2px + var(--focus-ring-width)) var(--focus),
|
|
149
|
+
var(--shadow-control, 0 0 #0000);
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
.range:disabled {
|
|
@@ -148,7 +164,9 @@
|
|
|
148
164
|
and would win the variable, leaving a Canvas-remapped fill.
|
|
149
165
|
The split lives in a background-image, which forced-color-adjust: auto
|
|
150
166
|
drops — so the tracks opt out locally. The colors stay system keywords,
|
|
151
|
-
keeping native contrast adaptation; only the host keeps adjusting.
|
|
167
|
+
keeping native contrast adaptation; only the host keeps adjusting. Opting
|
|
168
|
+
out also keeps a theme's --shadow-inset, which the forced palette would
|
|
169
|
+
drop everywhere else, hence the reset. */
|
|
152
170
|
@media (forced-colors: active) {
|
|
153
171
|
.range {
|
|
154
172
|
--range-track-bg: CanvasText;
|
|
@@ -163,6 +181,7 @@
|
|
|
163
181
|
Highlight var(--range-progress),
|
|
164
182
|
CanvasText var(--range-progress)
|
|
165
183
|
);
|
|
184
|
+
box-shadow: none;
|
|
166
185
|
}
|
|
167
186
|
|
|
168
187
|
.range::-moz-range-track {
|
|
@@ -172,6 +191,7 @@
|
|
|
172
191
|
Highlight var(--range-progress),
|
|
173
192
|
CanvasText var(--range-progress)
|
|
174
193
|
);
|
|
194
|
+
box-shadow: none;
|
|
175
195
|
}
|
|
176
196
|
.range::-webkit-slider-thumb {
|
|
177
197
|
background: ButtonFace;
|
package/src/css/forms/select.css
CHANGED
|
@@ -12,17 +12,25 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Public hooks:
|
|
14
14
|
* --select-icon-size
|
|
15
|
+
* --select-icon-inset
|
|
15
16
|
*/
|
|
16
17
|
/* --select-icon-size is typographic (em), so the reserved slot and the
|
|
17
18
|
pictogram scale with the control's font size, not a fixed rem sliver. */
|
|
18
19
|
.select:not(:is([multiple], [size]:not([size="1"]))) {
|
|
19
20
|
--select-icon-size: 1em;
|
|
21
|
+
/* why: optical, not geometric. The chevron is drawn on the middle half of
|
|
22
|
+
its box (6..18 of 24), so a box at the pad left its ink a quarter icon
|
|
23
|
+
further in than the text on the other side and than the native date,
|
|
24
|
+
time and search icons, which fill their box. Shifting the box by that
|
|
25
|
+
margin puts the ink at the pad. A replacement --icon-chevron that fills
|
|
26
|
+
its box sets this to the pad. */
|
|
27
|
+
--select-icon-inset: calc(var(--control-pad-x) - var(--select-icon-size) * 0.25);
|
|
20
28
|
|
|
21
29
|
appearance: none;
|
|
22
30
|
-webkit-appearance: none;
|
|
23
31
|
padding-inline-end: calc(var(--control-pad-x) * 2 + var(--select-icon-size));
|
|
24
32
|
background-image: var(--icon-chevron);
|
|
25
|
-
background-position: center right var(--
|
|
33
|
+
background-position: center right var(--select-icon-inset);
|
|
26
34
|
background-size: var(--select-icon-size) auto;
|
|
27
35
|
background-repeat: no-repeat;
|
|
28
36
|
}
|
|
@@ -34,15 +42,15 @@
|
|
|
34
42
|
directionality, so the explicit ltr rule neutralizes an outer RTL fallback
|
|
35
43
|
for a nested direction change. */
|
|
36
44
|
[dir="rtl"] .select:not(:is([multiple], [size]:not([size="1"]))) {
|
|
37
|
-
background-position: center left var(--
|
|
45
|
+
background-position: center left var(--select-icon-inset);
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
.select:not(:is([multiple], [size]:not([size="1"]))):dir(ltr) {
|
|
41
|
-
background-position: center right var(--
|
|
49
|
+
background-position: center right var(--select-icon-inset);
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
.select:not(:is([multiple], [size]:not([size="1"]))):dir(rtl) {
|
|
45
|
-
background-position: center left var(--
|
|
53
|
+
background-position: center left var(--select-icon-inset);
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
/* Both forced-colors and prefers-contrast hand the arrow back to the
|
|
@@ -52,6 +60,7 @@
|
|
|
52
60
|
@media (forced-colors: active), (prefers-contrast: more) {
|
|
53
61
|
.select:not(:is([multiple], [size]:not([size="1"]))) {
|
|
54
62
|
appearance: auto;
|
|
63
|
+
-webkit-appearance: auto;
|
|
55
64
|
background-image: none;
|
|
56
65
|
padding-inline-end: var(--control-pad-x);
|
|
57
66
|
}
|
package/src/css/forms/switch.css
CHANGED
|
@@ -76,6 +76,8 @@
|
|
|
76
76
|
border: var(--border-width) solid var(--form-invalid-border, var(--switch-border));
|
|
77
77
|
border-radius: var(--radius-full);
|
|
78
78
|
background: var(--switch-bg);
|
|
79
|
+
/* A rail, recessed with the fields when a theme sets --shadow-inset. */
|
|
80
|
+
box-shadow: var(--shadow-inset, none);
|
|
79
81
|
appearance: none;
|
|
80
82
|
-webkit-appearance: none;
|
|
81
83
|
cursor: pointer;
|
|
@@ -96,11 +98,11 @@
|
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
/*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
against the track is what makes
|
|
101
|
+
/* Never --shadow on the knob: it is a surface elevation (card, modal, drawer,
|
|
102
|
+
fab), and at this size its 12px blur reads as a smudge that spills past the
|
|
103
|
+
rail while carrying no state. A theme lifts it with the control-scale
|
|
104
|
+
--shadow-control; unset, the knob stays flat and the concentric inset
|
|
105
|
+
against the track is what makes it legible. */
|
|
104
106
|
.switch::before {
|
|
105
107
|
content: "";
|
|
106
108
|
/* Out of flow like the checkbox mark, so the track carries no in-flow item
|
|
@@ -116,6 +118,7 @@
|
|
|
116
118
|
block-size: var(--switch-knob-size);
|
|
117
119
|
border-radius: var(--radius-full);
|
|
118
120
|
background: var(--switch-knob);
|
|
121
|
+
box-shadow: var(--shadow-control, none);
|
|
119
122
|
transition:
|
|
120
123
|
transform var(--duration),
|
|
121
124
|
background-color var(--duration);
|
|
@@ -129,10 +132,13 @@
|
|
|
129
132
|
}
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
/* The checked track is a solid fill: it takes the theme finish. */
|
|
132
136
|
.switch:checked {
|
|
133
137
|
--switch-bg: var(--intent, var(--state-selected));
|
|
134
138
|
--switch-border: var(--switch-bg);
|
|
135
139
|
--switch-knob: var(--intent-fg, var(--state-selected-fg));
|
|
140
|
+
|
|
141
|
+
background-image: var(--finish, none);
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
.switch:checked::before {
|
|
@@ -7,11 +7,19 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Docs: docs/pages/layout/app-layout.md
|
|
9
9
|
*
|
|
10
|
+
* data-nav="rail" is the application's desktop preference for a captioned rail.
|
|
11
|
+
* It only changes the side presentation; the bottom bar ignores it. Setting,
|
|
12
|
+
* toggling and persisting it belong to the application.
|
|
13
|
+
*
|
|
10
14
|
* Public hooks:
|
|
11
15
|
* --app-nav-side-size
|
|
16
|
+
* --app-nav-rail-size
|
|
17
|
+
* --app-layout-bar-size
|
|
12
18
|
*/
|
|
13
19
|
.app-layout {
|
|
14
20
|
--app-nav-side-size: 12rem;
|
|
21
|
+
--app-nav-rail-size: 5.5rem;
|
|
22
|
+
--app-layout-bar-size: calc(var(--control-size) + var(--space-30) * 2);
|
|
15
23
|
|
|
16
24
|
display: grid;
|
|
17
25
|
grid-template:
|
|
@@ -58,23 +66,68 @@
|
|
|
58
66
|
/ var(--app-nav-side-size) minmax(0, 1fr);
|
|
59
67
|
}
|
|
60
68
|
|
|
69
|
+
/* A column, not grid rows: the footer takes the free space above it with an
|
|
70
|
+
auto margin. Scrolls on its own when the destinations outgrow a short
|
|
71
|
+
viewport, so the footer follows the last link instead of covering it. */
|
|
72
|
+
/* Where the brand lives decides who owns the top-left corner. A nav header
|
|
73
|
+
claims it, and the nav runs the full height; without one the brand is in
|
|
74
|
+
the topbar, which then spans the navigation as a global bar. Areas only:
|
|
75
|
+
columns stay with the rules above and the rail's, which this selector
|
|
76
|
+
would outweigh. Without :has() the nav keeps the full height. */
|
|
77
|
+
.app-layout:not(:has(> .app-nav > header)) {
|
|
78
|
+
grid-template-areas:
|
|
79
|
+
"topbar topbar"
|
|
80
|
+
"nav main";
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
.app-layout > .app-nav {
|
|
62
84
|
position: sticky;
|
|
63
85
|
inset-block: 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
grid-auto-columns: auto;
|
|
67
|
-
align-content: start;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
68
88
|
gap: var(--space-20);
|
|
69
89
|
min-block-size: 0;
|
|
70
90
|
padding-block: max(var(--space-20), env(safe-area-inset-top))
|
|
71
91
|
max(var(--space-20), env(safe-area-inset-bottom));
|
|
72
92
|
padding-inline: var(--space-20);
|
|
93
|
+
overflow-y: auto;
|
|
73
94
|
border-block-start: 0;
|
|
74
95
|
border-inline-end: var(--border-width) solid var(--ui-border, var(--border));
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
|
|
98
|
+
/* An explicit tile min-size would otherwise let an overflowing column
|
|
99
|
+
shrink a two-line label below its content. */
|
|
100
|
+
.app-layout > .app-nav > * {
|
|
101
|
+
flex: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.app-layout > .app-nav > :is(header, footer) {
|
|
105
|
+
display: grid;
|
|
106
|
+
gap: var(--space-20);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* The nav spans both rows, so its header cannot read the topbar's height.
|
|
110
|
+
Both share one band instead: the header's first row (the brand) centres
|
|
111
|
+
on the topbar's line, a primary action stacks below it, and the first
|
|
112
|
+
destination starts below the band, level with the main region. */
|
|
113
|
+
.app-layout > .topbar {
|
|
114
|
+
min-block-size: calc(var(--app-layout-bar-size) + env(safe-area-inset-top));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.app-layout > .app-nav > header {
|
|
118
|
+
grid-template-rows: var(--app-layout-bar-size);
|
|
119
|
+
align-items: center;
|
|
120
|
+
/* Starts at the nav's border edge, as the topbar does at the viewport's:
|
|
121
|
+
cancels the nav's top padding and re-adds the inset above the band. */
|
|
122
|
+
margin-block-start: calc(max(var(--space-20), env(safe-area-inset-top)) * -1);
|
|
123
|
+
padding-block-start: env(safe-area-inset-top);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.app-layout > .app-nav > footer {
|
|
127
|
+
margin-block-start: auto;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.app-layout > .app-nav > :is(a, button) {
|
|
78
131
|
grid-template-rows: auto;
|
|
79
132
|
grid-template-columns: 1.5rem minmax(0, 1fr);
|
|
80
133
|
place-content: center start;
|
|
@@ -82,9 +135,55 @@
|
|
|
82
135
|
justify-items: start;
|
|
83
136
|
gap: var(--space-30);
|
|
84
137
|
padding-inline: var(--space-30);
|
|
138
|
+
/* The xs caption suits a label under an icon in a cramped bar; beside the
|
|
139
|
+
icon it reads as a navigation link, at body size like .nav-link. */
|
|
140
|
+
font-size: inherit;
|
|
85
141
|
text-align: start;
|
|
86
142
|
}
|
|
87
143
|
|
|
144
|
+
/* A labelled row is the target itself: the state fills the whole row and
|
|
145
|
+
the icon drops its pill (app-nav.css), back to a plain glyph. */
|
|
146
|
+
.app-layout:not([data-nav="rail"]) > .app-nav > :is(a, button) {
|
|
147
|
+
background: var(--app-nav-fill, transparent);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.app-layout:not([data-nav="rail"]) > .app-nav > a[aria-current="page"] {
|
|
151
|
+
color: var(--app-nav-ink);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.app-layout:not([data-nav="rail"])
|
|
155
|
+
> .app-nav
|
|
156
|
+
> :is(a, button)
|
|
157
|
+
> :where(svg, img, [aria-hidden="true"]) {
|
|
158
|
+
padding: 0;
|
|
159
|
+
background: none;
|
|
160
|
+
color: inherit;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.app-layout[data-nav="rail"] {
|
|
164
|
+
grid-template-columns: var(--app-nav-rail-size) minmax(0, 1fr);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* The rail keeps a caption under each icon, the bottom bar's tile turned
|
|
168
|
+
upright: a visible label needs no tooltip and names the tile for everyone.
|
|
169
|
+
The track fits single-word xs captions ("Notifications" measured 76px),
|
|
170
|
+
with the nav's inline padding narrowed so the tile keeps that width; two
|
|
171
|
+
words wrap onto a second line. */
|
|
172
|
+
.app-layout[data-nav="rail"] > .app-nav {
|
|
173
|
+
padding-inline: var(--space-10);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.app-layout[data-nav="rail"] > .app-nav > :is(a, button) {
|
|
177
|
+
grid-template-rows: auto auto;
|
|
178
|
+
grid-template-columns: auto;
|
|
179
|
+
place-content: center;
|
|
180
|
+
justify-items: center;
|
|
181
|
+
gap: var(--space-10);
|
|
182
|
+
padding: var(--space-10) 0;
|
|
183
|
+
font-size: var(--font-size-xs);
|
|
184
|
+
text-align: center;
|
|
185
|
+
}
|
|
186
|
+
|
|
88
187
|
/* In the side layout the FAB owns the viewport's bottom safe-area inset. */
|
|
89
188
|
.app-layout > .fab {
|
|
90
189
|
margin-block-end: max(var(--fab-offset), env(safe-area-inset-bottom));
|
package/src/js/dialog.js
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
import { registerCommands, targetFor } from "./command.js";
|
|
33
|
+
import { readDataFlag } from "./data-flag.js";
|
|
33
34
|
import enhance, { registerEnhancement } from "./enhance.js";
|
|
34
35
|
import { EVENTS } from "./events.js";
|
|
35
36
|
import { submissionSetting } from "./form-submission.js";
|
|
@@ -65,10 +66,6 @@ function allowsDialogEnhancement(dialog) {
|
|
|
65
66
|
return true;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function boolData(el, name) {
|
|
69
|
-
return el.hasAttribute(name) && el.getAttribute(name) !== "false";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
69
|
function setOwnedAttribute(state, el, name, value) {
|
|
73
70
|
const current = el.getAttribute(name);
|
|
74
71
|
if (current === value) return;
|
|
@@ -136,7 +133,7 @@ function syncDialogSemantics(dialog, state, modal = isModal(dialog)) {
|
|
|
136
133
|
}
|
|
137
134
|
|
|
138
135
|
function isModal(dialog) {
|
|
139
|
-
return dialog
|
|
136
|
+
return readDataFlag(dialog, "data-dialog-modal", true);
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
function resolveModalMode(dialog, forcedModal = null) {
|
|
@@ -190,11 +187,11 @@ function syncModalOpenClass(doc = document) {
|
|
|
190
187
|
}
|
|
191
188
|
|
|
192
189
|
function isDismissible(dialog) {
|
|
193
|
-
return
|
|
190
|
+
return readDataFlag(dialog, "data-dialog-dismissible");
|
|
194
191
|
}
|
|
195
192
|
|
|
196
193
|
function wantsViewTransition(dialog) {
|
|
197
|
-
return
|
|
194
|
+
return readDataFlag(dialog, "data-dialog-view-transition");
|
|
198
195
|
}
|
|
199
196
|
|
|
200
197
|
const VT_NAME = "actual-dialog";
|
|
@@ -359,6 +356,7 @@ function showDialog(dialog, focusReturn, forcedModal) {
|
|
|
359
356
|
const viewport = dialog.ownerDocument.defaultView;
|
|
360
357
|
const scrollX = viewport?.scrollX ?? 0;
|
|
361
358
|
const scrollY = viewport?.scrollY ?? 0;
|
|
359
|
+
const indicated = dialog.ownerDocument.activeElement?.matches(":focus-visible") === true;
|
|
362
360
|
|
|
363
361
|
if (modal) {
|
|
364
362
|
dialog.showModal();
|
|
@@ -367,6 +365,7 @@ function showDialog(dialog, focusReturn, forcedModal) {
|
|
|
367
365
|
dialog.show();
|
|
368
366
|
state.modalOpen = false;
|
|
369
367
|
}
|
|
368
|
+
if (!indicated) quietInitialFocus(dialog);
|
|
370
369
|
|
|
371
370
|
if (scrollX !== 0 || scrollY > 0) {
|
|
372
371
|
viewport?.scrollTo(scrollX, scrollY);
|
|
@@ -375,6 +374,23 @@ function showDialog(dialog, focusReturn, forcedModal) {
|
|
|
375
374
|
syncModalOpenClass(dialog.ownerDocument);
|
|
376
375
|
}
|
|
377
376
|
|
|
377
|
+
/*
|
|
378
|
+
* WebKit shows the focus ring on the control showModal() focuses even when a
|
|
379
|
+
* tap or a click opened the dialog, so a Cancel button looked pressed on an
|
|
380
|
+
* iPad. Chromium and Firefox follow the opening's modality: the ring shows
|
|
381
|
+
* only when the element focused before it showed one. Refocusing with
|
|
382
|
+
* focusVisible: false brings WebKit in line; it needs the blur, since focusing
|
|
383
|
+
* the active element again is a no-op. Text fields keep their ring in every
|
|
384
|
+
* engine, whatever the modality.
|
|
385
|
+
*/
|
|
386
|
+
function quietInitialFocus(dialog) {
|
|
387
|
+
const focused = dialog.ownerDocument.activeElement;
|
|
388
|
+
if (!focused || !dialog.contains(focused) || !focused.matches(":focus-visible")) return;
|
|
389
|
+
if (focused.matches("input, textarea, select, [contenteditable]")) return;
|
|
390
|
+
focused.blur();
|
|
391
|
+
focused.focus({ focusVisible: false, preventScroll: true });
|
|
392
|
+
}
|
|
393
|
+
|
|
378
394
|
function handleDialogPointerDown(event) {
|
|
379
395
|
const dialog = event.currentTarget;
|
|
380
396
|
const state = dialogMap.get(dialog);
|
|
@@ -558,7 +574,7 @@ function swallowNextClose(dialog) {
|
|
|
558
574
|
without JavaScript, non-modally; the runtime upgrades it to its modal mode.
|
|
559
575
|
A reinserted node does not reopen; a new node does. */
|
|
560
576
|
function autoOpen(dialog) {
|
|
561
|
-
if (!
|
|
577
|
+
if (!readDataFlag(dialog, "data-dialog-open") || autoOpened.has(dialog)) return;
|
|
562
578
|
if (dialog.open) {
|
|
563
579
|
// Already modal (a command came first), or meant to stay non-modal.
|
|
564
580
|
if (isModalOpen(dialog) || !isModal(dialog)) {
|