craft-library 0.7.2 → 0.9.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/dist/elements.js CHANGED
@@ -1,5 +1,5 @@
1
- /*! Sara Lobo Library · craft-library 0.7.2 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
- // <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin> and <token-wheel>: the
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
+ // <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin>, <token-wheel>, <thumbs-reaction> and <fold-orb>: the
3
3
  // pieces as HTML tags, for pages without React. They render into the page itself (no shadow root), so the glass can
4
4
  // blend with what is behind it.
5
5
  import { mountLike } from './like.js';
@@ -11,6 +11,8 @@ import { mountThinking } from './thinking.js';
11
11
  import { mountPanoramaReel } from './panorama-mount.js';
12
12
  import { mountMapPin } from './pin-mount.js';
13
13
  import { mountTokenWheel } from './tokens-mount.js';
14
+ import { mountThumbsReaction } from './joinha.js';
15
+ import { mountFoldOrb } from './orb.js';
14
16
  import { css } from './style.js';
15
17
  import { sign } from './sign.js';
16
18
 
@@ -21,7 +23,7 @@ function define(name, mount, options) {
21
23
  customElements.define(name, class extends HTMLElement {
22
24
  connectedCallback() {
23
25
  if (this.piece) return; // moved, not new: it keeps its state
24
- css('craft-hosts', 'like-button,magnetic-icon{display:inline-block;line-height:0;vertical-align:middle}');
26
+ css('craft-hosts', 'like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}fold-orb{display:block}');
25
27
  this.piece = mount(this, options(this));
26
28
  }
27
29
  });
@@ -138,4 +140,49 @@ define('token-wheel', (el, o) => {
138
140
  turned: el.hasAttribute('turned') && el.getAttribute('turned') !== 'false'
139
141
  }));
140
142
 
141
- export { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel };
143
+ // the thumbs: inline, in the text colour. size="24" (px) or any CSS length; value="up" or "down" starts it chosen, with
144
+ // no animation. Each choice fires "change" with e.detail.value ("up", "down" or null). The names: label-up,
145
+ // label-down, label. From code, el.set("up"), el.play("up") (the reaction again) and el.value
146
+ define('thumbs-reaction', (el, o) => {
147
+ const m = mountThumbsReaction(el, o);
148
+ el.set = m.set; el.play = m.play;
149
+ Object.defineProperty(el, 'value', { configurable: true, get: () => m.value(), set: (v) => m.set(v) });
150
+ return m;
151
+ }, (el) => ({
152
+ value: el.getAttribute('value') || undefined,
153
+ size: el.getAttribute('size') ? (isNaN(el.getAttribute('size')) ? el.getAttribute('size') : +el.getAttribute('size')) : undefined,
154
+ labels: { up: el.getAttribute('label-up') || undefined, down: el.getAttribute('label-down') || undefined },
155
+ label: el.getAttribute('label') || undefined,
156
+ onChange: (value) => send(el, 'change', { value })
157
+ }));
158
+
159
+ // the orb: a block, 100% wide, height="420" (px) or any CSS length. tone="steel|mist|blue", state="idle|typing|listening|
160
+ // thinking|speaking", follow="#field" (a selector: it watches that field's caret while it has focus), level="0.6"
161
+ // (your own audio; leave it out for the built-in voice), mic (listening uses the microphone). Changing an attribute
162
+ // moves it; from code, el.state = "thinking", el.tone = "mist", el.level = 0.6 (null: the built-in voice), el.pulse()
163
+ // (one keystroke), el.lookAt(clientX, clientY) (null: stop), el.follow(field)
164
+ define('fold-orb', (el, o) => {
165
+ const m = mountFoldOrb(el, o), num = (v) => v == null || v === '' ? null : +v;
166
+ const sel = el.getAttribute('follow');
167
+ if (sel && !o.follow) { const f = () => m.follow(document.querySelector(sel)); if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', f, { once: true }); else f(); }
168
+ el.pulse = m.pulse; el.lookAt = m.lookAt; el.follow = m.follow;
169
+ Object.defineProperty(el, 'state', { configurable: true, get: () => el.getAttribute('state') || 'idle', set: (v) => el.setAttribute('state', v) });
170
+ Object.defineProperty(el, 'tone', { configurable: true, get: () => el.getAttribute('tone') || 'steel', set: (v) => el.setAttribute('tone', v) });
171
+ Object.defineProperty(el, 'level', { configurable: true, get: () => num(el.getAttribute('level')), set: (v) => { if (v == null) el.removeAttribute('level'); else el.setAttribute('level', v); } });
172
+ new MutationObserver((list) => list.forEach((r) => {
173
+ if (r.attributeName === 'state') m.set(el.getAttribute('state') || 'idle');
174
+ else if (r.attributeName === 'tone') m.tone(el.getAttribute('tone') || 'steel');
175
+ else if (r.attributeName === 'level') m.level(num(el.getAttribute('level')));
176
+ else if (r.attributeName === 'height') m.height(el.getAttribute('height'));
177
+ })).observe(el, { attributes: true, attributeFilter: ['state', 'tone', 'level', 'height'] });
178
+ return m;
179
+ }, (el) => ({
180
+ tone: el.getAttribute('tone') || undefined,
181
+ state: el.getAttribute('state') || undefined,
182
+ height: el.getAttribute('height') || undefined,
183
+ level: el.hasAttribute('level') && el.getAttribute('level') !== '' ? +el.getAttribute('level') : undefined,
184
+ mic: el.hasAttribute('mic') && el.getAttribute('mic') !== 'false',
185
+ label: el.getAttribute('label') || undefined
186
+ }));
187
+
188
+ export { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb };
package/dist/glassnav.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Sara Lobo Library · craft-library 0.7.2 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
2
  // Liquid glass nav bar · Craft Library, by Sara Lobo. The bar's CSS, markup and engine from the library, unchanged,
3
3
  // around a mount.
4
4
  import { css } from './style.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Sara Lobo Library · craft-library 0.7.2 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
2
  // The pieces as React components. Each renders an empty host and mounts the library's own piece into it, so what
3
3
  // shows is the same markup, CSS and motion as on the site.
4
4
  import { createElement, useEffect, useRef } from 'react';
@@ -11,6 +11,8 @@ import { mountThinking } from './thinking.js';
11
11
  import { mountPanoramaReel } from './panorama-mount.js';
12
12
  import { mountMapPin } from './pin-mount.js';
13
13
  import { mountTokenWheel } from './tokens-mount.js';
14
+ import { mountThumbsReaction } from './joinha.js';
15
+ import { mountFoldOrb } from './orb.js';
14
16
  import { sign } from './sign.js';
15
17
 
16
18
  sign();
@@ -140,4 +142,37 @@ export function TokenWheel({ height = 900, labels, frame, controls, autoplay, fo
140
142
  return createElement('div', { ref: host, className, style: { position: 'relative', width: '100%', height, ...style } });
141
143
  }
142
144
 
143
- export { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel };
145
+ // A thumbs up and a thumbs down (24px by default, in the text colour). A tap on the up thumb opens a ring of dots and the
146
+ // thumb jumps and lands on a soft contact; holding it charges a bigger jump. The down thumb only bows its head. value
147
+ // sets it without the animation (and follows the prop when it changes); onChange reports every choice: "up", "down" or
148
+ // null.
149
+ export function ThumbsReaction({ value, size, labels, label, onChange, className, style }) {
150
+ const host = useRef(null), pair = useRef(null), change = useLatest(onChange);
151
+ const key = JSON.stringify([size, labels, label]);
152
+ useEffect(() => {
153
+ const m = pair.current = mountThumbsReaction(host.current, { value, size, labels, label, onChange: (v) => change.current && change.current(v) });
154
+ return () => { m.destroy(); pair.current = null; };
155
+ }, [key]);
156
+ useEffect(() => { const m = pair.current; if (m && value !== undefined && m.value() !== (value || null)) m.set(value); }, [value]);
157
+ return createElement('span', { ref: host, className, style: { ...HOST, ...style } });
158
+ }
159
+
160
+ // An AI assistant orb (WebGL, no dependencies), 100% wide and `height` tall, painting its own ground in one of three
161
+ // tones. state moves it between "idle", "typing", "listening", "thinking" and "speaking" without a jump; follow (a ref,
162
+ // an element or a selector) makes it watch that field's caret while it has focus; level (0–1) drives the voice states
163
+ // from your own audio, or a built-in voice does.
164
+ export function FoldOrb({ tone = 'steel', state = 'idle', height = 420, follow, level, mic = false, label, className, style }) {
165
+ const host = useRef(null), orb = useRef(null);
166
+ useEffect(() => {
167
+ const m = orb.current = mountFoldOrb(host.current, { tone, state, height, follow, level, mic, label });
168
+ return () => { m.destroy(); orb.current = null; };
169
+ }, [mic, label]);
170
+ useEffect(() => { if (orb.current) orb.current.tone(tone); }, [tone]);
171
+ useEffect(() => { if (orb.current) orb.current.set(state); }, [state]);
172
+ useEffect(() => { if (orb.current) orb.current.level(level == null ? null : level); }, [level]);
173
+ useEffect(() => { if (orb.current) orb.current.height(height); }, [height]);
174
+ useEffect(() => { if (orb.current) orb.current.follow(follow); }, [follow, follow && follow.current]);
175
+ return createElement('div', { ref: host, className, style: { position: 'relative', width: '100%', ...style } });
176
+ }
177
+
178
+ export { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb };
package/dist/joinha.js ADDED
@@ -0,0 +1,279 @@
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
+ // Thumbs reaction (Joinha) · Craft Library, by Sara Lobo. joinha.css and joinha.js from the library, unchanged,
3
+ // around a mount.
4
+ import { css } from './style.js';
5
+ const CSS = "/* Joinha · Sara Lobo Library\n A thumbs up and a thumbs down in one group. joinha.js draws them and runs their physics. The size is --joinha-size\n (default 24px, the size of an icon in an app); the colour is the text colour around it (set color on it or on its\n parent, or --joinha-color). */\n\n.joinha {\n --joinha-size: 24px;\n display: inline-flex;\n align-items: center;\n gap: var(--joinha-gap, calc(var(--joinha-size) * .2));\n color: var(--joinha-color, currentColor); /* currentColor as the colour itself means: the text colour it sits in */\n line-height: 0;\n vertical-align: middle;\n}\n.joinha-btn {\n position: relative;\n display: block;\n margin: 0;\n padding: calc(var(--joinha-size) * .25);\n border: 0;\n border-radius: calc(var(--joinha-size) * .4);\n background: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n touch-action: none; /* a hold charges the jump: the press must not turn into a scroll */\n -webkit-tap-highlight-color: transparent;\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n}\n.joinha-btn:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n.joinha-slot {\n position: relative;\n display: block;\n width: var(--joinha-size);\n height: var(--joinha-size);\n pointer-events: none;\n}\n.joinha-svg {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n overflow: visible; /* the jump and the ring of dots leave the icon's box */\n display: block;\n}\n.joinha-out {\n fill: none;\n stroke: currentColor;\n stroke-width: 2.1;\n stroke-linejoin: round;\n}\n.joinha-fill {\n fill: currentColor;\n stroke: currentColor;\n stroke-width: 2.1;\n stroke-linejoin: round;\n opacity: 0;\n}\n.joinha-dot {\n fill: currentColor;\n}\n";
6
+ let api;
7
+ function engine() {
8
+ if (api) return api;
9
+ const window = {};
10
+ // Joinha · Sara Lobo Library
11
+ // A thumbs up and a thumbs down, drawn in the manner of SF Symbols (from scratch: Apple's licence keeps its own
12
+ // symbols in apps for its platforms). Nothing here is a recorded animation: every frame is simulated.
13
+ // up · a tap and the thumb leaves the ground on its own speed while a ring of dots opens from its middle; it leans
14
+ // back in the air and comes down upright onto a contact spring (silicone: it gives a little, sends back about
15
+ // a fifth with one small hop, and the tip of the thumb lands a moment after its base). Hold to charge: the
16
+ // longer the press, the deeper it crouches and trembles, and the higher the jump and the wider the ring.
17
+ // down · no party: it fills, sinks a little and nods forward from the wrist, then comes back slowly.
18
+ // A second tap clears it; choosing one clears the other. A tap in the middle of a motion adds to it.
19
+ // Markup (styled by joinha.css): <div class="joinha"></div>
20
+ // Every .joinha on the page is filled as the page loads (data-value="up|down", data-label-up, data-label-down,
21
+ // aria-label on it are read). For one added later, call joinha(el, options), which returns
22
+ // { set(value, animate), play(value), value(), destroy() }. Options: value ('up', 'down' or null), labels { up, down },
23
+ // label (the group's name), onchange(value). Each choice also fires a "joinhachange" event (detail.value) on the element.
24
+ (function () {
25
+ 'use strict';
26
+ var NS = 'http://www.w3.org/2000/svg', reduce = matchMedia('(prefers-reduced-motion: reduce)');
27
+
28
+ // the drawing, on a 32 grid: one continuous outline with four finger pads, and the cuff apart
29
+ var HAND = 'M12 27.8H22.9A1.7 1.7 0 0 0 22.9 24.4H23.9A1.75 1.75 0 0 0 23.9 20.9H24.6A1.75 1.75 0 0 0 24.6 17.4H25A1.9 1.9 0 0 0 25 13.6H20.2C18.6 13.6 17.9 12.6 18 11L18.3 7.6A3 3 0 0 0 12.4 6.9C12.2 8.6 11.6 10.9 10.6 12.3C10.1 13 9.8 13.6 9.8 14.4V25.6A2.2 2.2 0 0 0 12 27.8Z';
30
+ var CUFF = 'M5 13.2H6.2A1.8 1.8 0 0 1 8 15V26A1.8 1.8 0 0 1 6.2 27.8H5A1.8 1.8 0 0 1 3.2 26V15A1.8 1.8 0 0 1 5 13.2Z';
31
+ var BASE = 27.8, SPAN = 23.6, CX = 15.05, G = 360, V0 = 120;
32
+ // silicone: how stiff the ground contact is (k), how much it loses (z), how far the squash shows (vis), how the
33
+ // thumb's tip follows the base (jf, jz) and how far it leans back in the air (tilt, degrees)
34
+ var MAT = { k: 1500, z: .42, vis: 1.5, jf: 7, jz: .32, tilt: 12 };
35
+ var uid = 0, HP = null, CP = null;
36
+
37
+ function el(tag, attrs, parent) { var e = document.createElementNS(NS, tag); for (var k in attrs) e.setAttribute(k, attrs[k]); if (parent) parent.appendChild(e); return e; }
38
+ function clamp(x, a, b) { return x < a ? a : x > b ? b : x; }
39
+ function rnd(a, b) { return a + Math.random() * (b - a); }
40
+ // the outline, sampled into points once: each frame those points are moved by the springs
41
+ function points() {
42
+ if (HP) return;
43
+ var m = el('svg', { width: '0', height: '0', 'aria-hidden': 'true' }); m.style.cssText = 'position:absolute;width:0;height:0;overflow:hidden';
44
+ (document.body || document.documentElement).appendChild(m);
45
+ function sample(d, n) { var p = el('path', { d: d }, m), L = p.getTotalLength(), pts = []; for (var i = 0; i < n; i++) { var q = p.getPointAtLength(L * i / n); pts.push([q.x, q.y]); } return pts; }
46
+ HP = sample(HAND, 176); CP = sample(CUFF, 44); m.remove();
47
+ }
48
+ // the strain at a height h (0 at the base, 1 at the thumb's tip): the up thumb squashes on the ground and its tip lags;
49
+ // the down thumb nods with two chained springs
50
+ function strain(S, h) { return S.dir > 0 ? S.ec + (S.et - S.ec) * h * h : S.e1 * 4 * h * (1 - h) + S.e2 * h * (2 * h - 1); }
51
+ function deform(pts, S, k) {
52
+ var d = '';
53
+ for (var i = 0; i < pts.length; i++) {
54
+ var x = pts[i][0], y = pts[i][1], h = clamp((BASE - y) / SPAN, 0, 1), E = strain(S, h);
55
+ var yy = BASE - (BASE - y) * (1 + E), xx = CX + (x - CX) * (1 - .5 * E);
56
+ if (k !== 1) { xx = CX + (xx - CX) * k; yy = 16.4 + (yy - 16.4) * k; }
57
+ d += (i ? 'L' : 'M') + xx.toFixed(2) + ' ' + yy.toFixed(2);
58
+ }
59
+ return d + 'Z';
60
+ }
61
+
62
+ /* one thumb: its springs, its fill and its dots */
63
+ function Body(btn, dir) {
64
+ this.dir = dir; this.btn = btn; this.t = 0; this.events = []; this.parts = [];
65
+ // up: height y (+ is down; past 0 it presses into the ground), speed v, the contact squash ec and the tip's lag et
66
+ this.y = 0; this.v = 0; this.ec = 0; this.et = 0; this.vet = 0; this.launching = false; this.tL = 0; this.TL = 0; this.tilt = 0;
67
+ this.pressA = 0; this.pressUntil = 0;
68
+ // down: a soft squash (two chained springs), a sag and a nod
69
+ this.e1 = 0; this.ve1 = 0; this.e2 = 0; this.ve2 = 0; this.jy = 0; this.vjy = 0; this.rot = 0; this.vrot = 0;
70
+ this.fs = 0; this.vfs = 0; this.ft = 0; this.charging = false; this.charge = 0; this.c0 = 0; this.on = false; this.awake = false;
71
+ var id = 'joinha' + (uid++), svg = el('svg', { class: 'joinha-svg', viewBox: '0 0 32 32', 'aria-hidden': 'true', focusable: 'false' });
72
+ var f = el('filter', { id: id, x: '-60%', y: '-60%', width: '220%', height: '220%' }, el('defs', {}, svg));
73
+ this.blur = el('feGaussianBlur', { stdDeviation: '0 0' }, f); this.smearUrl = 'url(#' + id + ')'; this.smearOn = false;
74
+ this.dots = el('g', {}, svg); this.body = el('g', {}, svg);
75
+ var flip = el('g', { transform: dir < 0 ? 'translate(.95 32) scale(1 -1)' : 'translate(.95 0)' }, this.body);
76
+ this.fill = el('path', { class: 'joinha-fill' }, flip); this.out = el('path', { class: 'joinha-out' }, flip);
77
+ var slot = document.createElement('span'); slot.className = 'joinha-slot'; slot.appendChild(svg); btn.appendChild(slot); this.slot = slot;
78
+ }
79
+ Body.prototype.at = function (dt, fn) { this.events.push({ t: this.t + dt, fn: fn }); wake(this); };
80
+ Body.prototype.step = function (dt) {
81
+ var S = this, M = MAT;
82
+ S.t += dt;
83
+ for (var i = S.events.length - 1; i >= 0; i--) if (S.t >= S.events[i].t) S.events.splice(i, 1)[0].fn();
84
+ if (S.charging) S.charge = clamp((S.t - S.c0) / .75, 0, 1);
85
+ var n = Math.max(1, Math.ceil(dt * 480)), h = dt / n, wf = 2 * Math.PI * 3.1;
86
+ var k = M.k, c = 2 * M.z * Math.sqrt(k), wt = 2 * Math.PI * M.jf, wr = 2 * Math.PI * 2.4, ws = 2 * Math.PI * 3;
87
+ for (var s = 0; s < n; s++) {
88
+ var af = -wf * wf * (S.fs - S.ft) - 2 * .62 * wf * S.vfs; S.vfs += af * h; S.fs += S.vfs * h;
89
+ if (S.dir > 0) {
90
+ // gravity, a press while you hold, and the ground: a spring that pushes but never pulls (a hair of tolerance,
91
+ // so it rests without chattering)
92
+ var press = (S.charging ? S.charge * k * 3.2 : 0) + (S.t < S.pressUntil ? S.pressA : 0), a = G + press;
93
+ if (S.y >= -.05 && !S.launching) a -= Math.max(0, G + k * S.y + c * S.v);
94
+ S.v += a * h; S.y += S.v * h;
95
+ if (S.launching && S.y < 0) S.launching = false;
96
+ S.ec = S.y > 0 ? -M.vis * S.y / SPAN : 0;
97
+ var at = -wt * wt * (S.et - S.ec) - 2 * M.jz * wt * S.vet; S.vet += at * h; S.et += S.vet * h;
98
+ } else {
99
+ var w1 = 2 * Math.PI * 4.8, w2 = 2 * Math.PI * 6, k1 = w1 * w1, k2 = w2 * w2, d1 = 2 * .42 * w1, d2 = 2 * .38 * w2, tg = S.charging ? -.1 * S.charge : 0;
100
+ var a1 = -k1 * (S.e1 - tg) - d1 * S.ve1 + k2 * (S.e2 - S.e1) + d2 * (S.ve2 - S.ve1), a2 = -k2 * (S.e2 - S.e1) - d2 * (S.ve2 - S.ve1);
101
+ S.ve1 += a1 * h; S.ve2 += a2 * h; S.e1 += S.ve1 * h; S.e2 += S.ve2 * h;
102
+ var as = -ws * ws * S.jy - 2 * .85 * ws * S.vjy; S.vjy += as * h; S.jy += S.vjy * h;
103
+ var ar = -wr * wr * S.rot - 2 * .7 * wr * S.vrot; S.vrot += ar * h; S.rot += S.vrot * h;
104
+ }
105
+ }
106
+ if (S.charging && S.dir > 0) S.vet += (Math.random() - .5) * S.charge * 3;
107
+ // the lean in the air: back, then upright, and already still when it lands (sin² has no speed at either end)
108
+ if (S.dir > 0 && S.TL) { var p = (S.t - S.tL) / S.TL; S.tilt = p > 0 && p < 1 ? -M.tilt * Math.pow(Math.sin(Math.PI * p), 2) : 0; if (p >= 1) S.TL = 0; }
109
+ for (var q = S.parts.length - 1; q >= 0; q--) { var P = S.parts[q]; P.age += dt; if (!P.step(P, dt)) { P.el.remove(); S.parts.splice(q, 1); } }
110
+ var still = S.dir > 0
111
+ ? Math.abs(S.y) + Math.abs(S.v) / 50 + Math.abs(S.et) + Math.abs(S.vet) / 20 < 2e-3
112
+ : Math.abs(S.e1) + Math.abs(S.e2) + Math.abs(S.ve1) + Math.abs(S.ve2) + Math.abs(S.jy) + Math.abs(S.vjy) / 20 + Math.abs(S.rot) / 20 + Math.abs(S.vrot) / 40 < 2e-3;
113
+ if (still && !S.charging && !S.events.length && !S.parts.length && !S.TL && S.t >= S.pressUntil && Math.abs(S.fs - S.ft) < 1e-3 && Math.abs(S.vfs) < 1e-3) {
114
+ S.y = S.v = S.ec = S.et = S.vet = S.e1 = S.e2 = S.ve1 = S.ve2 = S.jy = S.vjy = S.rot = S.vrot = 0; S.fs = S.ft; S.awake = false;
115
+ }
116
+ };
117
+ Body.prototype.render = function () {
118
+ var S = this, kf = .45 + .55 * S.fs, tr;
119
+ S.out.setAttribute('d', deform(HP, S, 1) + deform(CP, S, 1));
120
+ S.fill.setAttribute('d', deform(HP, S, kf) + deform(CP, S, kf));
121
+ S.fill.style.opacity = clamp(S.fs * 4, 0, 1).toFixed(3);
122
+ if (S.dir > 0) tr = 'translate(0 ' + Math.min(0, S.y).toFixed(2) + ')' + (S.tilt ? ' rotate(' + S.tilt.toFixed(2) + ' 16 21)' : '');
123
+ else tr = 'translate(0 ' + S.jy.toFixed(2) + ')' + (S.rot ? ' rotate(' + S.rot.toFixed(2) + ' 16 6)' : '');
124
+ S.body.setAttribute('transform', tr);
125
+ // a motion blur along the jump, only while it is fast
126
+ var smear = S.dir > 0 && S.y < 0 ? clamp(Math.abs(S.v) * .009 - .25, 0, 1.4) : 0;
127
+ if (smear > .02) { S.blur.setAttribute('stdDeviation', '0 ' + smear.toFixed(2)); if (!S.smearOn) { S.body.setAttribute('filter', S.smearUrl); S.smearOn = true; } }
128
+ else if (S.smearOn) { S.body.removeAttribute('filter'); S.smearOn = false; }
129
+ for (var i = 0; i < S.parts.length; i++) S.parts[i].draw(S.parts[i]);
130
+ };
131
+ // the ring: dots leave the middle of the hand the moment you let go, stretch along their flight and shrink away.
132
+ // Small icons get bigger dots, so they still read (1× at 64px, up to 1.9× at 22px and under)
133
+ Body.prototype.ring = function (k) {
134
+ var S = this, n = 10 + Math.round(2 * k), off = rnd(0, 360), y0 = Math.min(0, S.y);
135
+ var size = S.slot.getBoundingClientRect().width || 24, ds = clamp(Math.pow(64 / size, .6), 1, 1.9);
136
+ for (var i = 0; i < n; i++) {
137
+ var a = (off + 360 * i / n) * Math.PI / 180, sp = (i % 2 ? 58 : 74) * (.85 + .35 * k);
138
+ S.dot(16 + Math.cos(a) * 9, 16.5 + Math.sin(a) * 9 + y0, Math.cos(a) * sp, Math.sin(a) * sp, (i % 2 ? .9 : 1.3) * ds);
139
+ }
140
+ };
141
+ Body.prototype.dot = function (x, y, vx, vy, r) {
142
+ var S = this, P = { x: x, y: y, vx: vx, vy: vy, r: r, age: 0, life: .58, el: el('ellipse', { class: 'joinha-dot', rx: '0', ry: '0' }, S.dots) };
143
+ P.step = function (P, dt) { var dr = Math.exp(-6 * dt); P.vx *= dr; P.vy *= dr; P.x += P.vx * dt; P.y += P.vy * dt; return P.age < P.life; };
144
+ P.draw = function (P) {
145
+ var t = P.age / P.life, sp = Math.hypot(P.vx, P.vy), st = Math.min(1.1, sp / 95), rr = P.r * (1 - .45 * t);
146
+ var o = t < .55 ? 1 : 1 - (t - .55) / .45, ang = Math.atan2(P.vy, P.vx) * 180 / Math.PI;
147
+ P.el.setAttribute('rx', (rr * (1 + st)).toFixed(3)); P.el.setAttribute('ry', (rr * (1 - .3 * st)).toFixed(3));
148
+ P.el.setAttribute('transform', 'translate(' + P.x.toFixed(2) + ' ' + P.y.toFixed(2) + ') rotate(' + ang.toFixed(1) + ')');
149
+ P.el.style.opacity = clamp(o, 0, 1).toFixed(3);
150
+ };
151
+ S.parts.push(P);
152
+ };
153
+ Body.prototype.react = function (k) {
154
+ var S = this; S.on = true; S.ft = 1;
155
+ if (reduce.matches) { wake(S); return; }
156
+ if (S.dir < 0) {
157
+ // it bows its head: sinks a little and tips forward from the wrist, then comes back slowly
158
+ var I = .75 + .35 * k; S.vjy += 105 * I; S.vrot += 210 * I; S.ve1 -= 1.4 * I; wake(S); return;
159
+ }
160
+ S.ring(k);
161
+ // a short press into the ground (the crouch), then it leaves on its own speed
162
+ S.pressA = MAT.k * 2.2 * (.7 + .5 * k); S.pressUntil = S.t + .09;
163
+ S.at(.09, function () {
164
+ S.pressUntil = 0;
165
+ var V = V0 * (.78 + .42 * k), y0 = Math.max(0, S.y);
166
+ S.v = -V; S.launching = true;
167
+ S.tL = S.t; S.TL = (V + Math.sqrt(Math.max(0, V * V - 2 * G * y0))) / G;
168
+ });
169
+ wake(S);
170
+ };
171
+ Body.prototype.clear = function () { var S = this; S.on = false; S.ft = 0; if (!reduce.matches) { if (S.dir > 0) S.vet -= .6; else S.ve1 -= 1.2; } wake(S); };
172
+ Body.prototype.still = function (on) {
173
+ var S = this;
174
+ S.parts.forEach(function (P) { P.el.remove(); }); S.parts = []; S.events = [];
175
+ S.y = S.v = S.ec = S.et = S.vet = S.tilt = S.TL = S.pressA = S.pressUntil = 0; S.launching = false; S.charging = false;
176
+ S.e1 = S.ve1 = S.e2 = S.ve2 = S.jy = S.vjy = S.rot = S.vrot = S.vfs = 0;
177
+ S.on = !!on; S.ft = S.fs = on ? 1 : 0; wake(S);
178
+ };
179
+
180
+ /* one loop for every thumb that is moving; it sleeps when they all rest */
181
+ var awake = [], running = false, last = 0;
182
+ function wake(S) { if (awake.indexOf(S) < 0) awake.push(S); S.awake = true; if (!running) { running = true; last = performance.now(); requestAnimationFrame(loop); } }
183
+ function loop(now) {
184
+ var dt = Math.min(1 / 30, Math.max(0, (now - last) / 1000)); last = now;
185
+ for (var i = awake.length - 1; i >= 0; i--) { var S = awake[i]; S.step(dt); S.render(); if (!S.awake) awake.splice(i, 1); }
186
+ if (awake.length) requestAnimationFrame(loop); else running = false;
187
+ }
188
+
189
+ function joinha(root, o) {
190
+ if (root.__joinha) return root.__joinha;
191
+ o = o || {}; points();
192
+ var labels = o.labels || {};
193
+ root.classList.add('joinha');
194
+ root.setAttribute('role', 'group');
195
+ if (o.label || !root.hasAttribute('aria-label')) root.setAttribute('aria-label', o.label || root.getAttribute('aria-label') || 'Rate');
196
+ root.textContent = '';
197
+ var B = {}, value = null;
198
+ [['up', 1, labels.up || 'Like'], ['down', -1, labels.down || 'Dislike']].forEach(function (d) {
199
+ var btn = document.createElement('button');
200
+ btn.type = 'button'; btn.className = 'joinha-btn'; btn.dataset.joinha = d[0];
201
+ btn.setAttribute('aria-pressed', 'false'); btn.setAttribute('aria-label', d[2]);
202
+ root.appendChild(btn);
203
+ B[d[0]] = new Body(btn, d[1]);
204
+ });
205
+ function show() { ['up', 'down'].forEach(function (v) { B[v].btn.setAttribute('aria-pressed', value === v ? 'true' : 'false'); }); }
206
+ function tell() {
207
+ if (o.onchange) o.onchange(value);
208
+ root.dispatchEvent(new CustomEvent('joinhachange', { bubbles: true, detail: { value: value } }));
209
+ }
210
+ // choose v as a tap would: k is the charge (0 a quick tap, 1 a full hold). A quick tap on the chosen one clears it
211
+ function choose(v, k, held) {
212
+ if (value === v && !held) { B[v].clear(); value = null; show(); return; }
213
+ var other = v === 'up' ? 'down' : 'up';
214
+ if (value === other) B[other].clear();
215
+ value = v; B[v].react(k); show();
216
+ }
217
+ var off = [];
218
+ ['up', 'down'].forEach(function (v) {
219
+ var S = B[v], btn = S.btn, at = 0;
220
+ function press() { S.charging = true; S.c0 = S.t; S.charge = 0; at = performance.now(); wake(S); }
221
+ function release() {
222
+ if (!S.charging) return;
223
+ var held = performance.now() - at > 170, k = held ? S.charge : .35;
224
+ S.charging = false; choose(v, k, held); tell();
225
+ }
226
+ function down(e) { if (e.button) return; try { btn.setPointerCapture(e.pointerId); } catch (_) {} press(); }
227
+ function key(e) { if ((e.key === ' ' || e.key === 'Enter') && !e.repeat) { e.preventDefault(); press(); } }
228
+ function keyup(e) { if (e.key === ' ' || e.key === 'Enter') { e.preventDefault(); release(); } }
229
+ function menu(e) { e.preventDefault(); }
230
+ btn.addEventListener('pointerdown', down); btn.addEventListener('pointerup', release); btn.addEventListener('pointercancel', release);
231
+ btn.addEventListener('keydown', key); btn.addEventListener('keyup', keyup); btn.addEventListener('contextmenu', menu);
232
+ off.push(function () { btn.removeEventListener('pointerdown', down); btn.removeEventListener('pointerup', release); btn.removeEventListener('pointercancel', release); btn.removeEventListener('keydown', key); btn.removeEventListener('keyup', keyup); btn.removeEventListener('contextmenu', menu); });
233
+ });
234
+ function set(v, animate) {
235
+ v = v === 'up' || v === 'down' ? v : null;
236
+ if (animate) { if (v) choose(v, .5, true); else if (value) { B[value].clear(); value = null; show(); } return; }
237
+ value = v; B.up.still(v === 'up'); B.down.still(v === 'down'); show();
238
+ }
239
+ set(o.value);
240
+ var api = {
241
+ set: set,
242
+ // the reaction again, as a tap would play it (from rest, so it can be shown on a loop)
243
+ play: function (v) { v = v === 'down' ? 'down' : 'up'; set(null); choose(v, .5, true); },
244
+ value: function () { return value; },
245
+ destroy: function () {
246
+ off.forEach(function (f) { f(); });
247
+ ['up', 'down'].forEach(function (v) { var S = B[v], i = awake.indexOf(S); if (i >= 0) awake.splice(i, 1); });
248
+ root.textContent = ''; root.__joinha = null;
249
+ }
250
+ };
251
+ return (root.__joinha = api);
252
+ }
253
+
254
+ function scan() {
255
+ Array.prototype.forEach.call(document.querySelectorAll('.joinha'), function (r) {
256
+ if (r.__joinha) return;
257
+ var v = r.getAttribute('data-value');
258
+ joinha(r, { value: v, labels: { up: r.getAttribute('data-label-up') || undefined, down: r.getAttribute('data-label-down') || undefined } });
259
+ });
260
+ }
261
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', scan); else scan();
262
+ window.joinha = joinha;
263
+ })();
264
+
265
+ return (api = window);
266
+ }
267
+
268
+ // host: the element the pair goes in. o: { value ('up', 'down' or null), size (px or any CSS length, default 24),
269
+ // labels { up, down } (the buttons' names, default "Like" and "Dislike"), label (the group's name, default "Rate"),
270
+ // onChange(value) }
271
+ export function mountThumbsReaction(host, o = {}) {
272
+ css('craft-joinha', CSS);
273
+ const J = engine();
274
+ host.innerHTML = '<div class="joinha"></div>';
275
+ const el = host.firstChild;
276
+ if (o.size) el.style.setProperty('--joinha-size', typeof o.size === 'number' ? o.size + 'px' : String(o.size));
277
+ const m = J.joinha(el, { value: o.value, label: o.label, labels: o.labels, onchange: (v) => { if (o.onChange) o.onChange(v); } });
278
+ return { element: el, set: (v, animate) => m.set(v, animate), play: (v) => m.play(v), value: () => m.value(), destroy() { m.destroy(); host.innerHTML = ''; } };
279
+ }
package/dist/like.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Sara Lobo Library · craft-library 0.7.2 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
2
  // Bursting heart · Craft Library, by Sara Lobo. like.css and like.js from the library, unchanged, around a mount.
