@edinstvo/glass 0.1.0-alpha.1 → 0.1.0-beta.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/README.md CHANGED
@@ -51,7 +51,7 @@ npm i @edinstvo/glass
51
51
  import "@edinstvo/glass/define";
52
52
  </script>
53
53
 
54
- <edinstvo-glass material="regular" interaction="calm">
54
+ <edinstvo-glass frost="0.4" refraction="0.5">
55
55
  Hello
56
56
  </edinstvo-glass>
57
57
  ```
@@ -63,14 +63,14 @@ Not a fan of custom elements? Attach glass to any node:
63
63
  ```js
64
64
  import { attachGlass } from "@edinstvo/glass";
65
65
 
66
- const glass = attachGlass(element, { material: "frost" });
66
+ const glass = attachGlass(element, { material: { frost: 0.7 } });
67
67
  glass.set({ material: { frost: 0.4 } });
68
68
  glass.destroy();
69
69
  ```
70
70
 
71
71
  ## Material
72
72
 
73
- Set a preset with `material`, then override anything with an attribute, a `--glass-*` CSS variable or a property.
73
+ There are no types of glass, only settings. Set anything with an attribute, a `--glass-*` CSS variable or the `material` property. The defaults are tuned against the system glass on macOS, pixel by pixel.
74
74
 
75
75
  | Attribute | Range | What it does |
76
76
  |---|---|---|
@@ -88,16 +88,46 @@ Set a preset with `material`, then override anything with an attribute, a `--gla
88
88
  | `light-angle` | -180 to 180° | Where the light comes from. 0 is the top |
89
89
  | `bloom` | 0 to 1 | Glow inside the glass and around it |
90
90
 
91
- ### Presets
91
+ ## Motion
92
92
 
93
- `pure` · `clear` · `regular` · `frost` · `lens` · `prism`
93
+ Change an element's size or position in CSS and the glass flows there with a spring, overshoot included.
94
+ Each of these is its own setting, on a group or on a single child. `prefers-reduced-motion` turns them all off.
94
95
 
95
- `regular` and `clear` are tuned against the system glass on macOS, pixel by pixel. `pure` is the same lens with no frost at all.
96
+ | Attribute | Range | What it does |
97
+ |---|---|---|
98
+ | `morph` | 0 to 1 | Softness of the flow. 0 jumps straight to the new shape |
99
+ | `jelly` | 0 to 1 | Stretch while moving and under a drag |
100
+ | `press` | 0 to 1 | How much the glass swells when held |
101
+ | `glow` | 0 to 1 | Light that spreads from under the finger |
102
+ | `follow` | 0 to 1 | How far the light chases the pointer |
103
+ | `merge` | 0 to 64 px | Melts this element into others that have it too. 0 stays separate |
104
+
105
+ ### Merge
106
+
107
+ Merging is opt-in, per element. Give `merge` to the pieces that should become one shape: they melt together when they get close and pull apart like liquid. Everything else in the group stays separate.
108
+
109
+ ```html
110
+ <edinstvo-glass-group>
111
+ <edinstvo-glass merge="28"></edinstvo-glass>
112
+ <edinstvo-glass merge="28"></edinstvo-glass>
113
+ <edinstvo-glass></edinstvo-glass>
114
+ </edinstvo-glass-group>
115
+ ```
96
116
 
97
- ### Interaction
117
+ Up to 64 merged shapes per group, all drawn in one pass. Pieces without `merge` are bodies of their own and slide over the rest. `merge` on the group sets it for every child, `merge="0"` on a child opts out.
98
118
 
99
- `none` · `calm` · `lively`, or your own `{ follow, press, stretch }`.
100
- Light follows the pointer, the surface swells under a press. `prefers-reduced-motion` turns all of it off.
119
+ ### Appear
120
+
121
+ Add `appear` to materialise on load, or call `show()` and `hide()`. Both return a promise.
122
+
123
+ ## Layers
124
+
125
+ Glass sees the glass under it. `layer` picks who is on top, higher wins. It is `z-index` with a shorter name, so plain `z-index` works too. On a tie the later element in the document is on top.
126
+
127
+ ```html
128
+ <edinstvo-glass layer="1"></edinstvo-glass>
129
+ <edinstvo-glass layer="2"></edinstvo-glass>
130
+ ```
101
131
 
