@zakisheriff/liquid-glass 0.2.7 → 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 CHANGED
@@ -45,12 +45,13 @@ Works with Next.js (the bundle is marked `"use client"`), Vite and CRA.
45
45
  | --- | --- |
46
46
  | `GlassButton` | Pill or circle (`icon` with no children). Swells, leans toward a drag, wobbles on release. |
47
47
  | `GlassSwitch` | The knob lifts into a clear lens that refracts the track. Tap, or drag with rubber-banding. |
48
- | `GlassNav` | Floating tab bar. The selection inflates into a lens you can drag across tabs. |
48
+ | `GlassNav` | Floating tab bar. The selection inflates into a lens you can drag across tabs. Icons with labels, or icons only. |
49
49
  | `GlassSegmented` | Segmented control. The whole control swells and the selection becomes a draggable lens. |
50
50
  | `GlassSlider` | Thin track with a lens thumb that magnifies the rail, or `showThumb={false}` for a Control Center block. |
51
51
  | `GlassInput` | Search / text field with icon, trailing accessory and clear button. |
52
52
  | `GlassCard` | Refracting panel, `regular` or `clear`. |
53
- | `GlassSheet` | Floating bottom sheet. Spring entrance, drag or flick to dismiss. |
53
+ | `GlassMenu` | Pull-down menu that grows out of its glass button and folds back into it. Slide a finger across the items to pick one. |
54
+ | `GlassSheet` | Floating bottom sheet. Spring entrance, drag or flick to dismiss. With `detents` it opens at half height and expands to full screen. |
54
55
 
55
56
  ### Buttons
56
57
 
@@ -82,6 +83,17 @@ Works with Next.js (the bundle is marked `"use client"`), Vite and CRA.
82
83
  ]}
83
84
  />
84
85
 
86
+ <GlassNav showLabels={false} activeIndex={tab} onChange={setTab} items={tabs} />
87
+
88
+ <GlassMenu
89
+ icon={<EllipsisIcon />}
90
+ aria-label="More"
91
+ items={[
92
+ { label: 'View as Gallery', icon: <GridIcon />, checked: view === 'gallery', onSelect: () => setView('gallery') },
93
+ { label: 'Delete', destructive: true, onSelect: remove },
94
+ ]}
95
+ />
96
+
85
97
  <GlassSegmented options={['Chat', 'Work']} value={mode} onChange={setMode} />
86
98
  <GlassSegmented size="sm" options={[{ label: 'Light', icon: <SunIcon /> }, 'Dark']} value={t} onChange={setT} />
87
99
 
@@ -94,22 +106,26 @@ Works with Next.js (the bundle is marked `"use client"`), Vite and CRA.
94
106
  <GlassCard variant="clear">…</GlassCard>
95
107
 
96
108
  <GlassSheet open={open} onClose={() => setOpen(false)} aria-label="Details">…</GlassSheet>
