craft-library 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -3
- package/dist/card-load.js +1 -1
- package/dist/card-mount.js +1 -1
- package/dist/card.cdn.js +1 -1
- package/dist/card.js +1 -1
- package/dist/cdn.js +4 -4
- package/dist/craft.js +1473 -5
- package/dist/elements.js +55 -4
- package/dist/glassnav.js +1 -1
- package/dist/index.js +36 -2
- package/dist/joinha.js +1 -1
- package/dist/leporello-assets.js +3 -0
- package/dist/leporello.js +466 -0
- package/dist/like.js +1 -1
- package/dist/magnet.js +1 -1
- package/dist/olea/amb-ecobag.jpg +0 -0
- package/dist/olea/amb-linha.jpg +0 -0
- package/dist/olea/amb-mesa.jpg +0 -0
- package/dist/olea/amb-papelaria.jpg +0 -0
- package/dist/olea/amb-rotulo.jpg +0 -0
- package/dist/olea/ecobag.jpg +0 -0
- package/dist/olea/linha.jpg +0 -0
- package/dist/olea/mesa.jpg +0 -0
- package/dist/olea/papelaria.jpg +0 -0
- package/dist/olea/rotulo.jpg +0 -0
- package/dist/orb.js +381 -0
- package/dist/panorama-assets.js +2 -2
- package/dist/panorama-mount.js +1 -1
- package/dist/panorama.js +1 -1
- package/dist/piggy-load.js +1 -1
- package/dist/piggy-mount.js +1 -1
- package/dist/piggy.cdn.js +1 -1
- package/dist/piggy.js +1 -1
- package/dist/pin-load.js +1 -1
- package/dist/pin-mount.js +1 -1
- package/dist/pin.cdn.js +1 -1
- package/dist/pin.js +1 -1
- package/dist/sign.js +1 -1
- package/dist/style.js +1 -1
- package/dist/thinking.js +1 -1
- package/dist/tokens-load.js +1 -1
- package/dist/tokens-mount.js +1 -1
- package/dist/tokens.cdn.js +1 -1
- package/dist/tokens.js +1 -1
- package/package.json +7 -3
package/dist/elements.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
2
|
-
// <glass-nav>, <like-button>, <magnetic-icon>, <iridescent-card>, <piggy-bank>, <magic-sphere>, <sweep-sphere>, <panorama-reel>, <map-pin>, <token-wheel> and <
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.10.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>, <fold-orb> and <leporello-book>: 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';
|
|
@@ -12,6 +12,8 @@ import { mountPanoramaReel } from './panorama-mount.js';
|
|
|
12
12
|
import { mountMapPin } from './pin-mount.js';
|
|
13
13
|
import { mountTokenWheel } from './tokens-mount.js';
|
|
14
14
|
import { mountThumbsReaction } from './joinha.js';
|
|
15
|
+
import { mountFoldOrb } from './orb.js';
|
|
16
|
+
import { mountLeporello } from './leporello.js';
|
|
15
17
|
import { css } from './style.js';
|
|
16
18
|
import { sign } from './sign.js';
|
|
17
19
|
|
|
@@ -22,7 +24,7 @@ function define(name, mount, options) {
|
|
|
22
24
|
customElements.define(name, class extends HTMLElement {
|
|
23
25
|
connectedCallback() {
|
|
24
26
|
if (this.piece) return; // moved, not new: it keeps its state
|
|
25
|
-
css('craft-hosts', 'like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}');
|
|
27
|
+
css('craft-hosts', 'like-button,magnetic-icon,thumbs-reaction{display:inline-block;line-height:0;vertical-align:middle}fold-orb,leporello-book{display:block}');
|
|
26
28
|
this.piece = mount(this, options(this));
|
|
27
29
|
}
|
|
28
30
|
});
|
|
@@ -155,4 +157,53 @@ define('thumbs-reaction', (el, o) => {
|
|
|
155
157
|
onChange: (value) => send(el, 'change', { value })
|
|
156
158
|
}));
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
// the orb: a block, 100% wide, height="420" (px) or any CSS length. tone="steel|mist|blue", state="idle|typing|listening|
|
|
161
|
+
// thinking|speaking", follow="#field" (a selector: it watches that field's caret while it has focus), level="0.6"
|
|
162
|
+
// (your own audio; leave it out for the built-in voice), mic (listening uses the microphone). Changing an attribute
|
|
163
|
+
// moves it; from code, el.state = "thinking", el.tone = "mist", el.level = 0.6 (null: the built-in voice), el.pulse()
|
|
164
|
+
// (one keystroke), el.lookAt(clientX, clientY) (null: stop), el.follow(field)
|
|
165
|
+
define('fold-orb', (el, o) => {
|
|
166
|
+
const m = mountFoldOrb(el, o), num = (v) => v == null || v === '' ? null : +v;
|
|
167
|
+
const sel = el.getAttribute('follow');
|
|
168
|
+
if (sel && !o.follow) { const f = () => m.follow(document.querySelector(sel)); if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', f, { once: true }); else f(); }
|
|
169
|
+
el.pulse = m.pulse; el.lookAt = m.lookAt; el.follow = m.follow;
|
|
170
|
+
Object.defineProperty(el, 'state', { configurable: true, get: () => el.getAttribute('state') || 'idle', set: (v) => el.setAttribute('state', v) });
|
|
171
|
+
Object.defineProperty(el, 'tone', { configurable: true, get: () => el.getAttribute('tone') || 'steel', set: (v) => el.setAttribute('tone', v) });
|
|
172
|
+
Object.defineProperty(el, 'level', { configurable: true, get: () => num(el.getAttribute('level')), set: (v) => { if (v == null) el.removeAttribute('level'); else el.setAttribute('level', v); } });
|
|
173
|
+
new MutationObserver((list) => list.forEach((r) => {
|
|
174
|
+
if (r.attributeName === 'state') m.set(el.getAttribute('state') || 'idle');
|
|
175
|
+
else if (r.attributeName === 'tone') m.tone(el.getAttribute('tone') || 'steel');
|
|
176
|
+
else if (r.attributeName === 'level') m.level(num(el.getAttribute('level')));
|
|
177
|
+
else if (r.attributeName === 'height') m.height(el.getAttribute('height'));
|
|
178
|
+
})).observe(el, { attributes: true, attributeFilter: ['state', 'tone', 'level', 'height'] });
|
|
179
|
+
return m;
|
|
180
|
+
}, (el) => ({
|
|
181
|
+
tone: el.getAttribute('tone') || undefined,
|
|
182
|
+
state: el.getAttribute('state') || undefined,
|
|
183
|
+
height: el.getAttribute('height') || undefined,
|
|
184
|
+
level: el.hasAttribute('level') && el.getAttribute('level') !== '' ? +el.getAttribute('level') : undefined,
|
|
185
|
+
mic: el.hasAttribute('mic') && el.getAttribute('mic') !== 'false',
|
|
186
|
+
label: el.getAttribute('label') || undefined
|
|
187
|
+
}));
|
|
188
|
+
|
|
189
|
+
// the leporello: a block, 100% wide; give it a height (style="height:560px" or height="560"). With no pages it shows the
|
|
190
|
+
// library's own book. pages='[{"title":"…","text":"…","image":"a.jpg"}, …]' (JSON), kicker, heading, autoplay="false",
|
|
191
|
+
// label-open, label-close. Events on the tag: leporellochange, leporelloopen, leporelloclose (e.detail.index). From
|
|
192
|
+
// code: el.open(), el.close(), el.next(), el.prev(), el.go(i), el.play(), el.pause()
|
|
193
|
+
define('leporello-book', (el, o) => {
|
|
194
|
+
const m = mountLeporello(el, o);
|
|
195
|
+
['open', 'close', 'next', 'prev', 'go', 'play', 'pause'].forEach((k) => { el[k] = m[k]; });
|
|
196
|
+
return m;
|
|
197
|
+
}, (el) => {
|
|
198
|
+
const a = (n) => el.getAttribute(n), json = (v) => { try { return v ? JSON.parse(v) : undefined; } catch (e) { return undefined; } };
|
|
199
|
+
return {
|
|
200
|
+
pages: json(a('pages')),
|
|
201
|
+
kicker: el.hasAttribute('kicker') ? a('kicker') : undefined,
|
|
202
|
+
title: el.hasAttribute('heading') ? a('heading') : undefined,
|
|
203
|
+
autoplay: a('autoplay') === 'false' ? false : undefined,
|
|
204
|
+
height: a('height') || undefined,
|
|
205
|
+
labels: { open: a('label-open') || undefined, close: a('label-close') || undefined }
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
export { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb, mountLeporello };
|
package/dist/glassnav.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.10.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.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.10.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';
|
|
@@ -12,6 +12,8 @@ import { mountPanoramaReel } from './panorama-mount.js';
|
|
|
12
12
|
import { mountMapPin } from './pin-mount.js';
|
|
13
13
|
import { mountTokenWheel } from './tokens-mount.js';
|
|
14
14
|
import { mountThumbsReaction } from './joinha.js';
|
|
15
|
+
import { mountFoldOrb } from './orb.js';
|
|
16
|
+
import { mountLeporello } from './leporello.js';
|
|
15
17
|
import { sign } from './sign.js';
|
|
16
18
|
|
|
17
19
|
sign();
|
|
@@ -156,4 +158,36 @@ export function ThumbsReaction({ value, size, labels, label, onChange, className
|
|
|
156
158
|
return createElement('span', { ref: host, className, style: { ...HOST, ...style } });
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
|
|
161
|
+
// An AI assistant orb (WebGL, no dependencies), 100% wide and `height` tall, painting its own ground in one of three
|
|
162
|
+
// tones. state moves it between "idle", "typing", "listening", "thinking" and "speaking" without a jump; follow (a ref,
|
|
163
|
+
// an element or a selector) makes it watch that field's caret while it has focus; level (0–1) drives the voice states
|
|
164
|
+
// from your own audio, or a built-in voice does.
|
|
165
|
+
export function FoldOrb({ tone = 'steel', state = 'idle', height = 420, follow, level, mic = false, label, className, style }) {
|
|
166
|
+
const host = useRef(null), orb = useRef(null);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const m = orb.current = mountFoldOrb(host.current, { tone, state, height, follow, level, mic, label });
|
|
169
|
+
return () => { m.destroy(); orb.current = null; };
|
|
170
|
+
}, [mic, label]);
|
|
171
|
+
useEffect(() => { if (orb.current) orb.current.tone(tone); }, [tone]);
|
|
172
|
+
useEffect(() => { if (orb.current) orb.current.set(state); }, [state]);
|
|
173
|
+
useEffect(() => { if (orb.current) orb.current.level(level == null ? null : level); }, [level]);
|
|
174
|
+
useEffect(() => { if (orb.current) orb.current.height(height); }, [height]);
|
|
175
|
+
useEffect(() => { if (orb.current) orb.current.follow(follow); }, [follow, follow && follow.current]);
|
|
176
|
+
return createElement('div', { ref: host, className, style: { position: 'relative', width: '100%', ...style } });
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// A brand book folded in a strip (CSS 3D), 100% wide and `height` tall, painting its own dark ground. With no pages it
|
|
180
|
+
// shows the library's own book (the Olea brand book). The middle page opens into a page of its own on a click.
|
|
181
|
+
export function Leporello({ pages, kicker, title, labels, autoplay = true, height = 560, onChange, onOpen, onClose, className, style }) {
|
|
182
|
+
const host = useRef(null), book = useRef(null), change = useLatest(onChange), open = useLatest(onOpen), close = useLatest(onClose);
|
|
183
|
+
const key = JSON.stringify([pages, kicker, title, labels, autoplay]);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const m = book.current = mountLeporello(host.current, { pages, kicker, title, labels, autoplay, height,
|
|
186
|
+
onChange: (i) => change.current && change.current(i), onOpen: (i) => open.current && open.current(i), onClose: (i) => close.current && close.current(i) });
|
|
187
|
+
return () => { m.destroy(); book.current = null; };
|
|
188
|
+
}, [key]);
|
|
189
|
+
useEffect(() => { if (book.current) book.current.height(height); }, [height]);
|
|
190
|
+
return createElement('div', { ref: host, className, style: { position: 'relative', width: '100%', height: typeof height === 'number' ? height + 'px' : height, ...style } });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb, mountLeporello };
|
package/dist/joinha.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.10.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
2
|
// Thumbs reaction (Joinha) · Craft Library, by Sara Lobo. joinha.css and joinha.js from the library, unchanged,
|
|
3
3
|
// around a mount.
|
|
4
4
|
import { css } from './style.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.10.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
|
+
// where the Leporello's own book is: jsDelivr, at this version of the package
|
|
3
|
+
export const ASSETS = 'https://cdn.jsdelivr.net/npm/craft-library@0.10.0/dist/';
|