3
3
  import { css } from './style.js';
4
4
  const CSS = "/* Bursting heart · Sara Lobo Library\n The heart eases out of sight, a disc grows and hollows into a ring, 14 dots and 2 or 3 small hearts fly out,\n and the heart springs back full. Every motion runs on its own property with its own curve; where two curves\n meet, both are at rest there, so nothing hitches. Unliking only takes the colour away. Pairs with like.js. */\n\n:root {\n --like-heart: #FF6767; /* the liked heart, filled (Figma: General / Heart) */\n --like-color: #F91880; /* the disc */\n --like-ring: #CC8EF5; /* the ring as it opens */\n --like-spring: cubic-bezier(.34, 1.4, .64, 1); /* fallback for browsers without linear() */\n}\n\n/* a damped spring (damping .55, 700 ms): about 12% over, a short settle, at rest at the end */\n@supports (animation-timing-function: linear(0, 1)) {\n :root {\n --like-spring: linear(0, 0.034, 0.12, 0.24, 0.378, 0.52, 0.655, 0.778, 0.883, 0.968, 1.033, 1.079, 1.108, 1.123, 1.126, 1.12, 1.108, 1.092, 1.075, 1.057, 1.04, 1.025, 1.012, 1.002, 0.994, 0.989, 0.986, 0.984, 0.984, 0.985, 0.987, 0.989, 0.991, 0.993, 0.995, 0.997, 0.999, 1, 1.001, 1.001, 1);\n }\n}\n\n/* lets the ring's hole open smoothly (without it, the ring leaves at once) */\n@property --like-hole {\n syntax: '<percentage>';\n inherits: false;\n initial-value: 0%;\n}\n\n/* the button: a 40px circle in black at 60%, made to sit over images */\n.like {\n all: unset;\n box-sizing: border-box;\n position: relative;\n display: inline-block;\n flex: none;\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: rgba(0, 0, 0, .6);\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n transition: background .2s ease, transform .22s cubic-bezier(.2, .8, .2, 1);\n}\n.like:hover {\n background: rgba(0, 0, 0, .72);\n}\n.like:active {\n transform: scale(.94);\n}\n.like:focus-visible {\n outline: 2px solid #fff;\n outline-offset: 2px;\n}\n.like-icon {\n position: absolute;\n left: 8px;\n top: 9px;\n width: 24px;\n height: 24px;\n}\n.like-icon svg {\n display: block;\n overflow: visible;\n}\n.like-line {\n fill: none;\n stroke: #fff;\n stroke-width: 2;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: stroke .24s cubic-bezier(.4, 0, .2, 1);\n}\n.like-fill {\n fill: var(--like-heart);\n opacity: 0;\n transition: opacity .24s cubic-bezier(.4, 0, .2, 1);\n}\n.like[aria-pressed=\"true\"] .like-line {\n stroke: var(--like-heart);\n}\n.like[aria-pressed=\"true\"] .like-fill {\n opacity: 1;\n}\n/* the colour swaps while the heart is out of sight */\n.like.is-liking .like-line,\n.like.is-liking .like-fill {\n transition-duration: 0s;\n transition-delay: .3s;\n}\n/* everything that flies out starts from the heart's centre */\n.like-fx {\n position: absolute;\n left: 20px;\n top: 21px;\n width: 0;\n height: 0;\n pointer-events: none;\n}\n\n/* the heart: out of sight in 120 ms, waits inside the disc, then the spring brings it back full */\n.like.is-liking .like-icon {\n animation: like-vanish .12s cubic-bezier(.5, 0, .75, 0) both, like-return .7s var(--like-spring) .32s forwards;\n}\n@keyframes like-vanish {\n from {\n scale: 1;\n opacity: 1;\n }\n to {\n scale: .15;\n opacity: 0;\n }\n}\n@keyframes like-return {\n from {\n scale: .15;\n opacity: 0;\n }\n to {\n scale: 1;\n opacity: 1;\n }\n}\n\n/* unliking: a soft dip and back while the colour leaves, at rest at both ends */\n.like.is-unliking .like-icon {\n animation: like-dip .34s cubic-bezier(.37, 0, .63, 1);\n}\n@keyframes like-dip {\n 0% {\n scale: 1;\n }\n 40% {\n scale: .86;\n }\n 100% {\n scale: 1;\n }\n}\n\n/* the ring: one long ease-out growth (to 110%), the tint, and a hole that opens before the growth ends */\n.like-ring {\n position: absolute;\n left: -23px;\n top: -23px;\n width: 46px;\n height: 46px;\n border-radius: 50%;\n background: var(--like-color);\n scale: 0;\n -webkit-mask: radial-gradient(circle closest-side, transparent var(--like-hole), #000 calc(var(--like-hole) + 2%));\n mask: radial-gradient(circle closest-side, transparent var(--like-hole), #000 calc(var(--like-hole) + 2%));\n}\n.like.is-liking .like-ring {\n animation: like-ring-grow .56s cubic-bezier(.22, 1, .36, 1) .06s both, like-ring-tint .3s ease-out .06s both, like-ring-open .36s cubic-bezier(.33, 1, .68, 1) .28s both;\n}\n@keyframes like-ring-grow {\n from {\n scale: 0;\n }\n to {\n scale: 1.1;\n }\n}\n@keyframes like-ring-tint {\n from {\n background-color: var(--like-color);\n }\n to {\n background-color: var(--like-ring);\n }\n}\n@keyframes like-ring-open {\n from {\n --like-hole: 0%;\n }\n to {\n --like-hole: 100%;\n }\n}\n\n/* the dots: 7 pairs around the ring. They fly out on a long ease-out, swell and shrink on their own clock,\n and the whole spray turns 12° as it goes */\n.like-dots i {\n position: absolute;\n left: 0;\n top: 0;\n width: 0;\n height: 0;\n transform: rotate(var(--a));\n}\n.like-dots b {\n position: absolute;\n left: -2.5px;\n top: -2.5px;\n width: 5px;\n height: 5px;\n border-radius: 50%;\n background: var(--d1);\n scale: 0;\n}\n.like-dots b + b {\n left: -1.75px;\n top: -1.75px;\n width: 3.5px;\n height: 3.5px;\n background: var(--d2);\n}\n.like-dots i:nth-child(1) { --a: 0deg; --d1: #F91880; --d2: #FF7AB6; }\n.like-dots i:nth-child(2) { --a: 51.43deg; --d1: #FFAD1F; --d2: #FFD166; }\n.like-dots i:nth-child(3) { --a: 102.86deg; --d1: #1D9BF0; --d2: #7CC6FE; }\n.like-dots i:nth-child(4) { --a: 154.29deg; --d1: #A78BFA; --d2: #C4B5FD; }\n.like-dots i:nth-child(5) { --a: 205.71deg; --d1: #00BA7C; --d2: #6EE7B7; }\n.like-dots i:nth-child(6) { --a: 257.14deg; --d1: #F97316; --d2: #FDBA74; }\n.like-dots i:nth-child(7) { --a: 308.57deg; --d1: #F91880; --d2: #CC8EF5; }\n.like.is-liking .like-dots i {\n animation: like-swirl .9s cubic-bezier(.22, 1, .36, 1) .34s both;\n}\n.like.is-liking .like-dots b {\n animation: like-fly .62s cubic-bezier(.16, 1, .3, 1) .34s both, like-dot .62s .34s both;\n}\n.like.is-liking .like-dots b + b {\n animation-name: like-fly-2, like-dot;\n animation-delay: .38s;\n}\n@keyframes like-swirl {\n from {\n rotate: 0deg;\n }\n to {\n rotate: 12deg;\n }\n}\n@keyframes like-fly {\n from {\n translate: 0 -20px;\n }\n to {\n translate: 0 -33px;\n }\n}\n@keyframes like-fly-2 {\n from {\n translate: 4.5px -18px;\n }\n to {\n translate: 8px -29px;\n }\n}\n@keyframes like-dot {\n 0% {\n scale: 0;\n animation-timing-function: cubic-bezier(.33, 1, .68, 1);\n }\n 24% {\n scale: 1;\n animation-timing-function: cubic-bezier(.32, 0, .67, 0);\n }\n 100% {\n scale: 0;\n }\n}\n\n/* the small hearts (like.js adds them): the rise is one unbroken ease-out, the sway a sine that rests at its turns,\n and size and fade keep their own clocks */\n.like-float {\n position: absolute;\n left: 0;\n top: -6px;\n opacity: 0;\n animation: like-rise var(--dur) cubic-bezier(.33, 1, .68, 1) var(--dl) both, like-fade var(--dur) var(--dl) both;\n}\n.like-float span {\n display: block;\n animation: like-sway var(--dur) cubic-bezier(.37, 0, .63, 1) var(--dl) both, like-grow var(--dur) var(--dl) both;\n}\n.like-float svg {\n display: block;\n width: var(--s);\n height: var(--s);\n margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);\n fill: var(--fc);\n}\n@keyframes like-rise {\n from {\n translate: 0 0;\n }\n to {\n translate: 0 var(--dy);\n }\n}\n@keyframes like-fade {\n 0% {\n opacity: 0;\n animation-timing-function: cubic-bezier(.33, 1, .68, 1);\n }\n 14% {\n opacity: 1;\n animation-timing-function: linear;\n }\n 50% {\n opacity: 1;\n animation-timing-function: cubic-bezier(.37, 0, .63, 1);\n }\n 100% {\n opacity: 0;\n }\n}\n@keyframes like-sway {\n 0% {\n translate: 0 0;\n rotate: 0deg;\n }\n 33% {\n translate: var(--dx) 0;\n rotate: var(--r);\n }\n 70% {\n translate: calc(var(--dx) * -.6) 0;\n rotate: calc(var(--r) * -.6);\n }\n 100% {\n translate: calc(var(--dx) * .25) 0;\n rotate: 0deg;\n }\n}\n@keyframes like-grow {\n 0% {\n scale: .3;\n animation-timing-function: cubic-bezier(.34, 1.56, .64, 1);\n }\n 24% {\n scale: 1;\n animation-timing-function: cubic-bezier(.32, 0, .67, 0);\n }\n 100% {\n scale: .8;\n }\n}\n\n/* less motion: only the colour changes */\n@media (prefers-reduced-motion: reduce) {\n .like,\n .like * {\n animation: none !important;\n }\n}\n";
