glasslikeui 1.6.1 → 1.8.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/LICENSE +373 -674
- package/README.md +299 -4
- package/dist/actions/dragSnap.d.ts +16 -39
- package/dist/actions/dragSnap.js +6 -224
- package/dist/actions/dragSnapMath.d.ts +68 -0
- package/dist/actions/dragSnapMath.js +166 -0
- package/dist/actions/dragSurface.d.ts +26 -0
- package/dist/actions/dragSurface.js +187 -0
- package/dist/actions/focusRingFit.d.ts +22 -0
- package/dist/actions/focusRingFit.js +115 -0
- package/dist/actions/focusTrap.d.ts +22 -0
- package/dist/actions/focusTrap.js +103 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/inertSiblings.d.ts +10 -0
- package/dist/actions/inertSiblings.js +35 -0
- package/dist/actions/reducedMotion.d.ts +25 -0
- package/dist/actions/reducedMotion.js +26 -0
- package/dist/actions/sheetBodyDrag.d.ts +14 -0
- package/dist/actions/sheetBodyDrag.js +26 -0
- package/dist/actions/sheetExit.d.ts +36 -0
- package/dist/actions/sheetExit.js +65 -0
- package/dist/actions/swipeActions.d.ts +14 -5
- package/dist/actions/swipeActions.js +89 -16
- package/dist/actions/viewTransition.d.ts +2 -1
- package/dist/actions/viewTransition.js +4 -2
- package/dist/components/glass/Glass.svelte +97 -6
- package/dist/components/glass/GlassMorph.svelte +21 -0
- package/dist/components/glass/Sheet.svelte +243 -61
- package/dist/components/glass/Sheet.svelte.d.ts +7 -1
- package/dist/components/interactive/Badge.svelte +2 -1
- package/dist/components/interactive/Button.svelte +164 -18
- package/dist/components/interactive/IconButton.svelte +23 -1
- package/dist/components/interactive/TabView.svelte +24 -1
- package/dist/components/interactive/Toggle.svelte +22 -4
- package/dist/components/layout/ScrollView.svelte +6 -0
- package/dist/components/list/ListRow.svelte +43 -9
- package/dist/components/menu/Menu.svelte +23 -0
- package/dist/components/menu/MenuItem.svelte +15 -2
- package/dist/components/navigation/NavigationLink.svelte +38 -2
- package/dist/components/typography/Text.svelte +2 -2
- package/dist/constants/shapes.d.ts +7 -0
- package/dist/constants/shapes.js +16 -0
- package/dist/styles/glasslikeui.css +143 -15
- package/dist/styles/lens.css +77 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
3
4
|
import { glassButtonVars, type ButtonVariant } from '../../constants/variants';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
@@ -52,16 +53,21 @@
|
|
|
52
53
|
</script>
|
|
53
54
|
|
|
54
55
|
{#if href}
|
|
56
|
+
<!-- A disabled link keeps its element but loses its destination: with no href
|
|
57
|
+
it cannot be focused or followed. The role keeps it announced as a link. -->
|
|
55
58
|
<a
|
|
56
|
-
{href}
|
|
57
|
-
{target}
|
|
58
|
-
rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}
|
|
59
|
+
href={disabled ? undefined : href}
|
|
60
|
+
target={disabled ? undefined : target}
|
|
61
|
+
rel={disabled ? undefined : (rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined))}
|
|
62
|
+
role={disabled ? 'link' : undefined}
|
|
63
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
59
64
|
class="button variant-{variant} size-{size} {className}"
|
|
60
65
|
class:full-width={fullWidth}
|
|
61
66
|
class:disabled
|
|
62
67
|
class:is-glass={!!glass}
|
|
63
68
|
class:is-tinted={glass?.tinted}
|
|
64
|
-
onclick={onclick}
|
|
69
|
+
onclick={disabled ? undefined : onclick}
|
|
70
|
+
{@attach fitFocusRing}
|
|
65
71
|
style="
|
|
66
72
|
--btn-padding: {styles.padding};
|
|
67
73
|
--btn-font-size: {styles.fontSize};
|
|
@@ -79,6 +85,7 @@
|
|
|
79
85
|
{disabled}
|
|
80
86
|
{onclick}
|
|
81
87
|
{type}
|
|
88
|
+
{@attach fitFocusRing}
|
|
82
89
|
style="
|
|
83
90
|
--btn-padding: {styles.padding};
|
|
84
91
|
--btn-font-size: {styles.fontSize};
|
|
@@ -106,12 +113,34 @@
|
|
|
106
113
|
transition: all var(--transition-fast);
|
|
107
114
|
position: relative;
|
|
108
115
|
overflow: hidden;
|
|
116
|
+
/* The accent as text, from this button's own accent colour. */
|
|
117
|
+
--_accent-text: var(--color-accent-text, color-mix(in srgb, var(--color-accent) var(--glass-accent-text-strength, 33%), var(--glass-text-toward, white)));
|
|
118
|
+
--_accent-text-hover: var(--color-accent-text-hover, var(--color-accent-text, color-mix(in srgb, var(--color-accent) var(--glass-accent-text-strength-hover, 26%), var(--glass-text-toward, white))));
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
.button.full-width {
|
|
112
122
|
width: 100%;
|
|
113
123
|
}
|
|
114
124
|
|
|
125
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
126
|
+
focus rules win. */
|
|
127
|
+
:where(.button:focus-visible) {
|
|
128
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
129
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* The same ring moved inside, for a part flush in a container that would clip
|
|
133
|
+
it (see focusRingFit). The label colour stands out on the part's own fill. */
|
|
134
|
+
:where(.button:global([data-focus-ring='inset']):focus-visible) {
|
|
135
|
+
outline-color: var(--glass-focus-ring-color, currentColor);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
139
|
+
the container cuts it off. Only the offset outranks it. */
|
|
140
|
+
.button:global([data-focus-ring='inset']):where(:focus-visible) {
|
|
141
|
+
outline-offset: calc(-2 * var(--glass-focus-ring-width, 2px));
|
|
142
|
+
}
|
|
143
|
+
|
|
115
144
|
.button.disabled {
|
|
116
145
|
opacity: 0.5;
|
|
117
146
|
pointer-events: none;
|
|
@@ -120,7 +149,7 @@
|
|
|
120
149
|
/* Filled variant */
|
|
121
150
|
.button.variant-filled {
|
|
122
151
|
background: var(--color-accent);
|
|
123
|
-
color: white;
|
|
152
|
+
color: var(--color-on-accent, white);
|
|
124
153
|
box-shadow: 0 4px 16px -4px var(--color-accent-50);
|
|
125
154
|
}
|
|
126
155
|
|
|
@@ -137,14 +166,14 @@
|
|
|
137
166
|
/* Outlined variant */
|
|
138
167
|
.button.variant-outlined {
|
|
139
168
|
background: transparent;
|
|
140
|
-
color: var(--
|
|
169
|
+
color: var(--_accent-text);
|
|
141
170
|
border: 1.5px solid var(--color-accent);
|
|
142
171
|
}
|
|
143
172
|
|
|
144
173
|
.button.variant-outlined:hover {
|
|
145
174
|
background: var(--color-accent-10);
|
|
146
175
|
border-color: var(--color-accent-hover);
|
|
147
|
-
color: var(--
|
|
176
|
+
color: var(--_accent-text-hover);
|
|
148
177
|
}
|
|
149
178
|
|
|
150
179
|
.button.variant-outlined:active {
|
|
@@ -154,23 +183,23 @@
|
|
|
154
183
|
/* Plain variant */
|
|
155
184
|
.button.variant-plain {
|
|
156
185
|
background: transparent;
|
|
157
|
-
color: var(--
|
|
186
|
+
color: var(--_accent-text);
|
|
158
187
|
}
|
|
159
188
|
|
|
160
189
|
.button.variant-plain:hover {
|
|
161
|
-
color: var(--
|
|
190
|
+
color: var(--_accent-text-hover);
|
|
162
191
|
text-decoration: underline;
|
|
163
192
|
}
|
|
164
193
|
|
|
165
194
|
/* Tinted variant */
|
|
166
195
|
.button.variant-tinted {
|
|
167
196
|
background: var(--color-accent-15);
|
|
168
|
-
color: var(--
|
|
197
|
+
color: var(--_accent-text);
|
|
169
198
|
}
|
|
170
199
|
|
|
171
200
|
.button.variant-tinted:hover {
|
|
172
201
|
background: var(--color-accent-25);
|
|
173
|
-
color: var(--
|
|
202
|
+
color: var(--_accent-text-hover);
|
|
174
203
|
}
|
|
175
204
|
|
|
176
205
|
.button.variant-tinted:active {
|
|
@@ -184,6 +213,11 @@
|
|
|
184
213
|
isolation: isolate;
|
|
185
214
|
}
|
|
186
215
|
|
|
216
|
+
/* A page can restyle the fill with --glass-button-fill, and its hover and
|
|
217
|
+
pressed fills with --glass-button-fill-hover and -active. Unset, those two
|
|
218
|
+
follow --glass-button-fill if that is set. Reduced transparency reads none
|
|
219
|
+
of them. */
|
|
220
|
+
|
|
187
221
|
/* Both layers sit at negative z-index inside the isolated button: behind the
|
|
188
222
|
label, which is unpositioned and would otherwise be painted over. */
|
|
189
223
|
.button.is-glass::before {
|
|
@@ -192,7 +226,9 @@
|
|
|
192
226
|
inset: 0;
|
|
193
227
|
z-index: -1;
|
|
194
228
|
border-radius: inherit;
|
|
195
|
-
|
|
229
|
+
/* Smoked glass: whatever is behind, even white, the fill stays dark enough
|
|
230
|
+
for a light label at 4.5:1. A white fill cannot over a bright backdrop. */
|
|
231
|
+
background: var(--glass-button-fill, rgba(62, 62, 64, 0.75));
|
|
196
232
|
backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
|
|
197
233
|
-webkit-backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
|
|
198
234
|
pointer-events: none;
|
|
@@ -214,22 +250,41 @@
|
|
|
214
250
|
z-index: 2;
|
|
215
251
|
}
|
|
216
252
|
|
|
253
|
+
/* Deepens on hover and press: brightening would cost the label its contrast. */
|
|
217
254
|
.button.is-glass:hover::before {
|
|
218
|
-
background:
|
|
255
|
+
background: var(--glass-button-fill-hover, var(--glass-button-fill, rgba(50, 50, 52, 0.75)));
|
|
219
256
|
}
|
|
220
257
|
|
|
221
258
|
.button.is-glass:active::before {
|
|
222
|
-
background:
|
|
259
|
+
background: var(--glass-button-fill-active, var(--glass-button-fill, rgba(38, 38, 40, 0.75)));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* The light theme has a dark label, so its white fill is opaque enough to hold
|
|
263
|
+
it at 4.5:1 even over black, and brightens on hover and press. :where adds
|
|
264
|
+
no specificity, so the prominent and reduced transparency rules below still
|
|
265
|
+
win. */
|
|
266
|
+
:global(:where(:root[data-theme='light'])) .button.is-glass::before {
|
|
267
|
+
background: var(--glass-button-fill, rgba(255, 255, 255, 0.55));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
:global(:where(:root[data-theme='light'])) .button.is-glass:hover::before {
|
|
271
|
+
background: var(--glass-button-fill-hover, var(--glass-button-fill, rgba(255, 255, 255, 0.65)));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
:global(:where(:root[data-theme='light'])) .button.is-glass:active::before {
|
|
275
|
+
background: var(--glass-button-fill-active, var(--glass-button-fill, rgba(255, 255, 255, 0.75)));
|
|
223
276
|
}
|
|
224
277
|
|
|
278
|
+
/* Prominent glass: a see-through accent fill, shaded so the label holds 4.5:1
|
|
279
|
+
whatever is behind it. An accent label on an accent wash could not. */
|
|
225
280
|
.button.is-glass.is-tinted {
|
|
226
|
-
color: var(--color-accent);
|
|
281
|
+
color: var(--color-on-accent, white);
|
|
227
282
|
}
|
|
228
283
|
|
|
229
284
|
.button.is-glass.is-tinted::before {
|
|
230
285
|
background: color-mix(
|
|
231
286
|
in srgb,
|
|
232
|
-
|
|
287
|
+
color-mix(in srgb, var(--color-accent) 80%, black) 84%,
|
|
233
288
|
transparent
|
|
234
289
|
);
|
|
235
290
|
}
|
|
@@ -237,15 +292,100 @@
|
|
|
237
292
|
.button.is-glass.is-tinted:hover::before {
|
|
238
293
|
background: color-mix(
|
|
239
294
|
in srgb,
|
|
240
|
-
|
|
295
|
+
color-mix(in srgb, var(--color-accent) 76%, black) 84%,
|
|
296
|
+
transparent
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.button.is-glass.is-tinted:active::before {
|
|
301
|
+
background: color-mix(
|
|
302
|
+
in srgb,
|
|
303
|
+
color-mix(in srgb, var(--color-accent) 72%, black) 84%,
|
|
241
304
|
transparent
|
|
242
305
|
);
|
|
243
306
|
}
|
|
244
307
|
|
|
308
|
+
/* Reduced transparency: no see-through layer, and a solid fill on the button
|
|
309
|
+
itself, where contrast checkers can read it and no fill or rule given to
|
|
310
|
+
::before can cover it. Plain glass mixes its white fill into the surface
|
|
311
|
+
colour. Prominent glass becomes solid accent, shaded on hover and press from
|
|
312
|
+
the accent where the button is, so a wrapper's own accent carries through.
|
|
313
|
+
The attribute works on the root or on any ancestor. */
|
|
314
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
315
|
+
.button.is-glass::before {
|
|
316
|
+
content: none;
|
|
317
|
+
}
|
|
318
|
+
.button.is-glass {
|
|
319
|
+
background: color-mix(
|
|
320
|
+
in srgb,
|
|
321
|
+
white calc(var(--btn-glass-opacity) * 93%),
|
|
322
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
.button.is-glass:hover {
|
|
326
|
+
background: color-mix(
|
|
327
|
+
in srgb,
|
|
328
|
+
white calc(var(--btn-glass-opacity) * 76%),
|
|
329
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
.button.is-glass:active {
|
|
333
|
+
background: color-mix(
|
|
334
|
+
in srgb,
|
|
335
|
+
white calc(var(--btn-glass-opacity) * 60%),
|
|
336
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
.button.is-glass.is-tinted {
|
|
340
|
+
color: var(--color-on-accent, white);
|
|
341
|
+
background: var(--color-accent);
|
|
342
|
+
}
|
|
343
|
+
.button.is-glass.is-tinted:hover {
|
|
344
|
+
background: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
345
|
+
}
|
|
346
|
+
.button.is-glass.is-tinted:active {
|
|
347
|
+
background: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass::before {
|
|
351
|
+
content: none;
|
|
352
|
+
}
|
|
353
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass {
|
|
354
|
+
background: color-mix(
|
|
355
|
+
in srgb,
|
|
356
|
+
white calc(var(--btn-glass-opacity) * 93%),
|
|
357
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass:hover {
|
|
361
|
+
background: color-mix(
|
|
362
|
+
in srgb,
|
|
363
|
+
white calc(var(--btn-glass-opacity) * 76%),
|
|
364
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass:active {
|
|
368
|
+
background: color-mix(
|
|
369
|
+
in srgb,
|
|
370
|
+
white calc(var(--btn-glass-opacity) * 60%),
|
|
371
|
+
rgb(var(--glass-surface-color, 28, 28, 30))
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass.is-tinted {
|
|
375
|
+
color: var(--color-on-accent, white);
|
|
376
|
+
background: var(--color-accent);
|
|
377
|
+
}
|
|
378
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass.is-tinted:hover {
|
|
379
|
+
background: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
380
|
+
}
|
|
381
|
+
:global(:where([data-reduced-transparency='true'])) .button.is-glass.is-tinted:active {
|
|
382
|
+
background: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
383
|
+
}
|
|
384
|
+
|
|
245
385
|
/* Destructive variant */
|
|
246
386
|
.button.variant-destructive {
|
|
247
387
|
background: var(--color-danger);
|
|
248
|
-
color: white;
|
|
388
|
+
color: var(--color-on-danger, white);
|
|
249
389
|
box-shadow: 0 4px 16px -4px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
250
390
|
}
|
|
251
391
|
|
|
@@ -258,4 +398,10 @@
|
|
|
258
398
|
background: var(--color-danger-active);
|
|
259
399
|
box-shadow: 0 2px 10px -4px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
260
400
|
}
|
|
401
|
+
/* The inner tone of the focus ring, filling the gap inside the outline. Two
|
|
402
|
+
tones hold 3:1 against any backdrop, which one cannot. Doubled and placed
|
|
403
|
+
last so the variant shadows do not hide it. */
|
|
404
|
+
.button.button:focus-visible {
|
|
405
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
406
|
+
}
|
|
261
407
|
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
5
6
|
children: Snippet;
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
{onclick}
|
|
39
40
|
{disabled}
|
|
40
41
|
{type}
|
|
42
|
+
{@attach fitFocusRing}
|
|
41
43
|
style="--btn-size: {sizeMap[size]}px"
|
|
42
44
|
>
|
|
43
45
|
{@render children()}
|
|
@@ -62,6 +64,26 @@
|
|
|
62
64
|
color: var(--color-text);
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
68
|
+
focus rules win. */
|
|
69
|
+
:where(.icon-button:focus-visible) {
|
|
70
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
71
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
72
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* The same ring moved inside, for a part flush in a container that would clip
|
|
76
|
+
it (see focusRingFit). The label colour stands out on the part's own fill. */
|
|
77
|
+
:where(.icon-button:global([data-focus-ring='inset']):focus-visible) {
|
|
78
|
+
outline-color: var(--glass-focus-ring-color, currentColor);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
82
|
+
the container cuts it off. Only the offset outranks it. */
|
|
83
|
+
.icon-button:global([data-focus-ring='inset']):where(:focus-visible) {
|
|
84
|
+
outline-offset: calc(-2 * var(--glass-focus-ring-width, 2px));
|
|
85
|
+
}
|
|
86
|
+
|
|
65
87
|
.icon-button:disabled {
|
|
66
88
|
opacity: 0.5;
|
|
67
89
|
pointer-events: none;
|
|
@@ -77,7 +99,7 @@
|
|
|
77
99
|
|
|
78
100
|
.icon-button.variant-filled {
|
|
79
101
|
background: var(--color-accent);
|
|
80
|
-
color: white;
|
|
102
|
+
color: var(--color-on-accent, white);
|
|
81
103
|
}
|
|
82
104
|
|
|
83
105
|
.icon-button.variant-filled:hover {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { onMount } from 'svelte';
|
|
4
4
|
import { Glass } from '../glass';
|
|
5
5
|
import { HStack } from '../layout';
|
|
6
|
+
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
6
7
|
|
|
7
8
|
interface Tab {
|
|
8
9
|
id: string;
|
|
@@ -103,6 +104,7 @@
|
|
|
103
104
|
class:active={activeTab === tab.id}
|
|
104
105
|
onclick={() => selectTab(tab.id)}
|
|
105
106
|
bind:this={buttonEls[tab.id]}
|
|
107
|
+
{@attach fitFocusRing}
|
|
106
108
|
>
|
|
107
109
|
{#if tab.icon}
|
|
108
110
|
<span class="tab-icon">{@render tab.icon()}</span>
|
|
@@ -196,6 +198,27 @@
|
|
|
196
198
|
font-weight: 500;
|
|
197
199
|
cursor: pointer;
|
|
198
200
|
transition: color var(--transition-fast);
|
|
201
|
+
--_accent-text: var(--color-accent-text, color-mix(in srgb, var(--color-accent) var(--glass-accent-text-strength, 33%), var(--glass-text-toward, white)));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
205
|
+
focus rules win. */
|
|
206
|
+
:where(.tab-item:focus-visible) {
|
|
207
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
208
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
209
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* The same ring moved inside, for a part flush in a container that would clip
|
|
213
|
+
it (see focusRingFit). The label colour stands out on the part's own fill. */
|
|
214
|
+
:where(.tab-item:global([data-focus-ring='inset']):focus-visible) {
|
|
215
|
+
outline-color: var(--glass-focus-ring-color, currentColor);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
219
|
+
the container cuts it off. Only the offset outranks it. */
|
|
220
|
+
.tab-item:global([data-focus-ring='inset']):where(:focus-visible) {
|
|
221
|
+
outline-offset: calc(-2 * var(--glass-focus-ring-width, 2px));
|
|
199
222
|
}
|
|
200
223
|
|
|
201
224
|
.tab-item:not(.active):hover {
|
|
@@ -203,7 +226,7 @@
|
|
|
203
226
|
}
|
|
204
227
|
|
|
205
228
|
.tab-item.active {
|
|
206
|
-
color: var(--
|
|
229
|
+
color: var(--_accent-text);
|
|
207
230
|
}
|
|
208
231
|
|
|
209
232
|
.tab-icon,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
3
|
+
|
|
2
4
|
interface Props {
|
|
3
5
|
/** Two-way bound on/off state. */
|
|
4
6
|
checked?: boolean;
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
aria-checked={checked}
|
|
40
42
|
{disabled}
|
|
41
43
|
onchange={handleChange}
|
|
44
|
+
{@attach (input: HTMLInputElement) => fitFocusRing(input, (node) => node.nextElementSibling)}
|
|
42
45
|
/>
|
|
43
46
|
<span class="toggle-track" aria-hidden="true">
|
|
44
47
|
<span class="toggle-thumb"></span>
|
|
@@ -96,15 +99,30 @@
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
.toggle-input:checked ~ .toggle-track {
|
|
99
|
-
background: var(--color-accent);
|
|
102
|
+
background: var(--glass-track-checked, var(--color-accent));
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
.toggle-input:checked ~ .toggle-track .toggle-thumb {
|
|
103
106
|
transform: translateX(20px);
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
110
|
+
focus rules win. */
|
|
111
|
+
:where(.toggle-input:focus-visible ~ .toggle-track) {
|
|
112
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
113
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
114
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* The same ring moved inside, for a part flush in a container that would clip
|
|
118
|
+
it (see focusRingFit). The label colour stands out on the part's own fill. */
|
|
119
|
+
:where(.toggle-input:focus-visible ~ .toggle-track:global([data-focus-ring='inset'])) {
|
|
120
|
+
outline-color: var(--glass-focus-ring-color, currentColor);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
124
|
+
the container cuts it off. Only the offset outranks it. */
|
|
125
|
+
.toggle-input:where(:focus-visible) ~ .toggle-track:global([data-focus-ring='inset']) {
|
|
126
|
+
outline-offset: calc(-2 * var(--glass-focus-ring-width, 2px));
|
|
109
127
|
}
|
|
110
128
|
</style>
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
const isInteractive = $derived(interactive || !!href || !!onclick);
|
|
46
46
|
|
|
47
47
|
let actionsElement = $state<HTMLElement | null>(null);
|
|
48
|
+
let swipeRowElement = $state<HTMLElement | null>(null);
|
|
48
49
|
</script>
|
|
49
50
|
|
|
50
51
|
{#snippet rowInner()}
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
{/snippet}
|
|
107
108
|
|
|
108
109
|
{#if swipeActions}
|
|
109
|
-
<div class="swipe-row">
|
|
110
|
+
<div class="swipe-row" bind:this={swipeRowElement}>
|
|
110
111
|
<!-- Behind the row until revealed, so it stays out of the reading order. -->
|
|
111
112
|
<div
|
|
112
113
|
class="swipe-actions"
|
|
@@ -121,6 +122,7 @@
|
|
|
121
122
|
{@attach fromAction(swipeGesture, () => ({
|
|
122
123
|
edge: swipeEdge,
|
|
123
124
|
actionsElement,
|
|
125
|
+
stateElement: swipeRowElement,
|
|
124
126
|
allowsFullSwipe,
|
|
125
127
|
onFullSwipe
|
|
126
128
|
}))}
|
|
@@ -150,6 +152,19 @@
|
|
|
150
152
|
cursor: pointer;
|
|
151
153
|
}
|
|
152
154
|
|
|
155
|
+
/* Shared focus ring, drawn inside because the container clips. :where keeps
|
|
156
|
+
it at zero specificity, so a page's own focus rules win. */
|
|
157
|
+
:where(.list-row:focus-visible) {
|
|
158
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
159
|
+
box-shadow: inset 0 0 0 calc(2 * var(--glass-focus-ring-width, 2px)) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
163
|
+
the container cuts it off. Only the offset outranks it. */
|
|
164
|
+
.list-row:where(:focus-visible) {
|
|
165
|
+
outline-offset: calc(-1 * var(--glass-focus-ring-width, 2px));
|
|
166
|
+
}
|
|
167
|
+
|
|
153
168
|
.list-row.interactive:hover {
|
|
154
169
|
background: var(--glass-hover-subtle);
|
|
155
170
|
}
|
|
@@ -201,7 +216,9 @@
|
|
|
201
216
|
color: var(--color-text-tertiary);
|
|
202
217
|
}
|
|
203
218
|
|
|
204
|
-
/* Swipe actions
|
|
219
|
+
/* Swipe actions. The action writes --swipe-x, --swipe-reveal and
|
|
220
|
+
data-swipe-state onto .swipe-row, so the content and the strip read the
|
|
221
|
+
same numbers and cannot drift apart. */
|
|
205
222
|
.swipe-row {
|
|
206
223
|
position: relative;
|
|
207
224
|
overflow: hidden;
|
|
@@ -213,6 +230,9 @@
|
|
|
213
230
|
bottom: 0;
|
|
214
231
|
display: flex;
|
|
215
232
|
align-items: stretch;
|
|
233
|
+
/* Natural width, or the revealed distance when the row is dragged
|
|
234
|
+
further: the strip always reaches the content's edge. */
|
|
235
|
+
min-width: var(--swipe-reveal, 0px);
|
|
216
236
|
}
|
|
217
237
|
|
|
218
238
|
.swipe-actions[data-swipe-edge='trailing'] {
|
|
@@ -223,6 +243,17 @@
|
|
|
223
243
|
left: 0;
|
|
224
244
|
}
|
|
225
245
|
|
|
246
|
+
/* The edge-most action absorbs the extra width and keeps its label centred.
|
|
247
|
+
:where() has zero specificity, so a caller's own rules still win. */
|
|
248
|
+
:where(.swipe-actions[data-swipe-edge='trailing'] > :global(:last-child)),
|
|
249
|
+
:where(.swipe-actions[data-swipe-edge='leading'] > :global(:first-child)) {
|
|
250
|
+
flex: 1 0 auto;
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: center;
|
|
253
|
+
justify-content: center;
|
|
254
|
+
text-align: center;
|
|
255
|
+
}
|
|
256
|
+
|
|
226
257
|
.swipe-content {
|
|
227
258
|
position: relative;
|
|
228
259
|
background: var(--color-bg, transparent);
|
|
@@ -230,12 +261,15 @@
|
|
|
230
261
|
touch-action: pan-y;
|
|
231
262
|
}
|
|
232
263
|
|
|
233
|
-
/* Settled positions animate
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
.swipe-
|
|
239
|
-
|
|
264
|
+
/* Settled positions animate in step: the content slides and the strip
|
|
265
|
+
shrinks over the same duration. The drag itself tracks the finger, so
|
|
266
|
+
both are left untransitioned while data-swipe-dragging is set. The
|
|
267
|
+
attributes are written by the action, so the compiler cannot see them in
|
|
268
|
+
the markup: :global keeps these rules from being pruned away. */
|
|
269
|
+
.swipe-row:global([data-swipe-state]):not(:global([data-swipe-dragging])) .swipe-content,
|
|
270
|
+
.swipe-row:global([data-swipe-state]):not(:global([data-swipe-dragging])) .swipe-actions {
|
|
271
|
+
transition:
|
|
272
|
+
transform var(--transition-fast),
|
|
273
|
+
min-width var(--transition-fast);
|
|
240
274
|
}
|
|
241
275
|
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import { tick } from 'svelte';
|
|
4
|
+
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
label: Snippet;
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
<div class="glass-menu">
|
|
82
83
|
<button
|
|
83
84
|
bind:this={triggerEl}
|
|
85
|
+
{@attach fitFocusRing}
|
|
84
86
|
type="button"
|
|
85
87
|
class="glass-menu-trigger {className}"
|
|
86
88
|
aria-haspopup="menu"
|
|
@@ -126,6 +128,27 @@
|
|
|
126
128
|
cursor: pointer;
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
132
|
+
focus rules win. */
|
|
133
|
+
:where(.glass-menu-trigger:focus-visible) {
|
|
134
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
135
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
136
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* The same ring moved inside, for a part flush in a container that would clip
|
|
140
|
+
it (see focusRingFit). The trigger has no padding, so it goes no
|
|
141
|
+
deeper than its edge. */
|
|
142
|
+
:where(.glass-menu-trigger:global([data-focus-ring='inset']):focus-visible) {
|
|
143
|
+
outline-color: var(--glass-focus-ring-color, currentColor);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
147
|
+
the container cuts it off. Only the offset outranks it. */
|
|
148
|
+
.glass-menu-trigger:global([data-focus-ring='inset']):where(:focus-visible) {
|
|
149
|
+
outline-offset: calc(-1 * var(--glass-focus-ring-width, 2px));
|
|
150
|
+
}
|
|
151
|
+
|
|
129
152
|
.glass-menu-panel {
|
|
130
153
|
position: absolute;
|
|
131
154
|
top: calc(100% + 8px);
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
text-decoration: none;
|
|
85
85
|
color: var(--color-text);
|
|
86
86
|
cursor: pointer;
|
|
87
|
+
--_danger-text: var(--color-danger-text, color-mix(in srgb, var(--color-danger) var(--glass-danger-text-strength, 30%), var(--glass-text-toward, white)));
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
.menu-item:hover {
|
|
@@ -96,11 +97,23 @@
|
|
|
96
97
|
|
|
97
98
|
.menu-item:focus-visible {
|
|
98
99
|
background: var(--glass-hover-subtle);
|
|
99
|
-
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Shared focus ring, drawn inside because the container clips. :where keeps
|
|
103
|
+
it at zero specificity, so a page's own focus rules win. */
|
|
104
|
+
:where(.menu-item:focus-visible) {
|
|
105
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
106
|
+
box-shadow: inset 0 0 0 calc(2 * var(--glass-focus-ring-width, 2px)) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
110
|
+
the container cuts it off. Only the offset outranks it. */
|
|
111
|
+
.menu-item:where(:focus-visible) {
|
|
112
|
+
outline-offset: calc(-1 * var(--glass-focus-ring-width, 2px));
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
.menu-item.destructive {
|
|
103
|
-
color: var(--
|
|
116
|
+
color: var(--_danger-text);
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
.menu-item-icon {
|