@glass-sdk/liquid-glass 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +235 -2
- package/dist/core/concentric.js +86 -0
- package/dist/core/materials.js +41 -0
- package/dist/core/morph-path.js +206 -0
- package/dist/core/optics.js +7 -0
- package/dist/core/progressive.js +35 -0
- package/dist/core/shape.js +95 -0
- package/dist/core/spring.js +78 -0
- package/dist/core/union.js +117 -0
- package/dist/core.js +6 -0
- package/dist/dom/compose-layers.js +54 -0
- package/dist/dom/compound-field.js +23 -0
- package/dist/dom/control-motion.js +101 -0
- package/dist/dom/engine.js +7 -0
- package/dist/dom/exit-handoff.js +14 -0
- package/dist/dom/filter-bounds.js +87 -0
- package/dist/dom/filter-budget.js +45 -0
- package/dist/dom/filter-groups.js +38 -0
- package/dist/dom/filter-paint-root.js +41 -0
- package/dist/dom/filter-patch.js +129 -0
- package/dist/dom/filter-reach.js +36 -0
- package/dist/dom/filter-stages.js +7 -0
- package/dist/dom/fixed-shape.js +20 -0
- package/dist/dom/foreground.js +36 -0
- package/dist/dom/interaction.js +129 -0
- package/dist/dom/lens-layers.js +163 -0
- package/dist/dom/map-blend.js +8 -0
- package/dist/dom/map-encoder.js +47 -0
- package/dist/dom/map-encoder.worker.js +16 -0
- package/dist/dom/map-encoding.js +17 -0
- package/dist/dom/map-image.js +34 -0
- package/dist/dom/map-store.js +189 -0
- package/dist/dom/maps.js +131 -0
- package/dist/dom/material-graph.js +52 -0
- package/dist/dom/morph.js +296 -0
- package/dist/dom/page-zoom.js +46 -0
- package/dist/dom/png.js +105 -0
- package/dist/dom/progressive.js +299 -0
- package/dist/dom/renderer.js +6 -0
- package/dist/dom/sampling-bounds.js +22 -0
- package/dist/dom/selection.js +106 -0
- package/dist/dom/shape-layout.js +199 -0
- package/dist/dom/shared-backdrop.js +41 -0
- package/dist/dom/ticker.js +103 -0
- package/dist/dom/warm.js +108 -0
- package/dist/dom.js +694 -0
- package/dist/gpu/geometry.js +9 -0
- package/dist/gpu/maps.js +8 -0
- package/dist/gpu/planes.js +4 -0
- package/dist/gpu.js +213 -0
- package/dist/index.js +11 -0
- package/dist/react/button.js +23 -0
- package/dist/react/control-thumb.js +50 -0
- package/dist/react/menu.js +159 -0
- package/dist/react/merged-ref.js +18 -0
- package/dist/react/progressive.js +73 -0
- package/dist/react/scene.js +122 -0
- package/dist/react/shape.js +93 -0
- package/dist/react/surface.js +69 -0
- package/dist/react/tabs.js +94 -0
- package/dist/react/toolbar.js +145 -0
- package/dist/react/value-control-motion.js +9 -0
- package/dist/react/value-controls.js +176 -0
- package/dist/styles.css +360 -0
- package/dist/styles.d.css.ts +2 -0
- package/dist/types/core/concentric.d.ts +32 -0
- package/dist/types/core/index.d.ts +10 -0
- package/dist/types/core/materials.d.ts +43 -0
- package/dist/types/core/morph-path.d.ts +110 -0
- package/dist/types/core/optics.d.ts +1 -0
- package/dist/types/core/progressive.d.ts +17 -0
- package/dist/types/core/shape.d.ts +16 -0
- package/dist/types/core/spring.d.ts +60 -0
- package/dist/types/core/union.d.ts +20 -0
- package/dist/types/dom/compose-layers.d.ts +15 -0
- package/dist/types/dom/compound-field.d.ts +35 -0
- package/dist/types/dom/control-motion.d.ts +13 -0
- package/dist/types/dom/engine.d.ts +9 -0
- package/dist/types/dom/exit-handoff.d.ts +7 -0
- package/dist/types/dom/filter-bounds.d.ts +30 -0
- package/dist/types/dom/filter-budget.d.ts +20 -0
- package/dist/types/dom/filter-groups.d.ts +25 -0
- package/dist/types/dom/filter-paint-root.d.ts +9 -0
- package/dist/types/dom/filter-patch.d.ts +4 -0
- package/dist/types/dom/filter-reach.d.ts +23 -0
- package/dist/types/dom/filter-stages.d.ts +5 -0
- package/dist/types/dom/fixed-shape.d.ts +3 -0
- package/dist/types/dom/foreground.d.ts +20 -0
- package/dist/types/dom/index.d.ts +64 -0
- package/dist/types/dom/interaction.d.ts +16 -0
- package/dist/types/dom/lens-layers.d.ts +68 -0
- package/dist/types/dom/map-blend.d.ts +22 -0
- package/dist/types/dom/map-encoder.d.ts +5 -0
- package/dist/types/dom/map-encoder.worker.d.ts +1 -0
- package/dist/types/dom/map-encoding.d.ts +5 -0
- package/dist/types/dom/map-image.d.ts +17 -0
- package/dist/types/dom/map-store.d.ts +22 -0
- package/dist/types/dom/maps.d.ts +31 -0
- package/dist/types/dom/material-graph.d.ts +22 -0
- package/dist/types/dom/morph.d.ts +78 -0
- package/dist/types/dom/page-zoom.d.ts +18 -0
- package/dist/types/dom/png.d.ts +9 -0
- package/dist/types/dom/progressive.d.ts +42 -0
- package/dist/types/dom/renderer.d.ts +4 -0
- package/dist/types/dom/sampling-bounds.d.ts +10 -0
- package/dist/types/dom/selection.d.ts +5 -0
- package/dist/types/dom/shape-layout.d.ts +29 -0
- package/dist/types/dom/shared-backdrop.d.ts +19 -0
- package/dist/types/dom/ticker.d.ts +36 -0
- package/dist/types/dom/warm.d.ts +17 -0
- package/dist/types/gpu/geometry.d.ts +17 -0
- package/dist/types/gpu/index.d.ts +36 -0
- package/dist/types/gpu/planes.d.ts +2 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/react/button.d.ts +11 -0
- package/dist/types/react/control-thumb.d.ts +11 -0
- package/dist/types/react/index.d.ts +20 -0
- package/dist/types/react/menu.d.ts +29 -0
- package/dist/types/react/merged-ref.d.ts +3 -0
- package/dist/types/react/progressive.d.ts +15 -0
- package/dist/types/react/scene.d.ts +35 -0
- package/dist/types/react/shape.d.ts +23 -0
- package/dist/types/react/surface.d.ts +35 -0
- package/dist/types/react/tabs.d.ts +29 -0
- package/dist/types/react/toolbar.d.ts +21 -0
- package/dist/types/react/value-control-motion.d.ts +9 -0
- package/dist/types/react/value-controls.d.ts +20 -0
- package/package.json +80 -4
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { GlassShape as e } from "./shape.js";
|
|
3
|
+
import { useGlassForeground as t } from "./scene.js";
|
|
4
|
+
import { useMergedRef as n } from "./merged-ref.js";
|
|
5
|
+
import { switchDragState as r } from "./value-control-motion.js";
|
|
6
|
+
import { ControlThumb as i } from "./control-thumb.js";
|
|
7
|
+
import { useEffect as a, useRef as o, useState as s } from "react";
|
|
8
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
import { Slider as u } from "@base-ui/react/slider";
|
|
10
|
+
import { Switch as d } from "@base-ui/react/switch";
|
|
11
|
+
//#region src/react/value-controls.tsx
|
|
12
|
+
function f({ material: r, appearance: o, tint: d, refraction: f, radius: p = "capsule", motion: m, interactive: h = !0, className: g = "", style: _, ticks: v = !1, min: y = 0, max: b = 100, step: x = .1, thumbProps: S, "aria-label": C, "aria-labelledby": w, ...T }) {
|
|
13
|
+
if (!Number.isFinite(y) || !Number.isFinite(b) || b <= y || !Number.isFinite(b - y) || !Number.isFinite(x) || x <= 0) throw RangeError("GlassSlider requires finite min < max and a positive finite step.");
|
|
14
|
+
let E = (b - y) / x;
|
|
15
|
+
if (v && (E < 1 || E > 100 || Math.abs(E - Math.round(E)) > 1e-7)) throw RangeError("Ticked sliders require 1–100 evenly divided intervals.");
|
|
16
|
+
let D = t(), O = n(T.ref, D), { className: k = "", ...A } = S ?? {}, [j, M] = s(!1);
|
|
17
|
+
return a(() => {
|
|
18
|
+
if (!j) return;
|
|
19
|
+
let e = () => M(!1);
|
|
20
|
+
return window.addEventListener("pointerup", e), window.addEventListener("pointercancel", e), window.addEventListener("blur", e), () => {
|
|
21
|
+
window.removeEventListener("pointerup", e), window.removeEventListener("pointercancel", e), window.removeEventListener("blur", e);
|
|
22
|
+
};
|
|
23
|
+
}, [j]), /* @__PURE__ */ c(u.Root, {
|
|
24
|
+
defaultValue: y,
|
|
25
|
+
...T,
|
|
26
|
+
ref: O,
|
|
27
|
+
min: y,
|
|
28
|
+
max: b,
|
|
29
|
+
step: x,
|
|
30
|
+
className: `lg-slider ${g}`,
|
|
31
|
+
style: {
|
|
32
|
+
"--lg-accent": d ?? "#8e8e93",
|
|
33
|
+
..._
|
|
34
|
+
},
|
|
35
|
+
"data-ticks": v ? "" : void 0,
|
|
36
|
+
children: /* @__PURE__ */ l(u.Control, {
|
|
37
|
+
className: "lg-slider-control",
|
|
38
|
+
onPointerDownCapture: (e) => {
|
|
39
|
+
!e.defaultPrevented && e.button === 0 && M(!0);
|
|
40
|
+
},
|
|
41
|
+
onPointerUp: () => M(!1),
|
|
42
|
+
onPointerCancel: () => M(!1),
|
|
43
|
+
onLostPointerCapture: () => M(!1),
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ c(e, {
|
|
46
|
+
radius: "capsule",
|
|
47
|
+
render: /* @__PURE__ */ c(u.Track, {}),
|
|
48
|
+
className: "lg-slider-track",
|
|
49
|
+
children: /* @__PURE__ */ c(e, {
|
|
50
|
+
radius: "capsule",
|
|
51
|
+
render: /* @__PURE__ */ c(u.Indicator, {}),
|
|
52
|
+
className: "lg-slider-fill"
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
v && /* @__PURE__ */ c("div", {
|
|
56
|
+
className: "lg-slider-ticks",
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
children: Array.from({ length: Math.round(E) + 1 }, (e, t) => /* @__PURE__ */ c("span", {}, t))
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ c(u.Thumb, {
|
|
61
|
+
"aria-label": C,
|
|
62
|
+
"aria-labelledby": w,
|
|
63
|
+
...A,
|
|
64
|
+
render: (e, t) => /* @__PURE__ */ c(i, {
|
|
65
|
+
...e,
|
|
66
|
+
motion: m,
|
|
67
|
+
interactive: h,
|
|
68
|
+
pressed: j || t.dragging,
|
|
69
|
+
options: {
|
|
70
|
+
material: r,
|
|
71
|
+
appearance: o,
|
|
72
|
+
radius: p,
|
|
73
|
+
refraction: f
|
|
74
|
+
},
|
|
75
|
+
className: `lg-slider-thumb ${typeof k == "function" ? k(t) : k}`
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function p({ material: a, appearance: u, tint: f, refraction: p, radius: m = "capsule", motion: h, interactive: g = !0, className: _ = "", style: v, ...y }) {
|
|
83
|
+
let b = t(), x = n(y.ref, b), [S, C] = s(!1), [w, T] = s(null), E = o(null), D = o(!1);
|
|
84
|
+
return /* @__PURE__ */ l(d.Root, {
|
|
85
|
+
...y,
|
|
86
|
+
ref: x,
|
|
87
|
+
nativeButton: !1,
|
|
88
|
+
className: `lg-switch ${_}`,
|
|
89
|
+
style: {
|
|
90
|
+
"--lg-accent": f ?? "#8e8e93",
|
|
91
|
+
...v
|
|
92
|
+
},
|
|
93
|
+
render: (e, t) => /* @__PURE__ */ c("span", {
|
|
94
|
+
...e,
|
|
95
|
+
role: "switch",
|
|
96
|
+
"aria-checked": t.checked,
|
|
97
|
+
tabIndex: e.tabIndex ?? 0,
|
|
98
|
+
style: {
|
|
99
|
+
...e.style,
|
|
100
|
+
"--lg-switch-position": w ?? +!!t.checked
|
|
101
|
+
},
|
|
102
|
+
"data-presentation-checked": w === null ? void 0 : w === 1 ? "true" : "false",
|
|
103
|
+
onPointerDown: (n) => {
|
|
104
|
+
if (e.onPointerDown?.(n), n.defaultPrevented || y.readOnly || n.button !== 0) return;
|
|
105
|
+
D.current = !1;
|
|
106
|
+
let r = getComputedStyle(n.currentTarget).direction === "rtl", i = +!!t.checked, a = n.currentTarget.getBoundingClientRect(), o = n.clientX >= a.left + a.width / 2 !== r;
|
|
107
|
+
E.current = {
|
|
108
|
+
id: n.pointerId,
|
|
109
|
+
x: n.clientX,
|
|
110
|
+
start: i,
|
|
111
|
+
current: i,
|
|
112
|
+
left: a.left,
|
|
113
|
+
width: a.width,
|
|
114
|
+
rtl: r,
|
|
115
|
+
oppositeHalf: o !== t.checked,
|
|
116
|
+
moved: !1
|
|
117
|
+
}, n.currentTarget.setPointerCapture(n.pointerId), T(i), C(!0);
|
|
118
|
+
},
|
|
119
|
+
onPointerMove: (t) => {
|
|
120
|
+
e.onPointerMove?.(t);
|
|
121
|
+
let n = E.current;
|
|
122
|
+
if (!n || n.id !== t.pointerId || t.defaultPrevented) return;
|
|
123
|
+
let i = t.clientX - n.x;
|
|
124
|
+
n.moved ||= Math.abs(i) > 3, n.current = Number(r(n, t.clientX)), n.moved && T(n.current);
|
|
125
|
+
},
|
|
126
|
+
onPointerUp: (n) => {
|
|
127
|
+
e.onPointerUp?.(n);
|
|
128
|
+
let r = E.current;
|
|
129
|
+
r && r.id === n.pointerId && (E.current = null, n.currentTarget.hasPointerCapture(n.pointerId) && n.currentTarget.releasePointerCapture(n.pointerId), r.moved && (!n.defaultPrevented && r.current >= .5 !== t.checked && n.currentTarget.click(), D.current = !0), T(null), C(!1));
|
|
130
|
+
},
|
|
131
|
+
onPointerCancel: (t) => {
|
|
132
|
+
e.onPointerCancel?.(t), E.current = null, D.current = !0, T(null), C(!1);
|
|
133
|
+
},
|
|
134
|
+
onLostPointerCapture: (t) => {
|
|
135
|
+
e.onLostPointerCapture?.(t), E.current && (E.current = null, D.current = !0, T(null), C(!1));
|
|
136
|
+
},
|
|
137
|
+
onClickCapture: (t) => {
|
|
138
|
+
if (D.current) {
|
|
139
|
+
D.current = !1, t.preventDefault(), t.stopPropagation();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
e.onClickCapture?.(t);
|
|
143
|
+
},
|
|
144
|
+
onKeyDown: (t) => {
|
|
145
|
+
e.onKeyDown?.(t), D.current = !1, !t.defaultPrevented && !y.readOnly && (t.key === " " || t.key === "Enter") && C(!0);
|
|
146
|
+
},
|
|
147
|
+
onKeyUp: (t) => {
|
|
148
|
+
e.onKeyUp?.(t), C(!1);
|
|
149
|
+
},
|
|
150
|
+
onBlur: (t) => {
|
|
151
|
+
e.onBlur?.(t), C(!1);
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
children: [/* @__PURE__ */ c(e, {
|
|
155
|
+
radius: "capsule",
|
|
156
|
+
render: /* @__PURE__ */ c("span", {}),
|
|
157
|
+
className: "lg-switch-track",
|
|
158
|
+
"aria-hidden": "true"
|
|
159
|
+
}), /* @__PURE__ */ c(d.Thumb, { render: (e) => /* @__PURE__ */ c(i, {
|
|
160
|
+
...e,
|
|
161
|
+
tag: "span",
|
|
162
|
+
pressed: S,
|
|
163
|
+
motion: h,
|
|
164
|
+
interactive: g,
|
|
165
|
+
options: {
|
|
166
|
+
material: a,
|
|
167
|
+
appearance: u,
|
|
168
|
+
radius: m,
|
|
169
|
+
refraction: p
|
|
170
|
+
},
|
|
171
|
+
className: "lg-switch-thumb"
|
|
172
|
+
}) })]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { f as GlassSlider, p as GlassSwitch };
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
:where(.lg-scene) {
|
|
2
|
+
position: relative;
|
|
3
|
+
isolation: isolate;
|
|
4
|
+
overflow: visible;
|
|
5
|
+
}
|
|
6
|
+
:where(.lg-content) {
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset: 0;
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
:where(.lg-content[data-layout="scroll"]) { overflow: auto; }
|
|
13
|
+
:where([data-glass-blur-host]) { display: contents; }
|
|
14
|
+
/* Gecko blurs this wrapper on the GPU, so glass copies the content unblurred. */
|
|
15
|
+
:where([data-glass-blur-host][data-glass-blur-active]) { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
|
|
16
|
+
:where([data-glass-blur-host][data-glass-blur-active][data-layout="flow"]) { position: relative; inset: auto; height: auto; }
|
|
17
|
+
:where(.lg-scroll-paint-root) { position: absolute; inset: 0; overflow: visible; }
|
|
18
|
+
:where(.lg-scroll-paint-root > foreignObject) { overflow: visible; }
|
|
19
|
+
/* Gecko draws each surface's glass in a layer beneath its children. */
|
|
20
|
+
.lg-glass-layer {
|
|
21
|
+
position: absolute;
|
|
22
|
+
z-index: -1;
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
background-repeat: no-repeat;
|
|
25
|
+
}
|
|
26
|
+
:where(.lg-surface) {
|
|
27
|
+
position: relative;
|
|
28
|
+
background: transparent;
|
|
29
|
+
border: 0;
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
--lg-material-foreground: var(--lg-foreground, #111113);
|
|
32
|
+
color: var(--lg-material-foreground);
|
|
33
|
+
}
|
|
34
|
+
:where(.lg-surface)[data-glass-appearance="dark"] {
|
|
35
|
+
--lg-material-foreground: var(--lg-foreground, #fff);
|
|
36
|
+
color: var(--lg-material-foreground);
|
|
37
|
+
}
|
|
38
|
+
:where(.lg-button) {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
gap: 4px;
|
|
43
|
+
min-height: 28px;
|
|
44
|
+
padding: 0 8px;
|
|
45
|
+
font: inherit;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
line-height: 1.625;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
-webkit-tap-highlight-color: transparent;
|
|
51
|
+
}
|
|
52
|
+
:where(.lg-button)[data-popup-open] {
|
|
53
|
+
background: var(--lg-control-highlight);
|
|
54
|
+
}
|
|
55
|
+
:where(.lg-button):focus-visible,
|
|
56
|
+
:where(.lg-tab):focus-visible {
|
|
57
|
+
outline: none;
|
|
58
|
+
background: var(--lg-control-highlight);
|
|
59
|
+
}
|
|
60
|
+
:where(.lg-button):disabled {
|
|
61
|
+
opacity: 0.45;
|
|
62
|
+
cursor: default;
|
|
63
|
+
}
|
|
64
|
+
:where(.lg-toolbar) {
|
|
65
|
+
--lg-toolbar-inset: 3px;
|
|
66
|
+
position: relative;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: 4px;
|
|
70
|
+
}
|
|
71
|
+
:where(.lg-toolbar-cluster) {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
gap: 4px;
|
|
75
|
+
padding: var(--lg-toolbar-inset, 3px);
|
|
76
|
+
flex: 1 0 auto;
|
|
77
|
+
}
|
|
78
|
+
:where(.lg-toolbar)[data-segmented] > :where(.lg-toolbar-cluster) { flex: 0 0 auto; }
|
|
79
|
+
:where(.lg-toolbar) :where(.lg-button) {
|
|
80
|
+
min-height: 22px;
|
|
81
|
+
padding: 0 8px;
|
|
82
|
+
}
|
|
83
|
+
:where(.lg-tabs-list) {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
padding: 3px;
|
|
87
|
+
gap: 0;
|
|
88
|
+
}
|
|
89
|
+
:where(.lg-tab) {
|
|
90
|
+
display: grid;
|
|
91
|
+
align-items: center;
|
|
92
|
+
position: relative;
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
border: 1px solid transparent;
|
|
95
|
+
background: transparent;
|
|
96
|
+
font: inherit;
|
|
97
|
+
height: 26px;
|
|
98
|
+
padding: 0 6px;
|
|
99
|
+
font-size: 12px;
|
|
100
|
+
line-height: 1.333333;
|
|
101
|
+
font-weight: 500;
|
|
102
|
+
|
|
103
|
+
color: inherit;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
opacity: 0.85;
|
|
106
|
+
transition: opacity 160ms;
|
|
107
|
+
}
|
|
108
|
+
:where(.lg-tab-label) {
|
|
109
|
+
grid-area: 1 / 1;
|
|
110
|
+
}
|
|
111
|
+
:where(.lg-tab)[data-active] {
|
|
112
|
+
opacity: 1;
|
|
113
|
+
font-weight: 500;
|
|
114
|
+
}
|
|
115
|
+
:where(.lg-menu-positioner) {
|
|
116
|
+
z-index: 20;
|
|
117
|
+
}
|
|
118
|
+
:where(.lg-menu-anchor) {
|
|
119
|
+
display: inline-flex;
|
|
120
|
+
vertical-align: middle;
|
|
121
|
+
}
|
|
122
|
+
:where(.lg-menu, .lg-toolbar, .lg-toolbar-cluster, .lg-button, .lg-tabs-list) {
|
|
123
|
+
/* Tint the existing material instead of covering it with an opaque fill.
|
|
124
|
+
currentColor follows the control foreground in either appearance. */
|
|
125
|
+
--lg-control-highlight: color-mix(in oklab, currentColor 8%, transparent);
|
|
126
|
+
}
|
|
127
|
+
:where(.lg-menu) {
|
|
128
|
+
--lg-menu-inset: 4px;
|
|
129
|
+
--lg-menu-highlight: var(--lg-control-highlight);
|
|
130
|
+
min-width: 128px;
|
|
131
|
+
padding: var(--lg-menu-inset);
|
|
132
|
+
outline: none;
|
|
133
|
+
overscroll-behavior: contain;
|
|
134
|
+
}
|
|
135
|
+
:where(.lg-menu)
|
|
136
|
+
:is([role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]) {
|
|
137
|
+
box-sizing: border-box;
|
|
138
|
+
min-height: 28px;
|
|
139
|
+
padding: 4px 8px;
|
|
140
|
+
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 8px;
|
|
144
|
+
font-size: 12px;
|
|
145
|
+
line-height: 1.625;
|
|
146
|
+
cursor: default;
|
|
147
|
+
outline: none;
|
|
148
|
+
}
|
|
149
|
+
:where(.lg-menu)
|
|
150
|
+
:is(
|
|
151
|
+
[role="menuitem"],
|
|
152
|
+
[role="menuitemcheckbox"],
|
|
153
|
+
[role="menuitemradio"]
|
|
154
|
+
)[data-highlighted],
|
|
155
|
+
:where(.lg-menu)
|
|
156
|
+
:is(
|
|
157
|
+
[role="menuitem"],
|
|
158
|
+
[role="menuitemcheckbox"],
|
|
159
|
+
[role="menuitemradio"]
|
|
160
|
+
):focus-visible,
|
|
161
|
+
:where(.lg-menu)
|
|
162
|
+
:is(
|
|
163
|
+
[role="menuitem"],
|
|
164
|
+
[role="menuitemcheckbox"],
|
|
165
|
+
[role="menuitemradio"]
|
|
166
|
+
):active {
|
|
167
|
+
background: var(--lg-menu-highlight);
|
|
168
|
+
}
|
|
169
|
+
@media (prefers-reduced-motion: reduce) {
|
|
170
|
+
:where(.lg-tab) {
|
|
171
|
+
transition: none;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Interactive glass illuminates from within, starting beneath the pointer.
|
|
176
|
+
The scene writes --lg-glow (0–1) and its position on the surface. */
|
|
177
|
+
:where(.lg-surface[data-glass-interactive]) {
|
|
178
|
+
--lg-glow-color: rgb(255 255 255 / 0.3);
|
|
179
|
+
background-image: radial-gradient(
|
|
180
|
+
var(--lg-glow-size, 64px) circle at var(--lg-glow-x, 50%) var(--lg-glow-y, 50%),
|
|
181
|
+
color-mix(in srgb, var(--lg-glow-color) calc(var(--lg-glow, 0) * 100%), transparent),
|
|
182
|
+
transparent
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
:where(.lg-surface[data-glass-interactive][data-glass-appearance="dark"]) {
|
|
186
|
+
--lg-glow-color: rgb(255 255 255 / 0.16);
|
|
187
|
+
}
|
|
188
|
+
:where(.lg-surface[data-glass-interactive]) { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
|
|
189
|
+
|
|
190
|
+
/* While glass grows out of, or back into, another shape, its content waits
|
|
191
|
+
for room: it condenses out of a blur as the outline opens, and dissolves
|
|
192
|
+
back into one as it closes. */
|
|
193
|
+
:where(.lg-surface[data-glass-morph]) > * {
|
|
194
|
+
opacity: calc(var(--lg-morph, 1) * var(--lg-glass-ready, 1));
|
|
195
|
+
filter: blur(calc((1 - var(--lg-morph, 1)) * 6px));
|
|
196
|
+
/* Keep animated text blur on its own layer: WebKit can otherwise flash
|
|
197
|
+
unpainted pixels while the containing outline changes. This hint does
|
|
198
|
+
not replace an author's transform and expires with the morph. */
|
|
199
|
+
will-change: transform;
|
|
200
|
+
backface-visibility: hidden;
|
|
201
|
+
}
|
|
202
|
+
/* Glass that has become another surface: its material is drawn by that
|
|
203
|
+
surface, and its own content withdraws as the glass leaves it. */
|
|
204
|
+
:where([data-glass-morph-source]) {
|
|
205
|
+
opacity: calc(1 - var(--lg-morph-source, 1));
|
|
206
|
+
filter: blur(calc(var(--lg-morph-source, 1) * 3px));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
:where(.lg-tab-indicator) {
|
|
210
|
+
position: absolute;
|
|
211
|
+
left: var(--active-tab-left);
|
|
212
|
+
top: var(--active-tab-top);
|
|
213
|
+
width: var(--active-tab-width);
|
|
214
|
+
height: var(--active-tab-height);
|
|
215
|
+
pointer-events: none;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
:where(.lg-button)[data-size="xs"],
|
|
219
|
+
:where(.lg-button)[data-size="icon-xs"] { min-height: 20px; }
|
|
220
|
+
:where(.lg-button)[data-size="sm"],
|
|
221
|
+
:where(.lg-button)[data-size="icon-sm"] { min-height: 24px; }
|
|
222
|
+
:where(.lg-button)[data-size="lg"],
|
|
223
|
+
:where(.lg-button)[data-size="icon-lg"] { min-height: 32px; padding-inline: 10px; }
|
|
224
|
+
:where(.lg-button)[data-size="xs"] { font-size: 10px; }
|
|
225
|
+
:where(.lg-button)[data-size^="icon"] { width: 28px; height: 28px; padding: 0; }
|
|
226
|
+
:where(.lg-button)[data-size="icon-xs"] { width: 20px; height: 20px; }
|
|
227
|
+
:where(.lg-button)[data-size="icon-sm"] { width: 24px; height: 24px; }
|
|
228
|
+
:where(.lg-button)[data-size="icon-lg"] { width: 32px; height: 32px; }
|
|
229
|
+
:where(.lg-button) > svg, :where(.lg-toolbar-button) > svg { width: 14px; height: 14px; }
|
|
230
|
+
:where(.lg-button)[data-size="xs"] > svg,
|
|
231
|
+
:where(.lg-button)[data-size="icon-xs"] > svg { width: 10px; height: 10px; }
|
|
232
|
+
:where(.lg-button)[data-size="sm"] > svg,
|
|
233
|
+
:where(.lg-button)[data-size="icon-sm"] > svg { width: 12px; height: 12px; }
|
|
234
|
+
:where(.lg-button)[data-size="lg"] > svg,
|
|
235
|
+
:where(.lg-button)[data-size="icon-lg"] > svg { width: 16px; height: 16px; }
|
|
236
|
+
|
|
237
|
+
:where(.lg-toolbar-button) {
|
|
238
|
+
display: inline-flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
justify-content: center;
|
|
241
|
+
width: 22px;
|
|
242
|
+
height: 22px;
|
|
243
|
+
padding: 0;
|
|
244
|
+
border: 0;
|
|
245
|
+
|
|
246
|
+
background: transparent;
|
|
247
|
+
color: inherit;
|
|
248
|
+
font: inherit;
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
}
|
|
251
|
+
:where(.lg-toolbar-button)[data-size="default"] {
|
|
252
|
+
width: auto;
|
|
253
|
+
padding-inline: 8px;
|
|
254
|
+
gap: 4px;
|
|
255
|
+
font-size: 12px;
|
|
256
|
+
font-weight: 500;
|
|
257
|
+
}
|
|
258
|
+
:where(.lg-toolbar, .lg-toolbar-cluster)[data-orientation="vertical"] { flex-direction: column; }
|
|
259
|
+
:where(.lg-toolbar-spacer) {
|
|
260
|
+
flex: 1 0 var(--lg-toolbar-space, 8px);
|
|
261
|
+
align-self: stretch;
|
|
262
|
+
pointer-events: none;
|
|
263
|
+
}
|
|
264
|
+
:where(.lg-toolbar-spacer)[data-sizing="fixed"] { flex-grow: 0; }
|
|
265
|
+
:where(.lg-toolbar-button):is(:hover, :focus-visible, :active, [aria-pressed="true"], [data-popup-open]):not([data-disabled]):not(:disabled) {
|
|
266
|
+
background: var(--lg-control-highlight);
|
|
267
|
+
}
|
|
268
|
+
:where(.lg-toolbar-button):focus-visible {
|
|
269
|
+
outline: none;
|
|
270
|
+
}
|
|
271
|
+
:where(.lg-toolbar-button)[data-disabled] {
|
|
272
|
+
opacity: 0.45;
|
|
273
|
+
cursor: default;
|
|
274
|
+
}
|
|
275
|
+
:where(.lg-tabs-list)[data-size="sm"] :where(.lg-tab) { height: 22px; }
|
|
276
|
+
:where(.lg-tabs-list)[data-size="lg"] :where(.lg-tab) {
|
|
277
|
+
height: 30px;
|
|
278
|
+
padding-inline: 12px;
|
|
279
|
+
font-size: 13px;
|
|
280
|
+
}
|
|
281
|
+
:where(.lg-tabs-list)[data-orientation="vertical"] {
|
|
282
|
+
flex-direction: column;
|
|
283
|
+
}
|
|
284
|
+
:where(.lg-tabs-list)[data-orientation="vertical"] :where(.lg-tab-indicator) {
|
|
285
|
+
left: var(--active-tab-left);
|
|
286
|
+
top: var(--active-tab-top);
|
|
287
|
+
|
|
288
|
+
}
|
|
289
|
+
:where(.lg-tab)[data-disabled],
|
|
290
|
+
:where(.lg-menu) [data-disabled] {
|
|
291
|
+
opacity: 0.45;
|
|
292
|
+
cursor: default;
|
|
293
|
+
}
|
|
294
|
+
:where(.lg-menu) [role="separator"] {
|
|
295
|
+
height: 1px;
|
|
296
|
+
margin: 4px 8px;
|
|
297
|
+
background: currentColor;
|
|
298
|
+
opacity: 0.15;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
:where(.lg-menu) :is([role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]) > svg { width: 14px; height: 14px; }
|
|
302
|
+
|
|
303
|
+
/* Open popups and their optical layer share a stacking context above nearby content. */
|
|
304
|
+
/* Set by the scene while a popup surface is registered in it. A `:has()` rule
|
|
305
|
+
here would re-style the whole scene on every inline style change inside it. */
|
|
306
|
+
:where(.lg-scene[data-glass-popup]) { z-index: 20; }
|
|
307
|
+
|
|
308
|
+
:where(.lg-content[data-layout="flow"]) { position: relative; inset: auto; height: auto; }
|
|
309
|
+
:where(.lg-progressive-blur) { position: absolute; pointer-events: none; }
|
|
310
|
+
:where(.lg-progressive-blur[data-edge="top"]) { inset: 0 0 auto; height: var(--lg-blur-size); }
|
|
311
|
+
:where(.lg-progressive-blur[data-edge="bottom"]) { inset: auto 0 0; height: var(--lg-blur-size); }
|
|
312
|
+
:where(.lg-progressive-blur[data-edge="inline-start"]) { inset-block: 0; inset-inline-start: 0; width: var(--lg-blur-size); }
|
|
313
|
+
:where(.lg-progressive-blur[data-edge="inline-end"]) { inset-block: 0; inset-inline-end: 0; width: var(--lg-blur-size); }
|
|
314
|
+
|
|
315
|
+
:where(.lg-slider) { position: relative; width: 280px; max-width: 100%; touch-action: none; }
|
|
316
|
+
:where(.lg-slider-control) { position: relative; display: flex; align-items: center; height: 28px; user-select: none; }
|
|
317
|
+
:where(.lg-slider-track) { position: relative; width: 100%; height: 6px; background: rgb(128 128 128 / 0.3); }
|
|
318
|
+
:where(.lg-slider-fill) { height: 100%; background: var(--lg-accent); }
|
|
319
|
+
:where(.lg-slider-thumb) { width: 20px; height: 16px; translate: -50% -50%; cursor: grab; z-index: 1; outline: none; }
|
|
320
|
+
:where(.lg-slider-thumb):dir(rtl) { translate: 50% -50%; }
|
|
321
|
+
:where(.lg-slider)[data-orientation="vertical"] :where(.lg-slider-thumb) { translate: -50% 50%; }
|
|
322
|
+
:where(.lg-slider-thumb)[data-press-phase="pressed"] { cursor: grabbing; }
|
|
323
|
+
:where(.lg-control-thumb) { --lg-control-progress: 0; --lg-control-grow-x: 2.5px; --lg-control-grow-y: 2px; }
|
|
324
|
+
:where(.lg-switch-thumb) { --lg-control-grow-x: 9px; --lg-control-grow-y: 5.5px; }
|
|
325
|
+
:where(.lg-control-lens, .lg-control-face) { position: absolute; inset: calc(-1 * var(--lg-control-grow-y) * var(--lg-control-progress)) calc(-1 * var(--lg-control-grow-x) * var(--lg-control-progress)); pointer-events: none; }
|
|
326
|
+
:where(.lg-control-face) { background: #fff; opacity: calc(1 - var(--lg-control-progress)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 3px 12px rgb(0 0 0 / 0.1); }
|
|
327
|
+
:where(.lg-control-lens) { opacity: var(--lg-control-progress); }
|
|
328
|
+
|
|
329
|
+
:where(.lg-slider-thumb):focus-within { outline: none; }
|
|
330
|
+
:where(.lg-slider-ticks) { display: flex; justify-content: space-between; position: absolute; inset-inline: 0; top: 23px; pointer-events: none; }
|
|
331
|
+
:where(.lg-slider-ticks) > span { width: 2px; height: 2px; border-radius: 50%; background: rgb(128 128 128 / 0.65); }
|
|
332
|
+
:where(.lg-slider)[data-orientation="vertical"] { width: 28px; height: 200px; }
|
|
333
|
+
:where(.lg-slider)[data-orientation="vertical"] :where(.lg-slider-control) { width: 28px; height: 100%; justify-content: center; }
|
|
334
|
+
:where(.lg-slider)[data-orientation="vertical"] :where(.lg-slider-track) { width: 6px; height: 100%; }
|
|
335
|
+
:where(.lg-slider)[data-orientation="vertical"] :where(.lg-slider-fill) { width: 100%; }
|
|
336
|
+
:where(.lg-slider)[data-orientation="vertical"] :where(.lg-slider-ticks) { inset: 0 auto 0 23px; flex-direction: column-reverse; }
|
|
337
|
+
:where(.lg-switch) { --lg-switch-travel: 18px; position: relative; display: inline-flex; align-items: center; flex-shrink: 0; box-sizing: border-box; width: 54px; height: 24px; padding: 2px; border: 0; cursor: pointer; touch-action: none; user-select: none; outline: none; transition: background-color 200ms ease-in-out; }
|
|
338
|
+
:where(.lg-switch-track) { position: absolute; inset: 0; pointer-events: none; background: rgb(128 128 128 / 0.4); transition: background-color 200ms ease-in-out; }
|
|
339
|
+
:where(.lg-switch)[data-checked] > .lg-switch-track, :where(.lg-switch)[data-presentation-checked="true"] > .lg-switch-track { background: var(--lg-accent); }
|
|
340
|
+
:where(.lg-switch)[data-presentation-checked="false"] > .lg-switch-track { background: rgb(128 128 128 / 0.4); }
|
|
341
|
+
:where(.lg-switch):dir(rtl) { --lg-switch-travel: -18px; }
|
|
342
|
+
:where(.lg-switch-thumb) { position: relative; display: block; width: 32px; height: 20px; flex-shrink: 0; left: calc(var(--lg-switch-position, 0) * var(--lg-switch-travel)); }
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
:where(.lg-switch):focus-visible { outline: none; }
|
|
346
|
+
:where(.lg-switch)[data-readonly] { cursor: default; }
|
|
347
|
+
@media (prefers-reduced-motion: reduce) {
|
|
348
|
+
:where(.lg-slider-thumb, .lg-switch, .lg-switch-track, .lg-switch-thumb, .lg-control-face),
|
|
349
|
+
:where(.lg-switch)[data-dragging] :where(.lg-switch-thumb) { transition: none; }
|
|
350
|
+
}
|
|
351
|
+
@media (forced-colors: active) {
|
|
352
|
+
:where(.lg-slider-track, .lg-switch-track) { background: Canvas; border: 1px solid ButtonText; }
|
|
353
|
+
:where(.lg-slider-fill), :where(.lg-switch)[data-checked] > .lg-switch-track { background: Highlight; }
|
|
354
|
+
:where(.lg-slider-thumb, .lg-switch-thumb) { background: ButtonText; }
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
:where(.lg-switch:has([data-glass-motion="none"]), .lg-switch:has([data-glass-motion="none"]) > .lg-switch-track) { transition: none; }
|
|
358
|
+
|
|
359
|
+
/* No rounded-rectangle first paint while Lisse measures the shape. */
|
|
360
|
+
[data-lg-shape]:not([style*="clip-path"]), .lg-surface:not([style*="clip-path"]) { visibility: hidden; }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GlassRadius } from "./shape.js";
|
|
2
|
+
export type ShapePoint = [number, number];
|
|
3
|
+
export interface ShapeBounds {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ShapeGeometry {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
radius: GlassRadius;
|
|
13
|
+
outline?: ShapePoint[];
|
|
14
|
+
}
|
|
15
|
+
/** Inward parallel offset of the convex Lisse outline, in CSS pixels. */
|
|
16
|
+
export declare function insetShape(shape: ShapeGeometry, inset: number): ShapePoint[];
|
|
17
|
+
/** Child-local outline: keep its own corners away from the container edge,
|
|
18
|
+
* and inherit the container's parallel curve wherever the two meet. */
|
|
19
|
+
export declare function concentricOutline(parent: ShapePoint[], bounds: ShapeBounds, radius?: GlassRadius): ShapePoint[];
|
|
20
|
+
export declare function polygonClip(points: ShapePoint[]): string;
|
|
21
|
+
/** Equal-edge inset that fits an entire fixed-size control inside a corner. */
|
|
22
|
+
export declare function cornerPlacement(shape: ShapeGeometry, width: number, height: number, gap: number, radius?: GlassRadius): number;
|
|
23
|
+
/** Horizontal clearance for a centered content band inside a clipped row. */
|
|
24
|
+
export declare function contentInsets(points: ShapePoint[], width: number, height: number, bandHeight: number): {
|
|
25
|
+
left: number;
|
|
26
|
+
right: number;
|
|
27
|
+
};
|
|
28
|
+
/** Uniform storage for an asymmetric convex contour used by the GPU field. */
|
|
29
|
+
export declare function outlineSegments(points: ShapePoint[]): {
|
|
30
|
+
segments: number[][];
|
|
31
|
+
count: number;
|
|
32
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { edgeDisplacement } from "./optics.js";
|
|
2
|
+
export { materials } from "./materials.js";
|
|
3
|
+
export type { MaterialOptions, GlassMaterial, GlassAppearance, } from "./materials.js";
|
|
4
|
+
export type { GlassRadius } from "./shape.js";
|
|
5
|
+
export { insetShape, concentricOutline, cornerPlacement, contentInsets, polygonClip } from "./concentric.js";
|
|
6
|
+
export type { ShapeGeometry, ShapeBounds, ShapePoint } from "./concentric.js";
|
|
7
|
+
export { Spring, springs, settleTime, rubberBand } from "./spring.js";
|
|
8
|
+
export type { SpringOptions } from "./spring.js";
|
|
9
|
+
export { smoothUnion, smoothMin, roundRectDistance } from "./union.js";
|
|
10
|
+
export type { RoundRect } from "./union.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { GlassRadius } from "./shape.js";
|
|
2
|
+
export type GlassMaterial = "clear" | "regular";
|
|
3
|
+
export type GlassAppearance = "light" | "dark";
|
|
4
|
+
export interface MaterialOptions {
|
|
5
|
+
material?: GlassMaterial;
|
|
6
|
+
appearance?: GlassAppearance;
|
|
7
|
+
radius?: GlassRadius;
|
|
8
|
+
/** Follow the nearest shape container; radius controls independent corners. */
|
|
9
|
+
concentric?: boolean | {
|
|
10
|
+
inset?: number;
|
|
11
|
+
};
|
|
12
|
+
refraction?: number;
|
|
13
|
+
/** Optional six-digit hex color, e.g. "#007aff". Omit for untinted glass. */
|
|
14
|
+
tint?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const materials: {
|
|
17
|
+
readonly clear: {
|
|
18
|
+
readonly blur: 0;
|
|
19
|
+
readonly refraction: 60;
|
|
20
|
+
readonly light: {
|
|
21
|
+
readonly shadowLift: 0.18;
|
|
22
|
+
readonly highlightRolloff: 0;
|
|
23
|
+
};
|
|
24
|
+
readonly dark: {
|
|
25
|
+
readonly shadowLift: 0.15;
|
|
26
|
+
readonly highlightRolloff: 0.2;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly regular: {
|
|
30
|
+
readonly blur: 7.33;
|
|
31
|
+
readonly refraction: 60;
|
|
32
|
+
readonly light: {
|
|
33
|
+
readonly fillSigma: 23;
|
|
34
|
+
readonly fillOpacity: 0.34;
|
|
35
|
+
readonly tone: readonly [0.36, 0.67, -0.1113, 1.1031];
|
|
36
|
+
};
|
|
37
|
+
readonly dark: {
|
|
38
|
+
readonly fillSigma: 21.8;
|
|
39
|
+
readonly fillOpacity: 0.65;
|
|
40
|
+
readonly tone: readonly [0.105, 0.83, -0.2091, 1.0648];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|