package/dist/magnet.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Sara Lobo Library · craft-library 0.7.2 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
2
  // Magnetic icon · Craft Library, by Sara Lobo. magnet.css and magnet.js from the library, unchanged, around a mount.
3
3
  import { css } from './style.js';
4
4
  const CSS = "/* Magnetic icon · Sara Lobo Library\n A dark disc with a brushed-metal rim and a search glyph (Figma: 40×40). Near the cursor the rim acts like metal\n near a strong magnet: the disc is drawn toward the pointer, the strained rim creases and trembles, its tip cracks\n into shards, and small voxels break off and fly to the pointer. Pairs with magnet.js.\n Everything is drawn in a 40-unit box, so --mag-size scales the whole piece, the pull included. */\n\n.mag {\n all: unset;\n position: relative;\n display: inline-grid;\n place-items: center;\n width: var(--mag-size, 40px);\n height: var(--mag-size, 40px);\n border-radius: 50%;\n color: #fff;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n transition: transform .2s cubic-bezier(.2, .8, .2, 1);\n}\n.mag:active {\n transform: scale(.94);\n}\n.mag:focus-visible {\n outline: 2px solid #9DB8FF;\n outline-offset: 4px;\n}\n/* the disc and its rim, redrawn by magnet.js; the stretch reaches past the button */\n.mag-ring {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n pointer-events: none;\n}\n/* the shards and voxels: 46 units of room on every side of the 40-unit button (46 / 40 = 115%) */\n.mag-dust {\n position: absolute;\n left: -115%;\n top: -115%;\n width: 330%;\n height: 330%;\n pointer-events: none;\n}\n.mag-icon {\n position: relative;\n display: block;\n width: 50%;\n height: 50%;\n}\n";