102
132
  ## Backdrop
103
133
 
package/dist/element.d.ts CHANGED
@@ -1,26 +1,40 @@
1
1
  import type { GlassSource } from "./backdrop.js";
2
- import type { Interaction, InteractionName } from "./interaction.js";
3
- import { type Material, type PresetName } from "./material.js";
2
+ import { type Material } from "./material.js";
3
+ import { GlassSurface } from "./surface.js";
4
4
  declare const Base: typeof HTMLElement;
5
5
  export declare class EdinstvoGlass extends Base {
6
6
  static observedAttributes: string[];
7
- private surface;
7
+ protected surface: GlassSurface;
8
+ private group;
9
+ private parentGroup;
10
+ private standing;
11
+ private ready;
8
12
  private sourceValue;
9
13
  private materialValue;
10
- private interactionValue;
11
14
  constructor();
15
+ protected get isGroup(): boolean;
12
16
  connectedCallback(): void;
13
17
  disconnectedCallback(): void;
18
+ private leave;
19
+ place(): void;
20
+ show(): Promise<void>;
21
+ hide(): Promise<void>;
14
22
  attributeChangedCallback(): void;
15
23
  get source(): GlassSource;
16
24
  set source(value: GlassSource);
17
- get material(): PresetName | Partial<Material>;
18
- set material(value: PresetName | Partial<Material>);
19
- get interaction(): InteractionName | Interaction;
20
- set interaction(value: InteractionName | Interaction);
25
+ get material(): Partial<Material>;
26
+ set material(value: Partial<Material>);
21
27
  invalidate(): void;
22
- private sync;
23
- private composeMaterial;
28
+ protected sync(): void;
29
+ composeMaterial(): Partial<Material>;
30
+ }
31
+ export declare class EdinstvoGlassGroup extends EdinstvoGlass {
32
+ protected get isGroup(): boolean;
33
+ connectedCallback(): void;
34
+ place(): void;
35
+ adopt(child: EdinstvoGlass): void;
36
+ release(child: EdinstvoGlass): void;
37
+ refresh(): void;
24
38
  }
25
39
  export declare function defineGlass(tag?: string): void;
26
40
  export {};
package/dist/element.js CHANGED
@@ -1,5 +1,6 @@
1
- import { kebab, numericKeys, presets } from "./material.js";
2
- import { GlassSurface, placeCanvas } from "./surface.js";
1
+ import { motionKeys } from "./interaction.js";
2
+ import { kebab, numericKeys } from "./material.js";
3
+ import { GlassSurface, placeCanvas, readMotion } from "./surface.js";
3
4
  const Base = (globalThis.HTMLElement ?? class {
4
5
  });
5
6
  const css = `
@@ -15,20 +16,42 @@ const css = `
15
16
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
16
17
  backdrop-filter: blur(16px) saturate(1.6);
17
18
  }
19
+ :host([data-grouped]) {
20
+ box-shadow: none;
21
+ background: none;
22
+ -webkit-backdrop-filter: none;
23
+ backdrop-filter: none;
24
+ }
25
+ :host([data-grouped]) > canvas {
26
+ display: none;
27
+ }
28
+ :host([data-glass-group]) {
29
+ display: block;
30
+ box-shadow: none;
31
+ border-radius: 0;
32
+ background: none;
33
+ -webkit-backdrop-filter: none;
34
+ backdrop-filter: none;
35
+ }
18
36
  .content {
19
37
  display: block;
20
38
  position: relative;
21
39
  z-index: 1;
22
40
  border-radius: inherit;
41
+ scale: var(--glass-scale, 1);
42
+ opacity: var(--glass-appear, 1);
23
43
  }