109
+ <GlassSheet open={open} onClose={() => setOpen(false)} detents={['medium', 'large']} aria-label="Details">…</GlassSheet>
97
110
  ```
98
111
 
99
112
  Sliders drag continuously by default (`step="any"`). Pass a numeric `step`, such as `step={5}`, when values should snap to fixed increments. `onChange` receives the full-precision value while block labels show a rounded number.
100
113
 
114
+ Pass a positioned element as a sheet's `container` to keep the sheet inside that element without locking page scrolling. Sheets use the full viewport by default.
115
+
101
116
  ### Props reference
102
117
 
103
118
  | Component | Props |
104
119
  | --- | --- |
105
120
  | `GlassButton` | `variant` (`glass` · `clear` · `tinted` · `filled`), `destructive`, `tint`, `size`, `icon`, `shimmer`, `intensity`, `thickness`, plus all `<button>` props |
106
121
  | `GlassSwitch` | `checked`, `defaultChecked`, `onChange(checked)`, `tint`, `disabled`, `intensity` |
107
- | `GlassNav` | `items: { label, icon? }[]`, `activeIndex`, `onChange(index)`, `intensity` |
122
+ | `GlassNav` | `items: { label, icon? }[]`, `activeIndex`, `onChange(index)`, `showLabels`, `intensity` |
123
+ | `GlassMenu` | `icon`, `items: { label, icon?, checked?, destructive?, disabled?, onSelect? }[]`, `aria-label`, `align` (`end` · `start`), `size`, `width`, `check` |
108
124
  | `GlassSegmented` | `options: (string \| { label, icon? })[]`, `value`, `onChange(index)`, `size` (`sm` · `md`), `intensity` |
109
125
  | `GlassSlider` | `value`, `min`, `max`, `step`, `onChange(value)`, `showThumb`, `icon`, `label`, `tint`, `intensity` |
110
126
  | `GlassInput` | `type`, `value`, `onChange(event)`, `placeholder`, `label`, `icon`, `trailing`, `onClear`, `tint`, `intensity` |
111
127
  | `GlassCard` | `variant` (`regular` · `clear`), `padding`, `radius`, `tint`, `thickness`, `intensity` |
112
- | `GlassSheet` | `open`, `onClose()`, `tint`, `aria-label`, `intensity` |
128
+ | `GlassSheet` | `open`, `onClose()`, `detents` (`['medium', 'large']`), `container`, `tint`, `aria-label`, `intensity` |
113
129
 
114
130
  `intensity` (1–10) scales refraction strength everywhere.
115
131
 
package/dist/index.css CHANGED
@@ -20,16 +20,17 @@
20
20
  --lg-lens-edge: rgb(0 0 0 / 0.07);
21
21
  --lg-lens-ring: rgb(0 0 0 / 0.22);
22
22
  --lg-navigation-fill: rgb(255 255 255 / 0.48);
23
- --lg-selection-lens-fill: rgb(255 255 255 / 0.025);
23
+ --lg-selection-lens-fill: rgb(255 255 255 / 0.18);
24
24
  --lg-selection-lens-edge: rgb(45 48 53 / 0.28);
25
25
  --lg-selection-lens-bevel: inset 0 3px 7px rgb(45 48 53 / 0.1), inset 0 -1px 2px rgb(255 255 255 / 0.8);
26
26
  --lg-selection-lens-brightness: 1;
27
27
  --lg-switch-face-fade: 1;
28
28
  --lg-panel-fill: rgb(255 255 255 / 0.62);
29
+ --lg-menu-fill: rgb(250 250 252 / 0.94);
29
30
  --lg-panel-blur: 28px;
30
31
  --lg-tab-selection: rgb(0 0 0 / 0.07);
31
32
  --lg-segment-selection: rgb(0 0 0 / 0.08);
32
- --lg-track: rgb(120 120 128 / 0.16);
33
+ --lg-track: rgb(120 120 128 / 0.26);
33
34
  --lg-rail: rgb(120 120 128 / 0.2);
34
35
  --lg-block-well: rgb(120 120 128 / 0.24);
35
36
  --lg-block-lit: #ffffff;
@@ -71,15 +72,16 @@
71
72
  --lg-lens-edge: rgb(255 255 255 / 0.12);
72
73
  --lg-lens-ring: rgb(255 255 255 / 0.3);
73
74
  --lg-navigation-fill: var(--lg-fill);
74
- --lg-selection-lens-fill: rgb(255 255 255 / 0.06);
75
+ --lg-selection-lens-fill: rgb(255 255 255 / 0.09);
75
76
  --lg-selection-lens-edge: rgb(255 255 255 / 0.25);
76
77
  --lg-selection-lens-bevel: inset 0 0 0 transparent;
77
78
  --lg-selection-lens-brightness: 1.06;
78
79
  --lg-switch-face-fade: 0.92;
79
80
  --lg-panel-fill: rgb(30 30 33 / 0.62);
81
+ --lg-menu-fill: rgb(38 38 42 / 0.94);
80
82
  --lg-tab-selection: rgb(0 0 0 / 0.36);
81
83
  --lg-segment-selection: rgb(255 255 255 / 0.14);
82
- --lg-track: rgb(120 120 128 / 0.36);
84
+ --lg-track: rgb(120 120 128 / 0.44);
83
85
  --lg-rail: rgb(120 120 128 / 0.4);
84
86
  --lg-block-well: rgb(120 120 128 / 0.3);
85
87
  --lg-block-lit: #ffffff;
@@ -111,15 +113,16 @@
111
113
  --lg-lens-edge: rgb(255 255 255 / 0.12);
112
114
  --lg-lens-ring: rgb(255 255 255 / 0.3);
113
115
  --lg-navigation-fill: var(--lg-fill);
114
- --lg-selection-lens-fill: rgb(255 255 255 / 0.06);
116
+ --lg-selection-lens-fill: rgb(255 255 255 / 0.09);
115
117
  --lg-selection-lens-edge: rgb(255 255 255 / 0.25);
116
118
  --lg-selection-lens-bevel: inset 0 0 0 transparent;
117
119
  --lg-selection-lens-brightness: 1.06;
118
120
  --lg-switch-face-fade: 0.92;
119
121
  --lg-panel-fill: rgb(30 30 33 / 0.62);
122
+ --lg-menu-fill: rgb(38 38 42 / 0.94);
120
123
  --lg-tab-selection: rgb(0 0 0 / 0.36);
121
124
  --lg-segment-selection: rgb(255 255 255 / 0.14);
122
- --lg-track: rgb(120 120 128 / 0.36);
125
+ --lg-track: rgb(120 120 128 / 0.44);
123
126
  --lg-rail: rgb(120 120 128 / 0.4);
124
127
  --lg-thumb-shadow: 0 3px 8px rgb(0 0 0 / 0.3), 0 1px 1px rgb(0 0 0 / 0.16);
125
128
  --lg-block-well: rgb(120 120 128 / 0.3);
@@ -499,6 +502,14 @@
499
502
  .lg-sheet::after {
500
503
  display: none;
501
504
  }
505
+ .lg-sheet--detents.lg-glass {
506
+ height: calc(100% - 10px - max(8px, env(safe-area-inset-bottom)));
507
+ max-height: none;
508
+ }
509
+ .lg-sheet--detents:not([data-raised]) {
510
+ overflow: hidden;
511
+ touch-action: none;
512
+ }
502
513
  .lg-sheet__grabber-zone {
503
514
  display: flex;
504
515
  justify-content: center;
@@ -516,6 +527,113 @@
516
527
  padding: 8px 24px 28px;
517
528
  }
518
529
 
530
+ /* src/components/GlassMenu/GlassMenu.css */
531
+ .lg-menu-anchor {
532
+ position: relative;
533
+ display: inline-flex;
534
+ flex: none;
535
+ }
536
+ .lg-menu-surface {
537
+ position: absolute;
538
+ top: 0;
539
+ right: 0;
540
+ z-index: 50;
541
+ color: var(--lg-fg);
542
+ font-family: var(--lg-font);
543
+ touch-action: none;
544
+ }
545
+ .lg-menu-anchor[data-align=start] .lg-menu-surface {
546
+ right: auto;
547
+ left: 0;
548
+ }
549
+ .lg-menu.lg-glass {
550
+ --lg-glass-fill: var(--lg-menu-fill);
551
+ --lg-glass-blur: var(--lg-panel-blur);
552
+ position: absolute;
553
+ inset: 0;
554
+ box-shadow: 0 12px 40px rgb(0 0 0 / 0.16), inset 0 0 0 0.5px var(--lg-edge);
555
+ transform-origin: top right;
556
+ transition: none;
557
+ pointer-events: none;
558
+ }
559
+ .lg-menu-anchor[data-align=start] .lg-menu.lg-glass {
560
+ transform-origin: top left;
561
+ }
562
+ .lg-menu::after {
563
+ display: none;
564
+ }
565
+ .lg-menu__content {
566
+ position: absolute;
567
+ top: 0;
568
+ right: 0;
569
+ z-index: 1;
570
+ box-sizing: border-box;
571
+ padding: 6px;
572
+ transform-origin: top right;
573
+ }
574
+ .lg-menu-anchor[data-align=start] .lg-menu__content {
575
+ right: auto;
576
+ left: 0;
577
+ transform-origin: top left;
578
+ }
579
+ .lg-menu__item {
580
+ display: flex;
581
+ align-items: center;
582
+ gap: 12px;
583
+ width: 100%;
584
+ min-height: 44px;
585
+ padding: 0 14px;
586
+ border: 0;
587
+ border-radius: 18px;
588
+ background: none;
589
+ color: inherit;
590
+ font: inherit;
591
+ font-size: 15px;
592
+ text-align: left;
593
+ cursor: pointer;
594
+ user-select: none;
595
+ -webkit-user-select: none;
596
+ -webkit-touch-callout: none;
597
+ -webkit-tap-highlight-color: transparent;
598
+ }
599
+ .lg-menu__item:hover,
600
+ .lg-menu__item[data-active],
601
+ .lg-menu__item:focus-visible {
602
+ background: color-mix(in srgb, var(--lg-fg) 8%, transparent);
603
+ outline: none;
604
+ }
605
+ .lg-menu__item:disabled {
606
+ opacity: 0.4;
607
+ cursor: default;
608
+ }
609
+ .lg-menu__item[data-destructive] {
610
+ color: var(--lg-tint-default, #ff3b30);
611
+ }
612
+ .lg-menu__icon {
613
+ display: grid;
614
+ place-items: center;
615
+ width: 20px;
616
+ height: 20px;
617
+ flex: none;
618
+ }
619
+ .lg-menu__icon > :is(svg, .lg-symbol) {
620
+ width: 100%;
621
+ height: 100%;
622
+ }
623
+ .lg-menu__label {
624
+ flex: 1;
625
+ min-width: 0;
626
+ overflow: hidden;
627
+ text-overflow: ellipsis;
628
+ white-space: nowrap;
629
+ }
630
+ .lg-menu__check {
631
+ display: grid;
632
+ place-items: center;
633
+ flex: none;
634
+ color: var(--lg-accent);
635
+ }
636
+
519
637
  /* src/components/internal/LensTrack.css */
520
638
  .lg-track {
521
639
  --lg-pad: 4px;
@@ -621,6 +739,10 @@
621
739
  }
622
740
  .lg-track__lens.lg-glass::before {
623
741
  opacity: calc(var(--lg-lift) * 1.2);
742
+ z-index: 2;
743
+ }
744
+ .lg-track__lens.lg-glass::after {
745
+ display: none;
624
746
  }
625
747
  .lg-track__select {
626
748
  z-index: 1;
@@ -632,7 +754,9 @@
632
754
  }
633
755
  .lg-track[data-lifted] .lg-track__lens.lg-glass {
634
756
  z-index: 4;
635
- -webkit-backdrop-filter: blur(0.6px) saturate(1.5) brightness(var(--lg-selection-lens-brightness));
757
+ }
758
+ .lg-track[data-lifted] .lg-track__lens.lg-glass[data-lg-refract] {
759
+ -webkit-backdrop-filter: var(--lg-filter, ) blur(0.3px) saturate(1.5) brightness(var(--lg-selection-lens-brightness));
636
760
  backdrop-filter: var(--lg-filter, ) blur(0.3px) saturate(1.5) brightness(var(--lg-selection-lens-brightness));
637
761
  }
638
762
  .lg-track:not([data-ready]) .lg-track__lens {
@@ -640,7 +764,7 @@
640
764
  }
641
765
  .lg-track--tabbar {
642
766
  --lg-navigation-fill: var(--lg-fill);
643
- --lg-selection-lens-fill: rgb(255 255 255 / 0.06);
767
+ --lg-selection-lens-fill: rgb(255 255 255 / 0.09);
644
768
  --lg-selection-lens-edge: rgb(255 255 255 / 0.25);
645
769
  --lg-selection-lens-bevel: inset 0 0 0 transparent;
646
770
  --lg-selection-lens-brightness: 1.06;
@@ -662,6 +786,10 @@
662
786
  .lg-track--tabbar .lg-nav__label {
663
787
  line-height: 1.1;
664
788
  }
789
+ .lg-track--tabbar.lg-track--icons-only .lg-nav__icon {
790
+ width: 28px;
791
+ height: 28px;
792
+ }
665
793
  .lg-track--tabbar.lg-track--labels-only {
666
794
  --lg-item-h: 44px;
667
795
  font-size: 15px;
@@ -690,6 +818,34 @@
690
818
  --lg-pad: 3px;
691
819
  font-size: 13px;
692
820
  }
821
+ .lg-track[data-lg-copy] > .lg-track__item {
822
+ color: var(--lg-track-active, var(--lg-accent));
823
+ }
824
+ .lg-track[data-lg-copy] .lg-nav__label {
825
+ background: none;
826
+ color: var(--lg-track-active, var(--lg-accent));
827
+ -webkit-text-fill-color: currentColor;
828
+ }
829
+ .lg-track[data-lg-copy] .lg-nav__icon > .lg-symbol {
830
+ background: var(--lg-track-active, var(--lg-accent));
831
+ }
832
+ [data-lg-copy] > :is(.lg-track__glass, .lg-track__select) {
833
+ visibility: hidden;
834
+ }
835
+ .lg-track[data-lifted]:not([data-lg-copy]) > .lg-track__item :is(.lg-nav__label, .lg-nav__icon) {
836
+ -webkit-mask: var(--lg-content-hide, none);
837
+ mask: var(--lg-content-hide, none);
838
+ -webkit-mask-composite:
839
+ source-out,
840
+ source-over,
841
+ source-over,
842
+ source-over;
843
+ mask-composite:
844
+ subtract,
845
+ add,
846
+ add,
847
+ add;
848
+ }
693
849
  .lg-track:not([data-lifted]) .lg-track__lens > .lg-mirror {
694
850
  visibility: hidden;
695
851
  }
@@ -697,6 +853,7 @@
697
853
  /* src/components/GlassSlider/GlassSlider.css */
698
854
  .lg-slider {
699
855
  --lg-lift: 0;
856
+ --lg-over: 0px;
700
857
  position: relative;
701
858
  width: 100%;
702
859
  height: 38px;
@@ -704,6 +861,9 @@
704
861
  touch-action: none;
705
862
  cursor: pointer;
706
863
  -webkit-tap-highlight-color: transparent;
864
+ user-select: none;
865
+ -webkit-user-select: none;
866
+ -webkit-touch-callout: none;
707
867
  }
708
868
  .lg-slider[data-lifted],
709
869
  .lg-slider[data-dragging] {
@@ -724,7 +884,7 @@
724
884
  .lg-slider__fill {
725
885
  display: block;
726
886
  height: 100%;
727
- width: calc(19px + (100% - 38px) * var(--lg-progress));
887
+ width: calc(19px + (100% - 38px) * var(--lg-progress) + 19px * (min(0, var(--lg-progress) / 0.12 - 1) + max(0, (var(--lg-progress) - 0.88) / 0.12)));
728
888
  border-radius: inherit;
729
889
  background: var(--lg-slider-fill, var(--lg-accent));
730
890
  }
@@ -732,6 +892,7 @@
732
892
  position: absolute;
733
893
  top: 50%;
734
894
  left: calc(19px + (100% - 38px) * var(--lg-progress));
895
+ translate: var(--lg-over) 0;
735
896
  width: 0;
736
897
  height: 0;
737
898
  pointer-events: none;
@@ -755,12 +916,12 @@
755
916
  transition: none;
756
917
  will-change: scale;
757
918
  }
758
- .lg-slider[data-lifted] .lg-slider__thumb.lg-glass {
759
- -webkit-backdrop-filter: blur(0.5px) saturate(1.6) brightness(1.08);
919
+ .lg-slider[data-lifted] .lg-slider__thumb.lg-glass[data-lg-refract] {
920
+ -webkit-backdrop-filter: var(--lg-filter, ) blur(0.3px) saturate(1.6) brightness(1.08);
760
921
  backdrop-filter: var(--lg-filter, ) blur(0.3px) saturate(1.6) brightness(1.08);
761
922
  }
762
923
  .lg-slider[data-mirror] > .lg-slider__rail {
763
- --x: calc(19px + (100% - 38px) * var(--lg-progress));
924
+ --x: calc(19px + (100% - 38px) * var(--lg-progress) + var(--lg-over));
764
925
  --r: calc(26px * var(--lg-lift));
765
926
  -webkit-mask-image:
766
927
  linear-gradient(
@@ -889,11 +1050,14 @@
889
1050
  margin: 0;
890
1051
  border: 0;
891
1052
  border-radius: 999px;
892
- background: var(--lg-track);
1053
+ background: none;
893
1054
  cursor: pointer;
894
1055
  touch-action: none;
895
1056
  -webkit-tap-highlight-color: transparent;
896
1057
  vertical-align: middle;
1058
+ user-select: none;
1059
+ -webkit-user-select: none;
1060
+ -webkit-touch-callout: none;
897
1061
  }
898
1062
  .lg-switch::before {
899
1063
  content: "";
@@ -903,6 +1067,34 @@
903
1067
  .lg-switch[data-lifted] {
904
1068
  z-index: 10;
905
1069
  }
1070
+ .lg-switch__track {
1071
+ position: absolute;
1072
+ inset: 0;
1073
+ border-radius: inherit;
1074
+ background: var(--lg-track);
1075
+ pointer-events: none;
1076
+ }
1077
+ .lg-switch[data-lifted]:not([data-lg-copy]) > .lg-switch__track,
1078
+ .lg-switch[data-lifted]:not([data-lg-copy]) > .lg-switch__fill {
1079
+ --a: clamp(0px, var(--lg-knob-x) - var(--lg-hole) - 7px, 100%);
1080
+ --b: clamp(0px, var(--lg-knob-x) - var(--lg-hole) + 5px, 100%);
1081
+ --c: clamp(0px, var(--lg-knob-x) + var(--lg-hole) - 5px, 100%);
1082
+ --d: clamp(0px, var(--lg-knob-x) + var(--lg-hole) + 7px, 100%);
1083
+ -webkit-mask-image:
1084
+ linear-gradient(
1085
+ 90deg,
1086
+ #000 var(--a),
1087
+ transparent var(--b),
1088
+ transparent var(--c),
1089
+ #000 var(--d));
1090
+ mask-image:
1091
+ linear-gradient(
1092
+ 90deg,
1093
+ #000 var(--a),
1094
+ transparent var(--b),
1095
+ transparent var(--c),
1096
+ #000 var(--d));
1097
+ }
906
1098
  .lg-switch__fill {
907
1099
  position: absolute;
908
1100
  inset: 0;