@sofyan/glass 0.2.0 → 0.3.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 +129 -1
- package/dist/dark.css +5 -2
- package/dist/dark.unlayered.css +5 -2
- package/dist/glass.css +397 -7
- package/dist/glass.unlayered.css +397 -7
- package/dist/react/index.d.ts +167 -2
- package/dist/react/index.js +613 -47
- package/dist/react/index.js.map +1 -1
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# @sofyan/glass
|
|
2
2
|
|
|
3
3
|
Liquid Glass for the web: a translucent material (CSS), React components, and a native
|
|
4
|
-
`<dialog>` sheet that closes with a swipe down on phones.
|
|
4
|
+
`<dialog>` sheet that closes with a swipe down on phones. Toasts, a confirm dialog, tabs and
|
|
5
|
+
labelled form fields come with it, so apps don't each keep their own.
|
|
5
6
|
|
|
6
7
|
- **CSS first.** Plain CSS in cascade layers. Works with Tailwind v4 (its utilities always
|
|
7
8
|
win) and without Tailwind. An unlayered build is there too, for apps whose own CSS is
|
|
@@ -64,7 +65,11 @@ colours.
|
|
|
64
65
|
| `glass-menu`, `glass-menu-item`, `glass-menu-separator` | Popover menus |
|
|
65
66
|
| `glass-sheet`, `glass-scrim` | A panel and backdrop you position yourself |
|
|
66
67
|
| `glass-dialog` | The `<dialog>` sheet (use `<GlassSheet>`) |
|
|
68
|
+
| `glass-confirm` | The confirm dialog (use `<GlassConfirm>`) |
|
|
69
|
+
| `glass-toasts`, `glass-toast` (+ `glass-toast-danger`, `glass-toast-dismiss`) | Toasts (use `<GlassToasts>`) |
|
|
70
|
+
| `glass-tabs`, `glass-tab`, `glass-tab-panel` | Tabs (use `<GlassTabs>`) |
|
|
67
71
|
| `glass-input`, `glass-chip` | Text field, badge |
|
|
72
|
+
| `glass-field` (+ `-label`, `-hint`, `-error`), `glass-select` | Labelled fields (use `<GlassInput>`, ...) |
|
|
68
73
|
| `glass-dark`, `glass-clear`, `glass-tinted`, `glass-tinted-secondary`, `glass-danger` | Tones |
|
|
69
74
|
| `glass-thin`, `glass-thick`, `glass-flat` | Thickness |
|
|
70
75
|
| `glass-sm`, `glass-lg`, `glass-xl`, `glass-pill` | Shape |
|
|
@@ -215,6 +220,129 @@ dialog.my-sheet[data-closing]::backdrop {
|
|
|
215
220
|
When the backdrop is a parent element instead, select it with `:has()`:
|
|
216
221
|
`.my-backdrop:has(> [data-closing]) { background-color: transparent; }`.
|
|
217
222
|
|
|
223
|
+
### Toasts
|
|
224
|
+
|
|
225
|
+
Mount `<GlassToasts />` once near the root, then call `toast()` from anywhere:
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
import { GlassToasts, toast, dismissToast } from '@sofyan/glass/react';
|
|
229
|
+
|
|
230
|
+
<GlassToasts dismissLabel={t('dismiss')} />; // position="bottom" to stack them at the bottom
|
|
231
|
+
|
|
232
|
+
toast('Saved');
|
|
233
|
+
const id = toast('Upload failed', { tone: 'danger' });
|
|
234
|
+
dismissToast(id); // or dismissToast() for all of them
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- Neutral toasts are read politely (`role="status"`) and leave after 5 seconds
|
|
238
|
+
(`duration` in ms; `Infinity` or `0` keeps one, with a dismiss button). The clock stops
|
|
239
|
+
while the pointer is on the toast or focus is inside it.
|
|
240
|
+
- `danger` toasts are read at once (`role="alert"`) and stay until dismissed: alerts that
|
|
241
|
+
vanish by themselves are easy to miss.
|
|
242
|
+
- Both live regions are in the page from the start, so a screen reader is already listening
|
|
243
|
+
when a toast arrives. Toasts never take focus.
|
|
244
|
+
- At most three show at once; a fourth pushes out the oldest neutral one, so news never pushes out an error. The stack clears the notch and
|
|
245
|
+
the home indicator, and lets taps through to the page around the toasts.
|
|
246
|
+
|
|
247
|
+
### `GlassConfirm`
|
|
248
|
+
|
|
249
|
+
A question that has to be answered, on a native `<dialog>` with `role="alertdialog"`. Esc
|
|
250
|
+
cancels; a tap outside does nothing. Focus starts on the confirm button, or on Cancel when
|
|
251
|
+
`tone="danger"`, so a stray Enter never deletes anything. Put `autoFocus` on an element in
|
|
252
|
+
`children` to start there instead. Focus returns to the opener on close.
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
import { GlassConfirm, useGlassConfirm } from '@sofyan/glass/react';
|
|
256
|
+
|
|
257
|
+
<GlassConfirm
|
|
258
|
+
open={open}
|
|
259
|
+
onConfirm={deleteChat}
|
|
260
|
+
onCancel={() => setOpen(false)}
|
|
261
|
+
title="Delete this chat?"
|
|
262
|
+
message="It is deleted for you only."
|
|
263
|
+
confirmLabel={t('delete')}
|
|
264
|
+
cancelLabel={t('cancel')}
|
|
265
|
+
tone="danger"
|
|
266
|
+
/>;
|
|
267
|
+
|
|
268
|
+
// Or await the answer, and render `dialog` once:
|
|
269
|
+
function LeaveButton() {
|
|
270
|
+
const { confirm, dialog } = useGlassConfirm();
|
|
271
|
+
const leave = async () => {
|
|
272
|
+
if (await confirm({ title: 'Leave the group?', tone: 'danger', confirmLabel: 'Leave' })) {
|
|
273
|
+
leaveGroup();
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
return (
|
|
277
|
+
<>
|
|
278
|
+
<GlassButton onClick={leave}>Leave</GlassButton>
|
|
279
|
+
{dialog}
|
|
280
|
+
</>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`children` (or `details` in `confirm()`) shows between the message and the buttons, for a
|
|
286
|
+
list of what goes or an input; `confirmDisabled` holds the confirm button until it is
|
|
287
|
+
filled in. The promise resolves once: `true` on confirm, `false` on cancel, when another
|
|
288
|
+
`confirm()` replaces it, or when the component unmounts.
|
|
289
|
+
|
|
290
|
+
### `GlassTabs`
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
import { GlassTabs, GlassTabList, GlassTab, GlassTabPanel } from '@sofyan/glass/react';
|
|
294
|
+
|
|
295
|
+
<GlassTabs value={tab} onChange={setTab} label="Sections">
|
|
296
|
+
<GlassTabList>
|
|
297
|
+
<GlassTab value="chats">Chats</GlassTab>
|
|
298
|
+
<GlassTab value="calls">Calls</GlassTab>
|
|
299
|
+
<GlassTab value="files" disabled>
|
|
300
|
+
Files
|
|
301
|
+
</GlassTab>
|
|
302
|
+
</GlassTabList>
|
|
303
|
+
<GlassTabPanel value="chats">…</GlassTabPanel>
|
|
304
|
+
<GlassTabPanel value="calls">…</GlassTabPanel>
|
|
305
|
+
<GlassTabPanel value="files">…</GlassTabPanel>
|
|
306
|
+
</GlassTabs>;
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
The arrow keys move between tabs and select the one they land on (Left and Right swap in
|
|
310
|
+
right-to-left layouts; `orientation="vertical"` uses Up and Down). They wrap at the ends and
|
|
311
|
+
skip disabled tabs; Home and End go to the first and last. Only the selected tab is in the
|
|
312
|
+
Tab order. Hidden panels stay mounted, so they keep their state. The list is a glass pill
|
|
313
|
+
that scrolls sideways when the tabs don't fit, and is marked `data-glass-no-drag`, so inside
|
|
314
|
+
a sheet a swipe along it never pulls the sheet. `<GlassTabs>` renders only its children, so
|
|
315
|
+
the layout around the list and panels is yours.
|
|
316
|
+
|
|
317
|
+
### Fields
|
|
318
|
+
|
|
319
|
+
`GlassInput`, `GlassTextarea` and `GlassSelect` take every prop of their element, plus:
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
import { GlassInput, GlassSelect } from '@sofyan/glass/react';
|
|
323
|
+
|
|
324
|
+
<GlassInput
|
|
325
|
+
label="Email"
|
|
326
|
+
type="email"
|
|
327
|
+
required
|
|
328
|
+
hint="We never share it."
|
|
329
|
+
error={errors.email} // set it once there is an error
|
|
330
|
+
/>;
|
|
331
|
+
|
|
332
|
+
<GlassSelect label="Language" value={lang} onChange={(e) => setLang(e.target.value)}>
|
|
333
|
+
<option value="id">Bahasa Indonesia</option>
|
|
334
|
+
<option value="en">English</option>
|
|
335
|
+
</GlassSelect>;
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
- The label is tied to the control; `hideLabel` hides it visually and keeps it as the name.
|
|
339
|
+
- `hint` and `error` are read with the control (`aria-describedby`, merged with one you pass).
|
|
340
|
+
The control is marked `aria-invalid` only while there is an error.
|
|
341
|
+
- `required` shows an asterisk that screen readers skip: the control's own `required` says it.
|
|
342
|
+
- Error text uses `--lg-danger-text` (4.5:1 on paper and canvas, light and dark). Text is
|
|
343
|
+
16px on touch screens, so iOS doesn't zoom in.
|
|
344
|
+
- `className` goes on the wrapper, `inputClassName` on the control; refs reach the control.
|
|
345
|
+
|
|
218
346
|
### Refraction (Chromium only)
|
|
219
347
|
|
|
220
348
|
Mount `<GlassFilter />` once near the root, then add `refract` (or `glass-refract`). Safari
|
package/dist/dark.css
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* Then add class="dark" or data-theme="dark" to any element: <html> for the whole page,
|
|
10
10
|
* or a wrapper for one part of it. Everything inside follows.
|
|
11
11
|
*
|
|
12
|
-
* It only retunes tokens (neutrals, the light glass, shadows) and the denser
|
|
13
|
-
* menus and sheets. Tones you set yourself (glass-dark, glass-clear, glass-tinted, ...)
|
|
12
|
+
* It only retunes tokens (neutrals, danger text, the light glass, shadows) and the denser
|
|
13
|
+
* fills of menus and sheets. Tones you set yourself (glass-dark, glass-clear, glass-tinted, ...)
|
|
14
14
|
* stay as they are.
|
|
15
15
|
*/
|
|
16
16
|
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
--lg-c-ink-3: 142 142 147;
|
|
33
33
|
--lg-c-line: 255 255 255;
|
|
34
34
|
|
|
35
|
+
/* 4.5:1 or more on the dark paper, raised and canvas neutrals. */
|
|
36
|
+
--lg-danger-text: #ff6961;
|
|
37
|
+
|
|
35
38
|
--lg-light-fill: rgba(30, 30, 32, 0.66);
|
|
36
39
|
--lg-light-fill-hover: rgba(44, 44, 46, 0.76);
|
|
37
40
|
--lg-light-text: #f5f5f7;
|
package/dist/dark.unlayered.css
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* Then add class="dark" or data-theme="dark" to any element: <html> for the whole page,
|
|
13
13
|
* or a wrapper for one part of it. Everything inside follows.
|
|
14
14
|
*
|
|
15
|
-
* It only retunes tokens (neutrals, the light glass, shadows) and the denser
|
|
16
|
-
* menus and sheets. Tones you set yourself (glass-dark, glass-clear, glass-tinted, ...)
|
|
15
|
+
* It only retunes tokens (neutrals, danger text, the light glass, shadows) and the denser
|
|
16
|
+
* fills of menus and sheets. Tones you set yourself (glass-dark, glass-clear, glass-tinted, ...)
|
|
17
17
|
* stay as they are.
|
|
18
18
|
*
|
|
19
19
|
* Cascade: no cascade layers here, so normal specificity and source order decide.
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
--lg-c-ink-3: 142 142 147;
|
|
38
38
|
--lg-c-line: 255 255 255;
|
|
39
39
|
|
|
40
|
+
/* 4.5:1 or more on the dark paper, raised and canvas neutrals. */
|
|
41
|
+
--lg-danger-text: #ff6961;
|
|
42
|
+
|
|
40
43
|
--lg-light-fill: rgba(30, 30, 32, 0.66);
|
|
41
44
|
--lg-light-fill-hover: rgba(44, 44, 46, 0.76);
|
|
42
45
|
--lg-light-text: #f5f5f7;
|
package/dist/glass.css
CHANGED
|
@@ -38,6 +38,13 @@
|
|
|
38
38
|
--lg-sheet-fill default rgb(var(--lg-c-paper)), the <dialog> sheet's fill */
|
|
39
39
|
--lg-danger: #ff3b30; /* iOS system red */
|
|
40
40
|
--lg-danger-strong: #e5352b;
|
|
41
|
+
/* Danger as a fill under white text (buttons, error toasts): 5.4:1 and 7.4:1 (WCAG 1.4.3).
|
|
42
|
+
White on --lg-danger is only 3.6:1, so that one stays for edges and rings. */
|
|
43
|
+
--lg-danger-fill: #d70015;
|
|
44
|
+
--lg-danger-fill-strong: #b00012;
|
|
45
|
+
/* Danger as text (field errors). --lg-danger is a fill and too light for text; this one
|
|
46
|
+
has 4.5:1 or more on the paper and canvas neutrals (WCAG 1.4.3). dark.css retunes it. */
|
|
47
|
+
--lg-danger-text: #d70015;
|
|
41
48
|
|
|
42
49
|
/* Theme-aware neutrals as RGB triplets, so `rgb(var(--lg-c-ink) / 0.5)` works.
|
|
43
50
|
tailwind.css maps them to `lg-*` colours. Redefine them for dark mode. */
|
|
@@ -145,7 +152,7 @@
|
|
|
145
152
|
@layer components {
|
|
146
153
|
/* ── Base material ──────────────────────────────────────────────────── */
|
|
147
154
|
/* Every class in this list is a glass surface; the composites below add to it. */
|
|
148
|
-
:where(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip) {
|
|
155
|
+
:where(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip, .glass-toast, .glass-tabs) {
|
|
149
156
|
--lg-fill: var(--lg-light-fill);
|
|
150
157
|
--lg-fill-hover: var(--lg-light-fill-hover);
|
|
151
158
|
--lg-rim: var(--lg-light-rim);
|
|
@@ -160,7 +167,9 @@
|
|
|
160
167
|
.glass-btn,
|
|
161
168
|
.glass-menu,
|
|
162
169
|
.glass-sheet,
|
|
163
|
-
.glass-chip
|
|
170
|
+
.glass-chip,
|
|
171
|
+
.glass-toast,
|
|
172
|
+
.glass-tabs {
|
|
164
173
|
position: relative;
|
|
165
174
|
isolation: isolate;
|
|
166
175
|
color: var(--lg-light-text);
|
|
@@ -175,8 +184,9 @@
|
|
|
175
184
|
}
|
|
176
185
|
|
|
177
186
|
/* Specular rim: a 1px gradient ring that follows the border radius. Light catches the
|
|
178
|
-
top edge only, then fades.
|
|
179
|
-
|
|
187
|
+
top edge only, then fades. Not on the tab track: it scrolls, and the ring would scroll
|
|
188
|
+
away with the tabs. */
|
|
189
|
+
:is(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip, .glass-toast)::before {
|
|
180
190
|
content: '';
|
|
181
191
|
position: absolute;
|
|
182
192
|
inset: 0;
|
|
@@ -364,6 +374,119 @@
|
|
|
364
374
|
0 0 0 4px color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 16%, transparent);
|
|
365
375
|
}
|
|
366
376
|
|
|
377
|
+
/* Invalid (aria-invalid, which the field components set once there is an error): a danger
|
|
378
|
+
ring, 3:1 against paper. The error text is the cue that does not rely on colour. */
|
|
379
|
+
.glass-input[aria-invalid='true'] {
|
|
380
|
+
box-shadow: inset 0 0 0 1.5px var(--lg-danger);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/* The first box-shadow is for engines without color-mix(). */
|
|
384
|
+
.glass-input[aria-invalid='true']:focus {
|
|
385
|
+
box-shadow: inset 0 0 0 2px var(--lg-danger);
|
|
386
|
+
box-shadow:
|
|
387
|
+
inset 0 0 0 1.5px var(--lg-danger),
|
|
388
|
+
0 0 0 4px color-mix(in srgb, var(--lg-danger) 16%, transparent);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
textarea.glass-input {
|
|
392
|
+
min-height: 5.5rem;
|
|
393
|
+
resize: vertical;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/* Fields (<GlassInput />, <GlassTextarea />, <GlassSelect />): label, control, hint and
|
|
397
|
+
error, one under the other. Margins, not flex gap, which needs Safari 14.1. */
|
|
398
|
+
.glass-field .glass-input {
|
|
399
|
+
display: block;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.glass-field .glass-input:disabled {
|
|
403
|
+
cursor: not-allowed;
|
|
404
|
+
opacity: 0.5;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.glass-field-label {
|
|
408
|
+
display: block;
|
|
409
|
+
margin-bottom: 0.375rem;
|
|
410
|
+
font-size: 0.875rem;
|
|
411
|
+
line-height: 1.25rem;
|
|
412
|
+
font-weight: 500;
|
|
413
|
+
color: rgb(var(--lg-c-ink));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/* hideLabel: out of sight, still read. */
|
|
417
|
+
.glass-field-label-hidden {
|
|
418
|
+
position: absolute;
|
|
419
|
+
width: 1px;
|
|
420
|
+
height: 1px;
|
|
421
|
+
margin: -1px;
|
|
422
|
+
padding: 0;
|
|
423
|
+
overflow: hidden;
|
|
424
|
+
clip: rect(0 0 0 0);
|
|
425
|
+
clip-path: inset(50%);
|
|
426
|
+
white-space: nowrap;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/* The asterisk is decoration (aria-hidden): the control's `required` carries the meaning. */
|
|
430
|
+
.glass-field-required {
|
|
431
|
+
margin-inline-start: 0.125rem;
|
|
432
|
+
color: var(--lg-danger-text);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.glass-field-hint,
|
|
436
|
+
.glass-field-error {
|
|
437
|
+
margin-top: 0.375rem;
|
|
438
|
+
font-size: 0.8125rem;
|
|
439
|
+
line-height: 1.125rem;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.glass-field-hint {
|
|
443
|
+
color: rgb(var(--lg-c-ink-2));
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.glass-field-error {
|
|
447
|
+
font-weight: 500;
|
|
448
|
+
color: var(--lg-danger-text);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/* A drop-down <select> in a .glass-select wrapper: the native arrow goes, and a chevron
|
|
452
|
+
drawn in the ink colour takes its place, so it follows the theme. Physical `right` first
|
|
453
|
+
for engines without inset-inline (before Safari 14.1). */
|
|
454
|
+
.glass-select {
|
|
455
|
+
position: relative;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.glass-select > select {
|
|
459
|
+
-webkit-appearance: none;
|
|
460
|
+
appearance: none;
|
|
461
|
+
padding-inline-end: 2.5rem;
|
|
462
|
+
cursor: pointer;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.glass-select::after {
|
|
466
|
+
content: '';
|
|
467
|
+
position: absolute;
|
|
468
|
+
top: 50%;
|
|
469
|
+
right: 1rem;
|
|
470
|
+
inset-inline-start: auto;
|
|
471
|
+
inset-inline-end: 1rem;
|
|
472
|
+
width: 0.5rem;
|
|
473
|
+
height: 0.5rem;
|
|
474
|
+
margin-top: -0.375rem;
|
|
475
|
+
border-right: 1.5px solid;
|
|
476
|
+
border-bottom: 1.5px solid;
|
|
477
|
+
color: rgb(var(--lg-c-ink-2));
|
|
478
|
+
transform: rotate(45deg);
|
|
479
|
+
pointer-events: none;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/* iOS zooms into a focused control whose text is under 16px. */
|
|
483
|
+
@media (pointer: coarse) {
|
|
484
|
+
.glass-field .glass-input {
|
|
485
|
+
font-size: 1rem;
|
|
486
|
+
line-height: 1.5rem;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
367
490
|
/* Small chip / badge: thin, pill. */
|
|
368
491
|
.glass-chip {
|
|
369
492
|
--lg-surface-blur: var(--lg-blur-thin);
|
|
@@ -378,6 +501,204 @@
|
|
|
378
501
|
font-weight: 600;
|
|
379
502
|
}
|
|
380
503
|
|
|
504
|
+
/* Toasts (<GlassToasts />): a stack at the top (or bottom) of the viewport, clear of the
|
|
505
|
+
notch and the home indicator. The stack lets taps through to the page; only the toasts
|
|
506
|
+
take them. Margins, not flex gap, which needs Safari 14.1. */
|
|
507
|
+
.glass-toasts {
|
|
508
|
+
position: fixed;
|
|
509
|
+
top: 0;
|
|
510
|
+
left: 0;
|
|
511
|
+
right: 0;
|
|
512
|
+
z-index: 9999;
|
|
513
|
+
display: flex;
|
|
514
|
+
flex-direction: column;
|
|
515
|
+
align-items: center;
|
|
516
|
+
padding: max(env(safe-area-inset-top), 0.75rem) max(env(safe-area-inset-right), 1rem) 0
|
|
517
|
+
max(env(safe-area-inset-left), 1rem);
|
|
518
|
+
pointer-events: none;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.glass-toasts-bottom {
|
|
522
|
+
top: auto;
|
|
523
|
+
bottom: 0;
|
|
524
|
+
padding-top: 0;
|
|
525
|
+
padding-bottom: max(env(safe-area-inset-bottom), 0.75rem);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/* The two live regions (status, then alert). Never display: none, even when empty: a live
|
|
529
|
+
region that is not rendered is not listening. */
|
|
530
|
+
.glass-toasts-region {
|
|
531
|
+
display: flex;
|
|
532
|
+
flex-direction: column;
|
|
533
|
+
align-items: center;
|
|
534
|
+
width: 100%;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.glass-toast + .glass-toast,
|
|
538
|
+
.glass-toasts-region:not(:empty) + .glass-toasts-region:not(:empty) {
|
|
539
|
+
margin-top: 0.5rem;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/* A pill while it holds one line; a rounded box when the message wraps. */
|
|
543
|
+
.glass-toast {
|
|
544
|
+
--lg-surface-blur: var(--lg-blur-thick);
|
|
545
|
+
--lg-shadow: var(--lg-shadow-lg);
|
|
546
|
+
display: flex;
|
|
547
|
+
align-items: center;
|
|
548
|
+
max-width: 28rem;
|
|
549
|
+
min-height: 44px;
|
|
550
|
+
padding: 0.625rem 1.25rem;
|
|
551
|
+
border-radius: 22px;
|
|
552
|
+
font-size: 0.875rem;
|
|
553
|
+
line-height: 1.25rem;
|
|
554
|
+
font-weight: 500;
|
|
555
|
+
pointer-events: auto;
|
|
556
|
+
animation: lg-pop var(--lg-duration) var(--lg-ease-spring) both;
|
|
557
|
+
transform-origin: top center;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.glass-toasts-bottom .glass-toast {
|
|
561
|
+
transform-origin: bottom center;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/* Danger: the solid danger fill. */
|
|
565
|
+
.glass-toast-danger {
|
|
566
|
+
--lg-fill: var(--lg-danger-fill);
|
|
567
|
+
--lg-rim: rgba(255, 255, 255, 0.28);
|
|
568
|
+
--lg-rim-low: rgba(255, 255, 255, 0);
|
|
569
|
+
--lg-edge: transparent;
|
|
570
|
+
--lg-surface-sheen: none;
|
|
571
|
+
color: #fff;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.glass-toast-message {
|
|
575
|
+
flex: 1 1 auto;
|
|
576
|
+
min-width: 0;
|
|
577
|
+
overflow-wrap: break-word;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/* 44px target, pulled into the padding so the toast stays 44px tall. */
|
|
581
|
+
.glass-toast-dismiss {
|
|
582
|
+
display: flex;
|
|
583
|
+
flex-shrink: 0;
|
|
584
|
+
align-items: center;
|
|
585
|
+
justify-content: center;
|
|
586
|
+
width: 44px;
|
|
587
|
+
height: 44px;
|
|
588
|
+
margin-top: -0.625rem;
|
|
589
|
+
margin-bottom: -0.625rem;
|
|
590
|
+
margin-inline-start: 0.25rem;
|
|
591
|
+
margin-inline-end: -1rem;
|
|
592
|
+
padding: 0;
|
|
593
|
+
border: 0;
|
|
594
|
+
border-radius: 9999px;
|
|
595
|
+
color: inherit;
|
|
596
|
+
background-color: transparent;
|
|
597
|
+
cursor: pointer;
|
|
598
|
+
transition: background-color var(--lg-duration-fast) ease;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.glass-toast-dismiss:hover {
|
|
602
|
+
background-color: rgba(127, 127, 127, 0.18);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.glass-toast-dismiss:focus-visible {
|
|
606
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
607
|
+
outline-offset: -2px;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.glass-toast-danger .glass-toast-dismiss:focus-visible {
|
|
611
|
+
outline-color: currentColor;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/* Tabs (<GlassTabList />): a pill track that scrolls sideways, without a scrollbar, when
|
|
615
|
+
the tabs do not fit. The selected tab is a raised pill. Focus rings sit inside the tabs,
|
|
616
|
+
where the scrolling track cannot clip them. */
|
|
617
|
+
.glass-tabs {
|
|
618
|
+
--lg-surface-blur: var(--lg-blur-thin);
|
|
619
|
+
--lg-shadow: var(--lg-shadow-sm);
|
|
620
|
+
display: flex;
|
|
621
|
+
width: max-content;
|
|
622
|
+
max-width: 100%;
|
|
623
|
+
padding: 0.25rem;
|
|
624
|
+
border-radius: 9999px;
|
|
625
|
+
overflow-x: auto;
|
|
626
|
+
overscroll-behavior-x: contain;
|
|
627
|
+
scrollbar-width: none;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.glass-tabs::-webkit-scrollbar {
|
|
631
|
+
display: none;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.glass-tabs[aria-orientation='vertical'] {
|
|
635
|
+
flex-direction: column;
|
|
636
|
+
border-radius: var(--lg-radius-lg);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
.glass-tab {
|
|
640
|
+
display: inline-flex;
|
|
641
|
+
flex-shrink: 0;
|
|
642
|
+
align-items: center;
|
|
643
|
+
justify-content: center;
|
|
644
|
+
gap: 0.375rem;
|
|
645
|
+
min-height: 44px;
|
|
646
|
+
padding: 0.5rem 1rem;
|
|
647
|
+
border: 0;
|
|
648
|
+
border-radius: 9999px;
|
|
649
|
+
font-family: inherit;
|
|
650
|
+
font-size: 0.875rem;
|
|
651
|
+
line-height: 1.25rem;
|
|
652
|
+
font-weight: 500;
|
|
653
|
+
white-space: nowrap;
|
|
654
|
+
color: inherit;
|
|
655
|
+
background-color: transparent;
|
|
656
|
+
cursor: pointer;
|
|
657
|
+
transition:
|
|
658
|
+
background-color var(--lg-duration-fast) ease,
|
|
659
|
+
box-shadow var(--lg-duration-fast) ease;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/* Concentric with the track's corners. */
|
|
663
|
+
.glass-tabs[aria-orientation='vertical'] .glass-tab {
|
|
664
|
+
justify-content: flex-start;
|
|
665
|
+
border-radius: calc(var(--lg-radius-lg) - 0.25rem);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
.glass-tab:not(:disabled):hover {
|
|
669
|
+
background-color: rgb(var(--lg-c-line) / 0.06);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/* Selected: raised, outlined and bolder, not only a different colour. */
|
|
673
|
+
.glass-tab[aria-selected='true'] {
|
|
674
|
+
font-weight: 600;
|
|
675
|
+
color: rgb(var(--lg-c-ink));
|
|
676
|
+
background-color: rgb(var(--lg-c-raised));
|
|
677
|
+
box-shadow:
|
|
678
|
+
inset 0 0 0 1px rgb(var(--lg-c-line) / 0.08),
|
|
679
|
+
0 1px 3px rgb(0 0 0 / 0.12);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
.glass-tab:focus-visible {
|
|
683
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
684
|
+
outline-offset: -2px;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.glass-tab:disabled {
|
|
688
|
+
cursor: not-allowed;
|
|
689
|
+
opacity: 0.4;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
.glass-tab-panel:focus-visible {
|
|
693
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
694
|
+
outline-offset: 2px;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/* Stays hidden even if a class of yours sets `display` on the panel. */
|
|
698
|
+
.glass-tab-panel[hidden] {
|
|
699
|
+
display: none;
|
|
700
|
+
}
|
|
701
|
+
|
|
381
702
|
/* ── Tones ──────────────────────────────────────────────────────────── */
|
|
382
703
|
.glass-dark {
|
|
383
704
|
--lg-fill: var(--lg-dark-fill);
|
|
@@ -432,8 +753,8 @@
|
|
|
432
753
|
}
|
|
433
754
|
|
|
434
755
|
.glass-danger {
|
|
435
|
-
--lg-fill: var(--lg-danger);
|
|
436
|
-
--lg-fill-hover: var(--lg-danger-strong);
|
|
756
|
+
--lg-fill: var(--lg-danger-fill);
|
|
757
|
+
--lg-fill-hover: var(--lg-danger-fill-strong);
|
|
437
758
|
}
|
|
438
759
|
|
|
439
760
|
/* ── Thickness ──────────────────────────────────────────────────────── */
|
|
@@ -669,6 +990,71 @@
|
|
|
669
990
|
user-select: none;
|
|
670
991
|
}
|
|
671
992
|
|
|
993
|
+
/* ── Confirm (<GlassConfirm />, or a <dialog class="glass-confirm">) ─── */
|
|
994
|
+
/* A centred box on every width: a question has to be answered, so it is never a sheet to
|
|
995
|
+
swipe away. The vh line is for engines without dvh (before Safari 15.4). */
|
|
996
|
+
dialog.glass-confirm {
|
|
997
|
+
width: 100%;
|
|
998
|
+
max-width: min(28rem, calc(100% - 2rem));
|
|
999
|
+
max-height: calc(100vh - 2rem);
|
|
1000
|
+
max-height: calc(100dvh - 2rem);
|
|
1001
|
+
margin: auto;
|
|
1002
|
+
padding: 1.5rem;
|
|
1003
|
+
border: 0;
|
|
1004
|
+
overflow-y: auto;
|
|
1005
|
+
overscroll-behavior: contain;
|
|
1006
|
+
border-radius: var(--lg-radius-xl);
|
|
1007
|
+
color: rgb(var(--lg-c-ink));
|
|
1008
|
+
background-color: var(--lg-sheet-fill, rgb(var(--lg-c-paper)));
|
|
1009
|
+
box-shadow:
|
|
1010
|
+
inset 0 0 0 1px rgb(var(--lg-c-line) / 0.1),
|
|
1011
|
+
var(--lg-shadow-lg);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
dialog.glass-confirm[open] {
|
|
1015
|
+
animation: lg-sheet-in var(--lg-duration) var(--lg-ease-spring) both;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
dialog.glass-confirm:focus {
|
|
1019
|
+
outline: none;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/* With a fallback: before Chrome 122, ::backdrop inherits no custom properties. */
|
|
1023
|
+
dialog.glass-confirm::backdrop {
|
|
1024
|
+
background-color: var(--lg-scrim, rgba(0, 0, 0, 0.4));
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
.glass-confirm-title {
|
|
1028
|
+
margin: 0;
|
|
1029
|
+
font-size: 1.125rem;
|
|
1030
|
+
line-height: 1.5rem;
|
|
1031
|
+
font-weight: 600;
|
|
1032
|
+
color: rgb(var(--lg-c-ink));
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
.glass-confirm-message {
|
|
1036
|
+
margin-top: 0.5rem;
|
|
1037
|
+
font-size: 0.9375rem;
|
|
1038
|
+
line-height: 1.375rem;
|
|
1039
|
+
color: rgb(var(--lg-c-ink-2));
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
.glass-confirm-details {
|
|
1043
|
+
margin-top: 1rem;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/* Side by side when they fit, one above the other when they do not. */
|
|
1047
|
+
.glass-confirm-actions {
|
|
1048
|
+
display: flex;
|
|
1049
|
+
flex-wrap: wrap;
|
|
1050
|
+
gap: 0.75rem;
|
|
1051
|
+
margin-top: 1.5rem;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
.glass-confirm-actions > * {
|
|
1055
|
+
flex: 1 1 8rem;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
672
1058
|
/* ── Keyframes ──────────────────────────────────────────────────────── */
|
|
673
1059
|
/* Pop-ins animate transform only: an element with opacity < 1 can't sample its
|
|
674
1060
|
backdrop in Chromium, so fading would show unblurred content until it settles. */
|
|
@@ -711,8 +1097,12 @@
|
|
|
711
1097
|
.glass-menu-item,
|
|
712
1098
|
.glass-sheet,
|
|
713
1099
|
.glass-scrim,
|
|
1100
|
+
.glass-toast,
|
|
1101
|
+
.glass-toast-dismiss,
|
|
1102
|
+
.glass-tab,
|
|
714
1103
|
dialog.glass-dialog[open],
|
|
715
|
-
dialog.glass-dialog::backdrop
|
|
1104
|
+
dialog.glass-dialog::backdrop,
|
|
1105
|
+
dialog.glass-confirm[open] {
|
|
716
1106
|
animation: none;
|
|
717
1107
|
transition: none;
|
|
718
1108
|
}
|