@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/dist/glass.unlayered.css
CHANGED
|
@@ -42,6 +42,13 @@
|
|
|
42
42
|
--lg-sheet-fill default rgb(var(--lg-c-paper)), the <dialog> sheet's fill */
|
|
43
43
|
--lg-danger: #ff3b30; /* iOS system red */
|
|
44
44
|
--lg-danger-strong: #e5352b;
|
|
45
|
+
/* Danger as a fill under white text (buttons, error toasts): 5.4:1 and 7.4:1 (WCAG 1.4.3).
|
|
46
|
+
White on --lg-danger is only 3.6:1, so that one stays for edges and rings. */
|
|
47
|
+
--lg-danger-fill: #d70015;
|
|
48
|
+
--lg-danger-fill-strong: #b00012;
|
|
49
|
+
/* Danger as text (field errors). --lg-danger is a fill and too light for text; this one
|
|
50
|
+
has 4.5:1 or more on the paper and canvas neutrals (WCAG 1.4.3). dark.css retunes it. */
|
|
51
|
+
--lg-danger-text: #d70015;
|
|
45
52
|
|
|
46
53
|
/* Theme-aware neutrals as RGB triplets, so `rgb(var(--lg-c-ink) / 0.5)` works.
|
|
47
54
|
tailwind.css maps them to `lg-*` colours. Redefine them for dark mode. */
|
|
@@ -147,7 +154,7 @@
|
|
|
147
154
|
|
|
148
155
|
/* ── Base material ──────────────────────────────────────────────────── */
|
|
149
156
|
/* Every class in this list is a glass surface; the composites below add to it. */
|
|
150
|
-
:where(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip) {
|
|
157
|
+
:where(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip, .glass-toast, .glass-tabs) {
|
|
151
158
|
--lg-fill: var(--lg-light-fill);
|
|
152
159
|
--lg-fill-hover: var(--lg-light-fill-hover);
|
|
153
160
|
--lg-rim: var(--lg-light-rim);
|
|
@@ -162,7 +169,9 @@
|
|
|
162
169
|
.glass-btn,
|
|
163
170
|
.glass-menu,
|
|
164
171
|
.glass-sheet,
|
|
165
|
-
.glass-chip
|
|
172
|
+
.glass-chip,
|
|
173
|
+
.glass-toast,
|
|
174
|
+
.glass-tabs {
|
|
166
175
|
position: relative;
|
|
167
176
|
isolation: isolate;
|
|
168
177
|
color: var(--lg-light-text);
|
|
@@ -177,8 +186,9 @@
|
|
|
177
186
|
}
|
|
178
187
|
|
|
179
188
|
/* Specular rim: a 1px gradient ring that follows the border radius. Light catches the
|
|
180
|
-
top edge only, then fades.
|
|
181
|
-
|
|
189
|
+
top edge only, then fades. Not on the tab track: it scrolls, and the ring would scroll
|
|
190
|
+
away with the tabs. */
|
|
191
|
+
:is(.glass, .glass-btn, .glass-menu, .glass-sheet, .glass-chip, .glass-toast)::before {
|
|
182
192
|
content: '';
|
|
183
193
|
position: absolute;
|
|
184
194
|
inset: 0;
|
|
@@ -366,6 +376,119 @@
|
|
|
366
376
|
0 0 0 4px color-mix(in srgb, var(--lg-accent, var(--color-primary, #0a84ff)) 16%, transparent);
|
|
367
377
|
}
|
|
368
378
|
|
|
379
|
+
/* Invalid (aria-invalid, which the field components set once there is an error): a danger
|
|
380
|
+
ring, 3:1 against paper. The error text is the cue that does not rely on colour. */
|
|
381
|
+
.glass-input[aria-invalid='true'] {
|
|
382
|
+
box-shadow: inset 0 0 0 1.5px var(--lg-danger);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* The first box-shadow is for engines without color-mix(). */
|
|
386
|
+
.glass-input[aria-invalid='true']:focus {
|
|
387
|
+
box-shadow: inset 0 0 0 2px var(--lg-danger);
|
|
388
|
+
box-shadow:
|
|
389
|
+
inset 0 0 0 1.5px var(--lg-danger),
|
|
390
|
+
0 0 0 4px color-mix(in srgb, var(--lg-danger) 16%, transparent);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
textarea.glass-input {
|
|
394
|
+
min-height: 5.5rem;
|
|
395
|
+
resize: vertical;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/* Fields (<GlassInput />, <GlassTextarea />, <GlassSelect />): label, control, hint and
|
|
399
|
+
error, one under the other. Margins, not flex gap, which needs Safari 14.1. */
|
|
400
|
+
.glass-field .glass-input {
|
|
401
|
+
display: block;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.glass-field .glass-input:disabled {
|
|
405
|
+
cursor: not-allowed;
|
|
406
|
+
opacity: 0.5;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.glass-field-label {
|
|
410
|
+
display: block;
|
|
411
|
+
margin-bottom: 0.375rem;
|
|
412
|
+
font-size: 0.875rem;
|
|
413
|
+
line-height: 1.25rem;
|
|
414
|
+
font-weight: 500;
|
|
415
|
+
color: rgb(var(--lg-c-ink));
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/* hideLabel: out of sight, still read. */
|
|
419
|
+
.glass-field-label-hidden {
|
|
420
|
+
position: absolute;
|
|
421
|
+
width: 1px;
|
|
422
|
+
height: 1px;
|
|
423
|
+
margin: -1px;
|
|
424
|
+
padding: 0;
|
|
425
|
+
overflow: hidden;
|
|
426
|
+
clip: rect(0 0 0 0);
|
|
427
|
+
clip-path: inset(50%);
|
|
428
|
+
white-space: nowrap;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/* The asterisk is decoration (aria-hidden): the control's `required` carries the meaning. */
|
|
432
|
+
.glass-field-required {
|
|
433
|
+
margin-inline-start: 0.125rem;
|
|
434
|
+
color: var(--lg-danger-text);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.glass-field-hint,
|
|
438
|
+
.glass-field-error {
|
|
439
|
+
margin-top: 0.375rem;
|
|
440
|
+
font-size: 0.8125rem;
|
|
441
|
+
line-height: 1.125rem;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.glass-field-hint {
|
|
445
|
+
color: rgb(var(--lg-c-ink-2));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.glass-field-error {
|
|
449
|
+
font-weight: 500;
|
|
450
|
+
color: var(--lg-danger-text);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/* A drop-down <select> in a .glass-select wrapper: the native arrow goes, and a chevron
|
|
454
|
+
drawn in the ink colour takes its place, so it follows the theme. Physical `right` first
|
|
455
|
+
for engines without inset-inline (before Safari 14.1). */
|
|
456
|
+
.glass-select {
|
|
457
|
+
position: relative;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.glass-select > select {
|
|
461
|
+
-webkit-appearance: none;
|
|
462
|
+
appearance: none;
|
|
463
|
+
padding-inline-end: 2.5rem;
|
|
464
|
+
cursor: pointer;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.glass-select::after {
|
|
468
|
+
content: '';
|
|
469
|
+
position: absolute;
|
|
470
|
+
top: 50%;
|
|
471
|
+
right: 1rem;
|
|
472
|
+
inset-inline-start: auto;
|
|
473
|
+
inset-inline-end: 1rem;
|
|
474
|
+
width: 0.5rem;
|
|
475
|
+
height: 0.5rem;
|
|
476
|
+
margin-top: -0.375rem;
|
|
477
|
+
border-right: 1.5px solid;
|
|
478
|
+
border-bottom: 1.5px solid;
|
|
479
|
+
color: rgb(var(--lg-c-ink-2));
|
|
480
|
+
transform: rotate(45deg);
|
|
481
|
+
pointer-events: none;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/* iOS zooms into a focused control whose text is under 16px. */
|
|
485
|
+
@media (pointer: coarse) {
|
|
486
|
+
.glass-field .glass-input {
|
|
487
|
+
font-size: 1rem;
|
|
488
|
+
line-height: 1.5rem;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
369
492
|
/* Small chip / badge: thin, pill. */
|
|
370
493
|
.glass-chip {
|
|
371
494
|
--lg-surface-blur: var(--lg-blur-thin);
|
|
@@ -380,6 +503,204 @@
|
|
|
380
503
|
font-weight: 600;
|
|
381
504
|
}
|
|
382
505
|
|
|
506
|
+
/* Toasts (<GlassToasts />): a stack at the top (or bottom) of the viewport, clear of the
|
|
507
|
+
notch and the home indicator. The stack lets taps through to the page; only the toasts
|
|
508
|
+
take them. Margins, not flex gap, which needs Safari 14.1. */
|
|
509
|
+
.glass-toasts {
|
|
510
|
+
position: fixed;
|
|
511
|
+
top: 0;
|
|
512
|
+
left: 0;
|
|
513
|
+
right: 0;
|
|
514
|
+
z-index: 9999;
|
|
515
|
+
display: flex;
|
|
516
|
+
flex-direction: column;
|
|
517
|
+
align-items: center;
|
|
518
|
+
padding: max(env(safe-area-inset-top), 0.75rem) max(env(safe-area-inset-right), 1rem) 0
|
|
519
|
+
max(env(safe-area-inset-left), 1rem);
|
|
520
|
+
pointer-events: none;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.glass-toasts-bottom {
|
|
524
|
+
top: auto;
|
|
525
|
+
bottom: 0;
|
|
526
|
+
padding-top: 0;
|
|
527
|
+
padding-bottom: max(env(safe-area-inset-bottom), 0.75rem);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/* The two live regions (status, then alert). Never display: none, even when empty: a live
|
|
531
|
+
region that is not rendered is not listening. */
|
|
532
|
+
.glass-toasts-region {
|
|
533
|
+
display: flex;
|
|
534
|
+
flex-direction: column;
|
|
535
|
+
align-items: center;
|
|
536
|
+
width: 100%;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.glass-toast + .glass-toast,
|
|
540
|
+
.glass-toasts-region:not(:empty) + .glass-toasts-region:not(:empty) {
|
|
541
|
+
margin-top: 0.5rem;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/* A pill while it holds one line; a rounded box when the message wraps. */
|
|
545
|
+
.glass-toast {
|
|
546
|
+
--lg-surface-blur: var(--lg-blur-thick);
|
|
547
|
+
--lg-shadow: var(--lg-shadow-lg);
|
|
548
|
+
display: flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
max-width: 28rem;
|
|
551
|
+
min-height: 44px;
|
|
552
|
+
padding: 0.625rem 1.25rem;
|
|
553
|
+
border-radius: 22px;
|
|
554
|
+
font-size: 0.875rem;
|
|
555
|
+
line-height: 1.25rem;
|
|
556
|
+
font-weight: 500;
|
|
557
|
+
pointer-events: auto;
|
|
558
|
+
animation: lg-pop var(--lg-duration) var(--lg-ease-spring) both;
|
|
559
|
+
transform-origin: top center;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.glass-toasts-bottom .glass-toast {
|
|
563
|
+
transform-origin: bottom center;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/* Danger: the solid danger fill. */
|
|
567
|
+
.glass-toast-danger {
|
|
568
|
+
--lg-fill: var(--lg-danger-fill);
|
|
569
|
+
--lg-rim: rgba(255, 255, 255, 0.28);
|
|
570
|
+
--lg-rim-low: rgba(255, 255, 255, 0);
|
|
571
|
+
--lg-edge: transparent;
|
|
572
|
+
--lg-surface-sheen: none;
|
|
573
|
+
color: #fff;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.glass-toast-message {
|
|
577
|
+
flex: 1 1 auto;
|
|
578
|
+
min-width: 0;
|
|
579
|
+
overflow-wrap: break-word;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/* 44px target, pulled into the padding so the toast stays 44px tall. */
|
|
583
|
+
.glass-toast-dismiss {
|
|
584
|
+
display: flex;
|
|
585
|
+
flex-shrink: 0;
|
|
586
|
+
align-items: center;
|
|
587
|
+
justify-content: center;
|
|
588
|
+
width: 44px;
|
|
589
|
+
height: 44px;
|
|
590
|
+
margin-top: -0.625rem;
|
|
591
|
+
margin-bottom: -0.625rem;
|
|
592
|
+
margin-inline-start: 0.25rem;
|
|
593
|
+
margin-inline-end: -1rem;
|
|
594
|
+
padding: 0;
|
|
595
|
+
border: 0;
|
|
596
|
+
border-radius: 9999px;
|
|
597
|
+
color: inherit;
|
|
598
|
+
background-color: transparent;
|
|
599
|
+
cursor: pointer;
|
|
600
|
+
transition: background-color var(--lg-duration-fast) ease;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.glass-toast-dismiss:hover {
|
|
604
|
+
background-color: rgba(127, 127, 127, 0.18);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.glass-toast-dismiss:focus-visible {
|
|
608
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
609
|
+
outline-offset: -2px;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.glass-toast-danger .glass-toast-dismiss:focus-visible {
|
|
613
|
+
outline-color: currentColor;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/* Tabs (<GlassTabList />): a pill track that scrolls sideways, without a scrollbar, when
|
|
617
|
+
the tabs do not fit. The selected tab is a raised pill. Focus rings sit inside the tabs,
|
|
618
|
+
where the scrolling track cannot clip them. */
|
|
619
|
+
.glass-tabs {
|
|
620
|
+
--lg-surface-blur: var(--lg-blur-thin);
|
|
621
|
+
--lg-shadow: var(--lg-shadow-sm);
|
|
622
|
+
display: flex;
|
|
623
|
+
width: max-content;
|
|
624
|
+
max-width: 100%;
|
|
625
|
+
padding: 0.25rem;
|
|
626
|
+
border-radius: 9999px;
|
|
627
|
+
overflow-x: auto;
|
|
628
|
+
overscroll-behavior-x: contain;
|
|
629
|
+
scrollbar-width: none;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.glass-tabs::-webkit-scrollbar {
|
|
633
|
+
display: none;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
.glass-tabs[aria-orientation='vertical'] {
|
|
637
|
+
flex-direction: column;
|
|
638
|
+
border-radius: var(--lg-radius-lg);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.glass-tab {
|
|
642
|
+
display: inline-flex;
|
|
643
|
+
flex-shrink: 0;
|
|
644
|
+
align-items: center;
|
|
645
|
+
justify-content: center;
|
|
646
|
+
gap: 0.375rem;
|
|
647
|
+
min-height: 44px;
|
|
648
|
+
padding: 0.5rem 1rem;
|
|
649
|
+
border: 0;
|
|
650
|
+
border-radius: 9999px;
|
|
651
|
+
font-family: inherit;
|
|
652
|
+
font-size: 0.875rem;
|
|
653
|
+
line-height: 1.25rem;
|
|
654
|
+
font-weight: 500;
|
|
655
|
+
white-space: nowrap;
|
|
656
|
+
color: inherit;
|
|
657
|
+
background-color: transparent;
|
|
658
|
+
cursor: pointer;
|
|
659
|
+
transition:
|
|
660
|
+
background-color var(--lg-duration-fast) ease,
|
|
661
|
+
box-shadow var(--lg-duration-fast) ease;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/* Concentric with the track's corners. */
|
|
665
|
+
.glass-tabs[aria-orientation='vertical'] .glass-tab {
|
|
666
|
+
justify-content: flex-start;
|
|
667
|
+
border-radius: calc(var(--lg-radius-lg) - 0.25rem);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.glass-tab:not(:disabled):hover {
|
|
671
|
+
background-color: rgb(var(--lg-c-line) / 0.06);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/* Selected: raised, outlined and bolder, not only a different colour. */
|
|
675
|
+
.glass-tab[aria-selected='true'] {
|
|
676
|
+
font-weight: 600;
|
|
677
|
+
color: rgb(var(--lg-c-ink));
|
|
678
|
+
background-color: rgb(var(--lg-c-raised));
|
|
679
|
+
box-shadow:
|
|
680
|
+
inset 0 0 0 1px rgb(var(--lg-c-line) / 0.08),
|
|
681
|
+
0 1px 3px rgb(0 0 0 / 0.12);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
.glass-tab:focus-visible {
|
|
685
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
686
|
+
outline-offset: -2px;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.glass-tab:disabled {
|
|
690
|
+
cursor: not-allowed;
|
|
691
|
+
opacity: 0.4;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.glass-tab-panel:focus-visible {
|
|
695
|
+
outline: 2px solid var(--lg-accent, var(--color-primary, #0a84ff));
|
|
696
|
+
outline-offset: 2px;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/* Stays hidden even if a class of yours sets `display` on the panel. */
|
|
700
|
+
.glass-tab-panel[hidden] {
|
|
701
|
+
display: none;
|
|
702
|
+
}
|
|
703
|
+
|
|
383
704
|
/* ── Tones ──────────────────────────────────────────────────────────── */
|
|
384
705
|
.glass-dark {
|
|
385
706
|
--lg-fill: var(--lg-dark-fill);
|
|
@@ -434,8 +755,8 @@
|
|
|
434
755
|
}
|
|
435
756
|
|
|
436
757
|
.glass-danger {
|
|
437
|
-
--lg-fill: var(--lg-danger);
|
|
438
|
-
--lg-fill-hover: var(--lg-danger-strong);
|
|
758
|
+
--lg-fill: var(--lg-danger-fill);
|
|
759
|
+
--lg-fill-hover: var(--lg-danger-fill-strong);
|
|
439
760
|
}
|
|
440
761
|
|
|
441
762
|
/* ── Thickness ──────────────────────────────────────────────────────── */
|
|
@@ -671,6 +992,71 @@ dialog.glass-dialog[data-dragging] {
|
|
|
671
992
|
user-select: none;
|
|
672
993
|
}
|
|
673
994
|
|
|
995
|
+
/* ── Confirm (<GlassConfirm />, or a <dialog class="glass-confirm">) ─── */
|
|
996
|
+
/* A centred box on every width: a question has to be answered, so it is never a sheet to
|
|
997
|
+
swipe away. The vh line is for engines without dvh (before Safari 15.4). */
|
|
998
|
+
dialog.glass-confirm {
|
|
999
|
+
width: 100%;
|
|
1000
|
+
max-width: min(28rem, calc(100% - 2rem));
|
|
1001
|
+
max-height: calc(100vh - 2rem);
|
|
1002
|
+
max-height: calc(100dvh - 2rem);
|
|
1003
|
+
margin: auto;
|
|
1004
|
+
padding: 1.5rem;
|
|
1005
|
+
border: 0;
|
|
1006
|
+
overflow-y: auto;
|
|
1007
|
+
overscroll-behavior: contain;
|
|
1008
|
+
border-radius: var(--lg-radius-xl);
|
|
1009
|
+
color: rgb(var(--lg-c-ink));
|
|
1010
|
+
background-color: var(--lg-sheet-fill, rgb(var(--lg-c-paper)));
|
|
1011
|
+
box-shadow:
|
|
1012
|
+
inset 0 0 0 1px rgb(var(--lg-c-line) / 0.1),
|
|
1013
|
+
var(--lg-shadow-lg);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
dialog.glass-confirm[open] {
|
|
1017
|
+
animation: lg-sheet-in var(--lg-duration) var(--lg-ease-spring) both;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
dialog.glass-confirm:focus {
|
|
1021
|
+
outline: none;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/* With a fallback: before Chrome 122, ::backdrop inherits no custom properties. */
|
|
1025
|
+
dialog.glass-confirm::backdrop {
|
|
1026
|
+
background-color: var(--lg-scrim, rgba(0, 0, 0, 0.4));
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.glass-confirm-title {
|
|
1030
|
+
margin: 0;
|
|
1031
|
+
font-size: 1.125rem;
|
|
1032
|
+
line-height: 1.5rem;
|
|
1033
|
+
font-weight: 600;
|
|
1034
|
+
color: rgb(var(--lg-c-ink));
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.glass-confirm-message {
|
|
1038
|
+
margin-top: 0.5rem;
|
|
1039
|
+
font-size: 0.9375rem;
|
|
1040
|
+
line-height: 1.375rem;
|
|
1041
|
+
color: rgb(var(--lg-c-ink-2));
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.glass-confirm-details {
|
|
1045
|
+
margin-top: 1rem;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/* Side by side when they fit, one above the other when they do not. */
|
|
1049
|
+
.glass-confirm-actions {
|
|
1050
|
+
display: flex;
|
|
1051
|
+
flex-wrap: wrap;
|
|
1052
|
+
gap: 0.75rem;
|
|
1053
|
+
margin-top: 1.5rem;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
.glass-confirm-actions > * {
|
|
1057
|
+
flex: 1 1 8rem;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
674
1060
|
/* ── Keyframes ──────────────────────────────────────────────────────── */
|
|
675
1061
|
/* Pop-ins animate transform only: an element with opacity < 1 can't sample its
|
|
676
1062
|
backdrop in Chromium, so fading would show unblurred content until it settles. */
|
|
@@ -713,8 +1099,12 @@ dialog.glass-dialog[data-dragging] {
|
|
|
713
1099
|
.glass-menu-item,
|
|
714
1100
|
.glass-sheet,
|
|
715
1101
|
.glass-scrim,
|
|
1102
|
+
.glass-toast,
|
|
1103
|
+
.glass-toast-dismiss,
|
|
1104
|
+
.glass-tab,
|
|
716
1105
|
dialog.glass-dialog[open],
|
|
717
|
-
dialog.glass-dialog::backdrop
|
|
1106
|
+
dialog.glass-dialog::backdrop,
|
|
1107
|
+
dialog.glass-confirm[open] {
|
|
718
1108
|
animation: none;
|
|
719
1109
|
transition: none;
|
|
720
1110
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -38,6 +38,85 @@ interface GlassButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
38
38
|
/** A glass button with a 44px touch target. Defaults to `type="button"`. */
|
|
39
39
|
declare const GlassButton: react.ForwardRefExoticComponent<GlassButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
40
40
|
|
|
41
|
+
type GlassConfirmTone = 'neutral' | 'danger';
|
|
42
|
+
interface GlassConfirmProps {
|
|
43
|
+
open: boolean;
|
|
44
|
+
/** The confirm button. */
|
|
45
|
+
onConfirm: () => void;
|
|
46
|
+
/** The cancel button, Esc, or any other way the dialog is closed without confirming. */
|
|
47
|
+
onCancel: () => void;
|
|
48
|
+
/** The question. Names the dialog (aria-labelledby). */
|
|
49
|
+
title: ReactNode;
|
|
50
|
+
/** What happens if they confirm. Describes the dialog (aria-describedby). */
|
|
51
|
+
message?: ReactNode;
|
|
52
|
+
confirmLabel?: string;
|
|
53
|
+
cancelLabel?: string;
|
|
54
|
+
/** `danger` for what is hard to undo: a red confirm button, and focus starts on Cancel. */
|
|
55
|
+
tone?: GlassConfirmTone;
|
|
56
|
+
confirmDisabled?: boolean;
|
|
57
|
+
/** Shown between the message and the buttons: more details, or an input. */
|
|
58
|
+
children?: ReactNode;
|
|
59
|
+
className?: string;
|
|
60
|
+
}
|
|
61
|
+
/** What `confirm()` of `useGlassConfirm` takes: the dialog's text and tone, and `details`. */
|
|
62
|
+
interface GlassConfirmOptions extends Pick<GlassConfirmProps, 'title' | 'message' | 'confirmLabel' | 'cancelLabel' | 'tone'> {
|
|
63
|
+
/** Shown between the message and the buttons, like `children` of <GlassConfirm>. */
|
|
64
|
+
details?: ReactNode;
|
|
65
|
+
}
|
|
66
|
+
interface GlassConfirmHook {
|
|
67
|
+
/** Asks, and resolves with the answer: true for confirm, false for anything else. */
|
|
68
|
+
confirm: (options: GlassConfirmOptions) => Promise<boolean>;
|
|
69
|
+
/** Render it once, anywhere in the component. */
|
|
70
|
+
dialog: ReactNode;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A confirmation on a native <dialog> (APG alertdialog): the page goes inert, focus stays
|
|
74
|
+
* inside and returns to the opener on close. It must be answered: Esc cancels, a tap on the
|
|
75
|
+
* backdrop does nothing.
|
|
76
|
+
*
|
|
77
|
+
* Focus starts on the confirm button, or on Cancel when `tone` is `danger` (or confirm is
|
|
78
|
+
* disabled), so a stray Enter never does the irreversible thing. An element in `children`
|
|
79
|
+
* with `autoFocus` (or `autofocus`) keeps focus instead.
|
|
80
|
+
*/
|
|
81
|
+
declare function GlassConfirm({ open, onConfirm, onCancel, title, message, confirmLabel, cancelLabel, tone, confirmDisabled, children, className, }: GlassConfirmProps): react.JSX.Element;
|
|
82
|
+
/**
|
|
83
|
+
* `await confirm({ title })` instead of wiring `open` state. Render `dialog` once.
|
|
84
|
+
*
|
|
85
|
+
* Each promise resolves exactly once: true on confirm, false on cancel, when a newer
|
|
86
|
+
* `confirm()` replaces it, or when the component unmounts.
|
|
87
|
+
*/
|
|
88
|
+
declare function useGlassConfirm(): GlassConfirmHook;
|
|
89
|
+
|
|
90
|
+
interface GlassFieldProps {
|
|
91
|
+
/** Names the control (a <label for>). Shown above it unless `hideLabel`. */
|
|
92
|
+
label: ReactNode;
|
|
93
|
+
/** Help under the control, read with it (aria-describedby). */
|
|
94
|
+
hint?: ReactNode;
|
|
95
|
+
/** What is wrong. Marks the control invalid and is read with it (aria-describedby). */
|
|
96
|
+
error?: ReactNode;
|
|
97
|
+
/** Hide the label visually; screen readers still read it. */
|
|
98
|
+
hideLabel?: boolean;
|
|
99
|
+
/** On the wrapper. */
|
|
100
|
+
className?: string;
|
|
101
|
+
/** On the control. */
|
|
102
|
+
inputClassName?: string;
|
|
103
|
+
}
|
|
104
|
+
interface GlassInputProps extends GlassFieldProps, Omit<ComponentPropsWithoutRef<'input'>, 'className'> {
|
|
105
|
+
}
|
|
106
|
+
interface GlassTextareaProps extends GlassFieldProps, Omit<ComponentPropsWithoutRef<'textarea'>, 'className'> {
|
|
107
|
+
}
|
|
108
|
+
interface GlassSelectProps extends GlassFieldProps, Omit<ComponentPropsWithoutRef<'select'>, 'className'> {
|
|
109
|
+
}
|
|
110
|
+
/** A labelled text input with an optional hint and error. Takes every <input> prop. */
|
|
111
|
+
declare const GlassInput: react.ForwardRefExoticComponent<GlassInputProps & react.RefAttributes<HTMLInputElement>>;
|
|
112
|
+
/** A labelled <textarea> with an optional hint and error. Takes every <textarea> prop. */
|
|
113
|
+
declare const GlassTextarea: react.ForwardRefExoticComponent<GlassTextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
114
|
+
/**
|
|
115
|
+
* A labelled <select> with an optional hint and error. Takes every <select> prop. A
|
|
116
|
+
* drop-down gets a chevron (`glass-select`); a list box (`multiple`, `size` > 1) shows none.
|
|
117
|
+
*/
|
|
118
|
+
declare const GlassSelect: react.ForwardRefExoticComponent<GlassSelectProps & react.RefAttributes<HTMLSelectElement>>;
|
|
119
|
+
|
|
41
120
|
/**
|
|
42
121
|
* True when the browser renders SVG filters inside `backdrop-filter`
|
|
43
122
|
* (currently Chromium only). Safari and Firefox accept the syntax but either
|
|
@@ -80,6 +159,92 @@ interface GlassSheetProps {
|
|
|
80
159
|
*/
|
|
81
160
|
declare function GlassSheet({ open, onClose, title, eyebrow, closeLabel, swipeToClose, footer, children, className, bodyClassName, }: GlassSheetProps): react.JSX.Element;
|
|
82
161
|
|
|
162
|
+
type GlassTabsOrientation = 'horizontal' | 'vertical';
|
|
163
|
+
interface GlassTabsProps {
|
|
164
|
+
/** The selected tab's `value`. */
|
|
165
|
+
value: string;
|
|
166
|
+
onChange: (value: string) => void;
|
|
167
|
+
/** Names the tab list (aria-label). Translate it. */
|
|
168
|
+
label: string;
|
|
169
|
+
/** Default `horizontal`: Left and Right move between tabs. `vertical`: Up and Down. */
|
|
170
|
+
orientation?: GlassTabsOrientation;
|
|
171
|
+
children?: ReactNode;
|
|
172
|
+
}
|
|
173
|
+
interface GlassTabListProps {
|
|
174
|
+
children?: ReactNode;
|
|
175
|
+
className?: string;
|
|
176
|
+
}
|
|
177
|
+
interface GlassTabProps {
|
|
178
|
+
/** Matches the `value` of its <GlassTabPanel>. */
|
|
179
|
+
value: string;
|
|
180
|
+
disabled?: boolean;
|
|
181
|
+
children?: ReactNode;
|
|
182
|
+
className?: string;
|
|
183
|
+
}
|
|
184
|
+
interface GlassTabPanelProps {
|
|
185
|
+
/** Matches the `value` of its <GlassTab>. */
|
|
186
|
+
value: string;
|
|
187
|
+
children?: ReactNode;
|
|
188
|
+
className?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Tabs (APG tabs pattern, automatic activation): the arrow keys move focus along the tabs
|
|
192
|
+
* and select the tab they land on, wrapping at the ends and skipping disabled tabs. Home and
|
|
193
|
+
* End go to the first and last. Only the selected tab is in the Tab order.
|
|
194
|
+
*
|
|
195
|
+
* Holds the state for <GlassTabList>, <GlassTab> and <GlassTabPanel>, and renders only its
|
|
196
|
+
* children, so the layout around them is yours.
|
|
197
|
+
*/
|
|
198
|
+
declare function GlassTabs({ value, onChange, label, orientation, children, }: GlassTabsProps): react.JSX.Element;
|
|
199
|
+
/**
|
|
200
|
+
* The row (or column) of tabs: a glass track that scrolls sideways when the tabs do not fit.
|
|
201
|
+
* Marked `data-glass-no-drag`, so in a sheet a sideways swipe along it never pulls the sheet.
|
|
202
|
+
*/
|
|
203
|
+
declare function GlassTabList({ children, className }: GlassTabListProps): react.JSX.Element;
|
|
204
|
+
/** One tab. Selected when its `value` is the value of <GlassTabs>. */
|
|
205
|
+
declare function GlassTab({ value, disabled, children, className }: GlassTabProps): react.JSX.Element;
|
|
206
|
+
/**
|
|
207
|
+
* The content of one tab. Hidden (not unmounted) while its tab is not selected, so its state
|
|
208
|
+
* and scroll position survive a switch. Focusable, so keyboard users can reach content that
|
|
209
|
+
* has nothing focusable in it.
|
|
210
|
+
*/
|
|
211
|
+
declare function GlassTabPanel({ value, children, className }: GlassTabPanelProps): react.JSX.Element;
|
|
212
|
+
|
|
213
|
+
type GlassToastTone = 'neutral' | 'danger';
|
|
214
|
+
interface GlassToastOptions {
|
|
215
|
+
/** `danger` is announced at once (role="alert") and stays until dismissed. */
|
|
216
|
+
tone?: GlassToastTone;
|
|
217
|
+
/**
|
|
218
|
+
* How long a neutral toast stays (ms). Default 5000. `Infinity` or 0 keeps it until it is
|
|
219
|
+
* dismissed. Ignored for `danger`, which always stays.
|
|
220
|
+
*/
|
|
221
|
+
duration?: number;
|
|
222
|
+
}
|
|
223
|
+
interface GlassToastsProps {
|
|
224
|
+
/** Accessible name of the dismiss button. Translate it. */
|
|
225
|
+
dismissLabel?: string;
|
|
226
|
+
/** Where the stack sits. Default `top`. */
|
|
227
|
+
position?: 'top' | 'bottom';
|
|
228
|
+
className?: string;
|
|
229
|
+
}
|
|
230
|
+
/** Shows a toast in the mounted <GlassToasts />. Returns its id, for `dismissToast(id)`. */
|
|
231
|
+
declare function toast(message: ReactNode, options?: GlassToastOptions): number;
|
|
232
|
+
/** Removes the toast with this id, or every toast when called without one. */
|
|
233
|
+
declare function dismissToast(id?: number): void;
|
|
234
|
+
/**
|
|
235
|
+
* Where `toast()` shows up. Mount it once, near the root of the app.
|
|
236
|
+
*
|
|
237
|
+
* Two live regions are always in the page, so assistive tech is already listening when a
|
|
238
|
+
* toast arrives: neutral toasts go in `role="status"` (read when the person is idle), danger
|
|
239
|
+
* toasts in `role="alert"` (read at once). `aria-atomic="false"` overrides the roles' default,
|
|
240
|
+
* so a new toast is read on its own rather than with the ones already showing.
|
|
241
|
+
*
|
|
242
|
+
* Toasts never take focus. Neutral ones leave after `duration`, pausing while hovered or
|
|
243
|
+
* focused; danger ones stay until dismissed. Rendered into <body> after mount, so the server
|
|
244
|
+
* render and hydration match.
|
|
245
|
+
*/
|
|
246
|
+
declare function GlassToasts({ dismissLabel, position, className, }: GlassToastsProps): react.ReactPortal | null;
|
|
247
|
+
|
|
83
248
|
interface ReleaseState {
|
|
84
249
|
/** How far the sheet is pulled down (px). */
|
|
85
250
|
offset: number;
|
|
@@ -142,5 +307,5 @@ interface SwipeToCloseOptions {
|
|
|
142
307
|
*/
|
|
143
308
|
declare function useSwipeToClose(sheetRef: RefObject<HTMLElement | null>, { enabled, scrollRef, onClose, media }: SwipeToCloseOptions): void;
|
|
144
309
|
|
|
145
|
-
export { Glass, GlassButton, GlassFilter, GlassSheet, glassClasses, shouldClose, supportsBackdropRefraction, useSwipeToClose };
|
|
146
|
-
export type { GlassButtonProps, GlassButtonSize, GlassButtonVariant, GlassOptions, GlassProps, GlassShape, GlassSheetProps, GlassThickness, GlassTone, ReleaseState, SwipeToCloseOptions };
|
|
310
|
+
export { Glass, GlassButton, GlassConfirm, GlassFilter, GlassInput, GlassSelect, GlassSheet, GlassTab, GlassTabList, GlassTabPanel, GlassTabs, GlassTextarea, GlassToasts, dismissToast, glassClasses, shouldClose, supportsBackdropRefraction, toast, useGlassConfirm, useSwipeToClose };
|
|
311
|
+
export type { GlassButtonProps, GlassButtonSize, GlassButtonVariant, GlassConfirmHook, GlassConfirmOptions, GlassConfirmProps, GlassConfirmTone, GlassFieldProps, GlassInputProps, GlassOptions, GlassProps, GlassSelectProps, GlassShape, GlassSheetProps, GlassTabListProps, GlassTabPanelProps, GlassTabProps, GlassTabsOrientation, GlassTabsProps, GlassTextareaProps, GlassThickness, GlassToastOptions, GlassToastTone, GlassToastsProps, GlassTone, ReleaseState, SwipeToCloseOptions };
|