craft-library 0.8.0 → 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/README.md +35 -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 +3 -3
- package/dist/craft.js +632 -5
- package/dist/elements.js +34 -4
- package/dist/glassnav.js +1 -1
- package/dist/index.js +21 -2
- package/dist/joinha.js +1 -1
- package/dist/like.js +1 -1
- package/dist/magnet.js +1 -1
- 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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sara Lobo Library
|
|
2
2
|
|
|
3
|
-
Interface pieces by [Sara Lobo](https://www.saralobodesign.com/), designed, tested and polished one detail at a time: a liquid glass nav bar, a bursting heart, a magnetic icon, an iridescent 3D card, a glass piggy bank, two "thinking" indicators, the Magic sphere and the Sweep, the Panorama, a hero for moving pictures, the Map pin, an address picker, the Token wheel, an onboarding screen,
|
|
3
|
+
Interface pieces by [Sara Lobo](https://www.saralobodesign.com/), designed, tested and polished one detail at a time: a liquid glass nav bar, a bursting heart, a magnetic icon, an iridescent 3D card, a glass piggy bank, two "thinking" indicators, the Magic sphere and the Sweep, the Panorama, a hero for moving pictures, the Map pin, an address picker, the Token wheel, an onboarding screen, the Thumbs reaction, a like and a dislike with simulated physics, and the Fold orb, an AI assistant orb that watches what you type. Each one is the exact piece from the library, with its own CSS and motion, for React 18+ or plain HTML. The only dependency is three.js, for five of the 3D pieces, and it loads only when one of them is on the page.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install craft-library
|
|
@@ -205,6 +205,37 @@ import { ThumbsReaction } from 'craft-library';
|
|
|
205
205
|
|
|
206
206
|
It takes the text colour: set `color` on it or its parent. The jump and the ring leave the icons' box, so keep room around it, with no `overflow: hidden` right next to it.
|
|
207
207
|
|
|
208
|
+
## Fold orb
|
|
209
|
+
|
|
210
|
+
<a href="https://saralobolibrary.com/orb?ref=npm"><img src="https://saralobolibrary.com/og/orb.jpg" width="600" alt="Fold orb, Sara Lobo Library"></a>
|
|
211
|
+
|
|
212
|
+
[See it live and copy its prompt →](https://saralobolibrary.com/orb?ref=npm)
|
|
213
|
+
|
|
214
|
+
An AI assistant orb that pays attention without a face, drawn by one WebGL shader (no dependencies): a glass sphere with two twisted folds of light inside, in three sibling tones that each paint their own ground. Typing, it sharpens and turns its fold and its rim toward the caret, and every key gives it a small push; listening and speaking, the voice ripples its folds; thinking, its folds turn faster and it defocuses into soft stripes of colour. Every motion runs on its own spring, so a change of state or tone never jumps.
|
|
215
|
+
|
|
216
|
+
```jsx
|
|
217
|
+
import { useRef, useState } from 'react';
|
|
218
|
+
import { FoldOrb } from 'craft-library';
|
|
219
|
+
|
|
220
|
+
const field = useRef(null);
|
|
221
|
+
const [state, setState] = useState('idle'); // yours: "idle", "typing", "listening", "thinking" or "speaking"
|
|
222
|
+
|
|
223
|
+
<FoldOrb tone="steel" state={state} height={420} follow={field} />
|
|
224
|
+
<input ref={field} />
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
| Prop | | |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| `tone` | `"steel"`, `"mist"` or `"blue"` | Mid grey with a white glow, a light ground with clear glass, or night blue. Default `"steel"`. |
|
|
230
|
+
| `state` | `"idle"`, `"typing"`, `"listening"`, `"thinking"`, `"speaking"` | Default `"idle"`. |
|
|
231
|
+
| `height` | `number` or CSS length | It is 100% wide. Default `420`. |
|
|
232
|
+
| `follow` | a ref, an element or a selector | A text field: while it has focus, the orb watches its caret and reacts to every key. |
|
|
233
|
+
| `level` | `0`–`1` | Your own audio, for `"listening"` and `"speaking"`. Leave it out and a built-in voice drives them. |
|
|
234
|
+
| `mic` | `boolean` | `"listening"` uses the microphone (it asks for permission). |
|
|
235
|
+
| `label` | `string` | Its accessible name. Default `"AI assistant"`. |
|
|
236
|
+
|
|
237
|
+
It paints its own ground in each tone, so give it a box: a hero area or the top of a chat screen. Each orb uses one WebGL context.
|
|
238
|
+
|
|
208
239
|
## Magic sphere and Sweep
|
|
209
240
|
|
|
210
241
|
<a href="https://saralobolibrary.com/sphere?ref=npm"><img src="https://saralobolibrary.com/og/sphere.jpg" width="296" alt="Magic sphere, Sara Lobo Library"></a> <a href="https://saralobolibrary.com/sweep?ref=npm"><img src="https://saralobolibrary.com/og/sweep.jpg" width="296" alt="Sweep, Sara Lobo Library"></a>
|
|
@@ -257,7 +288,7 @@ It is WebGL with no dependencies, so one per screen is best. Your clip and pictu
|
|
|
257
288
|
|
|
258
289
|
## Plain HTML
|
|
259
290
|
|
|
260
|
-
One script registers
|
|
291
|
+
One script registers twelve tags. Same pieces, same props as attributes.
|
|
261
292
|
|
|
262
293
|
```html
|
|
263
294
|
<script src="https://cdn.jsdelivr.net/npm/craft-library@0/dist/craft.js"></script>
|
|
@@ -273,13 +304,14 @@ One script registers eleven tags. Same pieces, same props as attributes.
|
|
|
273
304
|
<map-pin></map-pin> <!-- "pinchange" and "pinconfirm" events: e.detail { address, neighbourhood, place }; label-title, label-confirm, label-confirmed; el.replay(); 100% wide, 560px tall unless you size it -->
|
|
274
305
|
<token-wheel></token-wheel> <!-- "tokenscontinue" event; label-eyebrow, label-title, label-cta, initials; frame="false", controls="false", turned; el.turn(true|false), el.replay(); 100% wide, 900px tall unless you size it -->
|
|
275
306
|
<thumbs-reaction></thumbs-reaction> <!-- "change" event: e.detail.value ("up", "down" or null); value, size="24", label-up, label-down; el.set(v), el.play("up") -->
|
|
307
|
+
<fold-orb tone="steel" follow="#ask"></fold-orb> <!-- tone steel|mist|blue, state idle|typing|listening|thinking|speaking (change the attribute or el.state), height="420", level="0.6", mic; el.pulse(), el.lookAt(x, y) -->
|
|
276
308
|
```
|
|
277
309
|
|
|
278
310
|
With a bundler and no React: `import 'craft-library/elements'`.
|
|
279
311
|
|
|
280
312
|
## Motion and access
|
|
281
313
|
|
|
282
|
-
Every item is a real `<button>` with an accessible name; the nav marks the chosen one with `aria-current` and moves with the arrow keys. The card is a `role="button"` that Enter, Space and the arrow keys turn over; the piggy bank and the map pin's map are labelled images; the pin's address is announced as it changes and Confirm is a real button. With `prefers-reduced-motion`, the heart only changes colour, the nav only slides, the magnet stays still, the card swaps faces with a fade, with no entrance and no breathing, the piggy bank stays in place while the coins appear inside it and its eyes close, the thinking balls hold still and only breathe, the panorama skips its opening and starts settled, the map pin appears in place without its flight, the token wheel starts formed and still,
|
|
314
|
+
Every item is a real `<button>` with an accessible name; the nav marks the chosen one with `aria-current` and moves with the arrow keys. The card is a `role="button"` that Enter, Space and the arrow keys turn over; the piggy bank and the map pin's map are labelled images; the pin's address is announced as it changes and Confirm is a real button. With `prefers-reduced-motion`, the heart only changes colour, the nav only slides, the magnet stays still, the card swaps faces with a fade, with no entrance and no breathing, the piggy bank stays in place while the coins appear inside it and its eyes close, the thinking balls hold still and only breathe, the panorama skips its opening and starts settled, the map pin appears in place without its flight, the token wheel starts formed and still, the thumbs only fill, and the orb stops swaying and turns its folds slowly. The token wheel's wheel is a `role="button"` that Enter and Space replay, its title is a heading and its round buttons are real buttons with names. The panorama's title is a heading; its screens and cursor are decorative. The thumbs are a group of two `<button aria-pressed>`, each with a name, and holding Enter or Space charges the jump like a press. The orb is a labelled image (`role="img"`).
|
|
283
315
|
|
|
284
316
|
MIT · [Sara Lobo Library](https://saralobolibrary.com)
|
|
285
317
|
|
package/dist/card-load.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
2
|
// where the card comes from: for bundlers, the package's card.js (it imports the `three` dependency)
|
|
3
3
|
export const loadCard = () => import('./card.js');
|
package/dist/card-mount.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
2
|
// Iridescent card: the mount around the library's card.js. card.js, and three.js with it, loads only when a card is
|
|
3
3
|
// mounted, so the other pieces stay light.
|
|
4
4
|
import { loadCard } from './card-load.js';
|
package/dist/card.cdn.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
2
|
// Iridescent card · Sara Lobo Library
|
|
3
3
|
// A metal credit card in 3D: brushed iridescent plate, a fine struck frame along the edge, a chip and the Visa mark.
|
|
4
4
|
// It arrives with a slow half turn, from its back to its face, and a tap turns it over to show the numbers.
|
package/dist/card.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
2
|
// Iridescent card · Sara Lobo Library
|
|
3
3
|
// A metal credit card in 3D: brushed iridescent plate, a fine struck frame along the edge, a chip and the Visa mark.
|
|
4
4
|
// It arrives with a slow half turn, from its back to its face, and a tap turns it over to show the numbers.
|
package/dist/cdn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! Sara Lobo Library · craft-library 0.
|
|
1
|
+
/*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
|
|
2
2
|
// the one-file build for a <script> tag: registers the eleven tags and exposes the mount functions (the 3D pieces' scenes
|
|
3
3
|
// are fetched from next to this file the first time one is mounted, and so are the Panorama's clip and pictures)
|
|
4
|
-
import { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction } from './elements.js';
|
|
5
|
-
window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction };
|
|
4
|
+
import { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb } from './elements.js';
|
|
5
|
+
window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel, mountThumbsReaction, mountFoldOrb };
|