24
44
  `;
25
45
  const materialAttributes = new Map(numericKeys.map((key) => [kebab(key), key]));
26
46
  export class EdinstvoGlass extends Base {
27
- static observedAttributes = ["material", "interaction", "source", "live", "tint", ...materialAttributes.keys()];
47
+ static observedAttributes = ["source", "live", "tint", "appear", "layer", ...motionKeys, ...materialAttributes.keys()];
28
48
  surface;
49
+ group = null;
50
+ parentGroup = null;
51
+ standing = false;
52
+ ready = false;
29
53
  sourceValue;
30
54
  materialValue;
31
- interactionValue;
32
55
  constructor() {
33
56
  super();
34
57
  const root = this.attachShadow({ mode: "open" });
@@ -42,18 +65,60 @@ export class EdinstvoGlass extends Base {
42
65
  content.setAttribute("part", "content");
43
66
  content.append(document.createElement("slot"));
44
67
  root.append(style, canvas, content);
45
- this.surface = new GlassSurface(this, canvas);
68
+ this.surface = new GlassSurface(this, canvas, {}, this.isGroup);
69
+ }
70
+ get isGroup() {
71
+ return false;
46
72
  }
47
73
  connectedCallback() {
48
- this.sync();
49
- this.surface.connect();
74
+ this.parentGroup = this.parentElement?.closest("[data-glass-group]") ?? null;
75
+ this.ready = true;
76
+ this.place();
50
77
  }
51
78
  disconnectedCallback() {
52
- this.surface.disconnect();
79
+ this.ready = false;
80
+ if (this.group)
81
+ this.leave();
82
+ if (this.standing)
83
+ this.surface.disconnect();
84
+ this.standing = false;
85
+ }
86
+ leave() {
87
+ this.group?.release(this);
88
+ this.group = null;
89
+ delete this.dataset.grouped;
90
+ }
91
+ place() {
92
+ const parent = this.parentGroup;
93
+ const reach = parent ? parseFloat(this.getAttribute("merge") ?? parent.getAttribute("merge") ?? "0") : 0;
94
+ if (parent && reach > 0) {
95
+ if (this.standing)
96
+ this.surface.disconnect();
97
+ this.standing = false;
98
+ if (!this.group) {
99
+ this.dataset.grouped = "";
100
+ parent.adopt(this);
101
+ this.group = parent;
102
+ }
103
+ parent.refresh();
104
+ return;
105
+ }
106
+ if (this.group)
107
+ this.leave();
108
+ this.sync();
109
+ if (!this.standing)
110
+ this.surface.connect();
111
+ this.standing = true;
112
+ }
113
+ show() {
114
+ return this.surface.show();
115
+ }
116
+ hide() {
117
+ return this.surface.hide();
53
118
  }
54
119
  attributeChangedCallback() {
55
- if (this.isConnected)
56
- this.sync();
120
+ if (this.ready)
121
+ this.place();
57
122
  }
58
123
  get source() {
59
124
  return this.sourceValue ?? this.getAttribute("source") ?? "auto";
@@ -63,29 +128,26 @@ export class EdinstvoGlass extends Base {
63
128
  this.sync();
64
129
  }
65
130
  get material() {
66
- return this.materialValue ?? (this.getAttribute("material") ?? "regular");
131
+ return this.materialValue ?? {};
67
132
  }
68
133
  set material(value) {
69
134
  this.materialValue = value;
70
135
  this.sync();
71
136
  }
72
- get interaction() {
73
- return this.interactionValue ?? (this.getAttribute("interaction") ?? "none");
74
- }
75
- set interaction(value) {
76
- this.interactionValue = value;
77
- this.sync();
78
- }
79
137
  invalidate() {
80
138
  this.surface.invalidate();
81
139
  }
82
140
  sync() {
83
141
  const live = this.getAttribute("live");
142
+ const layer = this.getAttribute("layer");
143
+ if (layer !== null)
144
+ this.style.zIndex = layer;
84
145
  this.surface.set({
85
146
  material: this.composeMaterial(),
86
- interaction: this.interaction,
147
+ motion: this.parentGroup ? readMotion(this.parentGroup) : undefined,
87
148
  source: this.source,
88
149
  live: live === null ? undefined : live !== "false",
150
+ appear: this.hasAttribute("appear"),
89
151
  });
90
152
  }
91
153
  composeMaterial() {
@@ -98,14 +160,38 @@ export class EdinstvoGlass extends Base {
98
160
  const tint = this.getAttribute("tint");
99
161
  if (tint)
100
162
  overrides.tint = tint;
101
- if (!Object.keys(overrides).length)
102
- return this.material;
103
- const base = this.material;
104
- return typeof base === "string" ? { ...presetOf(base), ...overrides } : { ...base, ...overrides };
163
+ return { ...this.parentGroup?.composeMaterial(), ...this.material, ...overrides };
164
+ }
165
+ }
166
+ export class EdinstvoGlassGroup extends EdinstvoGlass {
167
+ get isGroup() {
168
+ return true;
169
+ }
170
+ connectedCallback() {
171
+ this.dataset.glassGroup = "";
172
+ super.connectedCallback();
173
+ }
174
+ place() {
175
+ super.place();
176
+ for (const child of this.querySelectorAll("[data-engine]")) {
177
+ if (child instanceof EdinstvoGlass)
178
+ child.place();
179
+ }
180
+ }
181
+ adopt(child) {
182
+ this.surface.track(child);
183
+ }
184
+ release(child) {
185
+ this.surface.untrack(child);
186
+ }
187
+ refresh() {
188
+ this.surface.restyle();
105
189
  }
106
190
  }
107
- const presetOf = (name) => presets[name] ?? presets.regular;
108
191
  export function defineGlass(tag = "edinstvo-glass") {
192
+ if (!customElements.get(`${tag}-group`))
193
+ customElements.define(`${tag}-group`, class extends EdinstvoGlassGroup {
194
+ });
109
195
  if (!customElements.get(tag))
110
196
  customElements.define(tag, class extends EdinstvoGlass {
111
197
  });
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI;CAAQ,CAAuB,CAAC;AAExE,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;CAmBX,CAAC;AAEF,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;AAEhF,MAAM,OAAO,aAAc,SAAQ,IAAI;IACrC,M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ACpH,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,KAAM,SAAQ,aAAa;SAAG,CAAC,CAAC;AAC3F,CAAC"}
@@ -15,3 +15,4 @@ export declare function uvTransform(rect: {
15
15
  };
16
16
  export declare function cornerRadius(value: string, w: number, h: number): number;
17
17
  export declare function lightVector(angle: number): [number, number];
18
+ export declare function softPeak(halfW: number, halfH: number, radius: number): number;
package/dist/geometry.js CHANGED
@@ -24,4 +24,10 @@ export function lightVector(angle) {
24
24
  const radians = (angle * Math.PI) / 180;
25
25
  return [Math.sin(radians), -Math.cos(radians)];
26
26
  }
27
+ export function softPeak(halfW, halfH, radius) {
28
+ const a = halfW + radius;
29
+ const b = halfH + radius;
30
+ const lo = Math.min(a, b);
31
+ return lo * (1 + (lo / Math.max(a, b)) ** 2.7) ** (-1 / 2.7) - radius;
32
+ }
27
33
  //# sourceMappingURL=geometry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../src/geometry.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,MAAM,CAAC,GAAQ,EAAE,QAAgB,EAAE,QAAgB,EAAE,GAAQ;IAC3E,IAAI,GAAG,KAAK,MAAM,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QAAE,OAAO,GAAG,CAAC;IACzD,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC5E,MAAM,IAAI,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,GA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C,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,KAAa,EAAE,MAAc;IACnE,MAAM,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC;IACzB,MAAM,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;AACxE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { EdinstvoGlass, defineGlass } from "./element.js";
1
+ export { EdinstvoGlass, EdinstvoGlassGroup, defineGlass } from "./element.js";
2
2
  export { GlassSurface, attachGlass, type GlassOptions } from "./surface.js";
3
- export { type Material, type PresetName, presets, ranges, resolveMaterial } from "./material.js";
4
- export { type Interaction, type InteractionName, interactions } from "./interaction.js";
3
+ export { type Material, defaults, ranges, resolveMaterial } from "./material.js";
4
+ export { type Motion, motionDefaults, motionRanges, resolveMotion } from "./interaction.js";
5
5
  export type { GlassImage, GlassSource } from "./backdrop.js";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { EdinstvoGlass, defineGlass } from "./element.js";
1
+ export { EdinstvoGlass, EdinstvoGlassGroup, defineGlass } from "./element.js";
2
2
  export { GlassSurface, attachGlass } from "./surface.js";
3
- export { presets, ranges, resolveMaterial } from "./material.js";
4
- export { interactions } from "./interaction.js";
3
+ export { defaults, ranges, resolveMaterial } from "./material.js";
4
+ export { motionDefaults, motionRanges, resolveMotion } from "./interaction.js";
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAkC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAA0C,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAiB,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAe,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,47 +1,61 @@
1
- export interface Interaction {
1
+ export interface Motion {
2
2
  follow: number;
3
3
  press: number;
4
- stretch: number;
4
+ jelly: number;
5
+ glow: number;
6
+ morph: number;
7
+ merge: number;
5
8
  }
6
- export declare const interactions: {
7
- readonly none: {
8
- readonly follow: 0;
9
- readonly press: 0;
10
- readonly stretch: 0;
11
- };
12
- readonly calm: {
13
- readonly follow: 0.5;
14
- readonly press: 0.4;
15
- readonly stretch: 0;
16
- };
17
- readonly lively: {
18
- readonly follow: 1;
19
- readonly press: 1;
20
- readonly stretch: 1;
21
- };
22
- };
23
- export type InteractionName = keyof typeof interactions;
9
+ export declare const motionRanges: Record<keyof Motion, readonly [number, number]>;
10
+ export declare const motionKeys: (keyof Motion)[];
11
+ export declare const motionDefaults: Motion;
12
+ export declare const still: Motion;
13
+ export declare function resolveMotion(...layers: (Partial<Motion> | undefined)[]): Motion;
24
14
  export declare class Spring {
25
15
  private stiffness;
26
16
  private damping;
27
17
  value: number;
28
18
  target: number;
29
- private velocity;
19
+ velocity: number;
30
20
  constructor(value?: number, stiffness?: number, damping?: number);
31
21
  step(dt: number): void;
22
+ tune(stiffness: number): void;
23
+ snap(value: number): void;
24
+ shift(delta: number): void;
32
25
  get settled(): boolean;
33
26
  }
34
- export declare class Motion {
35
- private host;
27
+ export interface ShapeBox {
28
+ x: number;
29
+ y: number;
30
+ halfW: number;
31
+ halfH: number;
32
+ radius: number;
33
+ join: number;
34
+ }
35
+ export declare class Shape {
36
+ readonly element: HTMLElement;
36
37
  private wake;
37
38
  x: Spring;
38
39
  y: Spring;
40
+ w: Spring;
41
+ h: Spring;
42
+ pointerX: Spring;
43
+ pointerY: Spring;
39
44
  held: Spring;
45
+ glow: Spring;
46
+ touchX: number;
47
+ touchY: number;
48
+ radius: number;
49
+ placed: boolean;
50
+ motion: Motion;
40
51
  private springs;
41
52
  private cleanup;
42
- constructor(host: HTMLElement, wake: () => void);
53
+ constructor(element: HTMLElement, wake: () => void);
43
54
  get moving(): boolean;
55
+ get pressed(): boolean;
44
56
  attach(): void;
45
57
  detach(): void;
46
- step(dt: number, interaction: Interaction): void;
58
+ read(rect: DOMRect, scrolled: boolean, grow: boolean): void;
59
+ step(dt: number): void;
60
+ box(scale: number): ShapeBox;
47
61
  }