glasslikeui 1.7.0 → 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/README.md +236 -5
- package/dist/actions/dragSnapMath.js +4 -3
- package/dist/actions/focusRingFit.d.ts +22 -0
- package/dist/actions/focusRingFit.js +115 -0
- package/dist/actions/focusTrap.js +24 -4
- package/dist/actions/viewTransition.d.ts +2 -1
- package/dist/actions/viewTransition.js +4 -2
- package/dist/components/glass/Glass.svelte +56 -0
- package/dist/components/glass/GlassMorph.svelte +21 -0
- package/dist/components/glass/Sheet.svelte +19 -4
- 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 +13 -0
- 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/styles/glasslikeui.css +116 -19
- package/dist/styles/lens.css +36 -0
- package/package.json +1 -1
|
@@ -223,6 +223,7 @@
|
|
|
223
223
|
<div
|
|
224
224
|
bind:this={sheetEl}
|
|
225
225
|
class="sheet-container {className}"
|
|
226
|
+
style:--sheet-hidden-height={sheetYForFraction(detentAt(fractions, currentIndex))}
|
|
226
227
|
class:open={isOpen}
|
|
227
228
|
data-sheet-state={sheetState}
|
|
228
229
|
role="dialog"
|
|
@@ -312,6 +313,7 @@
|
|
|
312
313
|
right: 0;
|
|
313
314
|
top: 0;
|
|
314
315
|
height: 100vh;
|
|
316
|
+
box-sizing: border-box;
|
|
315
317
|
margin: 0 auto;
|
|
316
318
|
background: var(--glass-sheet-bg);
|
|
317
319
|
backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
@@ -384,9 +386,9 @@
|
|
|
384
386
|
.sheet-close-btn:focus-visible {
|
|
385
387
|
/* Two tones, so the ring holds 3:1 on a dark or a light sheet. The inner
|
|
386
388
|
ring is the shadow hugging the button, the outer one the outline. */
|
|
387
|
-
outline: 2px solid var(--sheet-focus-ring-outer, #3b8eea);
|
|
388
|
-
outline-offset: 2px;
|
|
389
|
-
box-shadow: 0 0 0 2px var(--sheet-focus-ring-inner, #ffffff);
|
|
389
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--sheet-focus-ring-outer, #3b8eea));
|
|
390
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
391
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--sheet-focus-ring-inner, #ffffff);
|
|
390
392
|
}
|
|
391
393
|
|
|
392
394
|
.sheet-title {
|
|
@@ -402,8 +404,13 @@
|
|
|
402
404
|
width: 36px;
|
|
403
405
|
}
|
|
404
406
|
|
|
407
|
+
/* The sheet is a viewport tall and pushed down to its detent, so that much of
|
|
408
|
+
it is below the screen. The content gives it up, or its end could never be
|
|
409
|
+
scrolled into view. It follows the settled detent, not the finger, so a drag
|
|
410
|
+
does not lay the content out again on every move. */
|
|
405
411
|
.sheet-content {
|
|
406
412
|
flex: 1;
|
|
413
|
+
margin-bottom: var(--sheet-hidden-height, 0px);
|
|
407
414
|
overflow-y: auto;
|
|
408
415
|
overflow-x: hidden;
|
|
409
416
|
-webkit-overflow-scrolling: touch;
|
|
@@ -413,6 +420,14 @@
|
|
|
413
420
|
touch-action: pan-x pan-y;
|
|
414
421
|
}
|
|
415
422
|
|
|
423
|
+
/* On a phone 100vh can reach behind the browser bars, which hides that much
|
|
424
|
+
more of the sheet. */
|
|
425
|
+
@supports (height: 100dvh) {
|
|
426
|
+
.sheet-content {
|
|
427
|
+
margin-bottom: calc(var(--sheet-hidden-height, 0px) + 100vh - 100dvh);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
416
431
|
/* At the top, the browser keeps only the pan that scrolls the content down
|
|
417
432
|
(a finger moving up), so a finger moving down reaches the drag handlers
|
|
418
433
|
instead of becoming a pan and a pointercancel. Engines without directional
|
|
@@ -425,7 +440,7 @@
|
|
|
425
440
|
|
|
426
441
|
@media (min-width: 769px) {
|
|
427
442
|
.sheet-container {
|
|
428
|
-
max-width: 900px;
|
|
443
|
+
max-width: var(--glass-sheet-max-width, 900px);
|
|
429
444
|
}
|
|
430
445
|
}
|
|
431
446
|
</style>
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
border-radius: var(--glass-radius-full);
|
|
27
27
|
font-weight: 500;
|
|
28
28
|
white-space: nowrap;
|
|
29
|
+
--_accent-text: var(--color-accent-text, color-mix(in srgb, var(--color-accent) var(--glass-accent-text-strength, 33%), var(--glass-text-toward, white)));
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
.badge.size-sm {
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
|
|
47
48
|
.badge.variant-accent {
|
|
48
49
|
background: var(--color-accent-15);
|
|
49
|
-
color: var(--
|
|
50
|
+
color: var(--_accent-text);
|
|
50
51
|
border: 1px solid var(--color-accent-25);
|
|
51
52
|
}
|
|
52
53
|
</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
|
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>
|
|
@@ -152,6 +152,19 @@
|
|
|
152
152
|
cursor: pointer;
|
|
153
153
|
}
|
|
154
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
|
+
|
|
155
168
|
.list-row.interactive:hover {
|
|
156
169
|
background: var(--glass-hover-subtle);
|
|
157
170
|
}
|
|
@@ -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 {
|