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/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, and the Token wheel, an onboarding screen. 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.
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
@@ -181,6 +181,61 @@ import { TokenWheel } from 'craft-library';
181
181
 
182
182
  It is WebGL (three.js 0.169, which comes with the package and loads the first time it mounts), so one per screen is best. The screen is true black; put it on a dark page.
183
183
 
184
+ ## Thumbs reaction
185
+
186
+ <a href="https://saralobolibrary.com/joinha?ref=npm"><img src="https://saralobolibrary.com/og/joinha.jpg" width="600" alt="Thumbs reaction, Sara Lobo Library"></a>
187
+
188
+ [See it live and copy its prompt →](https://saralobolibrary.com/joinha?ref=npm)
189
+
190
+ A thumbs up and a thumbs down drawn like Apple's symbols, 24px by default, in the text colour. Nothing is recorded: every frame is simulated. A tap on the up thumb opens a ring of dots from its middle and the thumb jumps, leaning back in the air, and lands upright on a soft silicone contact with one small hop, the tip landing a moment after the base. Hold it to charge: it crouches and trembles, and the jump and the ring grow. The down thumb only bows its head. A second tap clears; choosing one clears the other.
191
+
192
+ ```jsx
193
+ import { ThumbsReaction } from 'craft-library';
194
+
195
+ <ThumbsReaction onChange={(value) => saveRating(value)} /> // "up", "down" or null
196
+ ```
197
+
198
+ | Prop | | |
199
+ |---|---|---|
200
+ | `value` | `"up"`, `"down"` or `null` | Sets it without the animation, and follows the prop when it changes. |
201
+ | `onChange` | `(value) => void` | After every tap: `"up"`, `"down"` or `null`. |
202
+ | `size` | `number` or CSS length | The icons. Default `24`. |
203
+ | `labels` | `{ up, down }` | The buttons' accessible names. Default `"Like"`, `"Dislike"`. |
204
+ | `label` | `string` | The group's name. Default `"Rate"`. |
205
+
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
+
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
+
184
239
  ## Magic sphere and Sweep
185
240
 
186
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>
@@ -233,7 +288,7 @@ It is WebGL with no dependencies, so one per screen is best. Your clip and pictu
233
288
 
234
289
  ## Plain HTML
235
290
 
236
- One script registers ten tags. Same pieces, same props as attributes.
291
+ One script registers twelve tags. Same pieces, same props as attributes.
237
292
 
238
293
  ```html
239
294
  <script src="https://cdn.jsdelivr.net/npm/craft-library@0/dist/craft.js"></script>
@@ -248,13 +303,15 @@ One script registers ten tags. Same pieces, same props as attributes.
248
303
  <panorama-reel heading="Lorem ipsum"></panorama-reel> <!-- text, text-italic; video and stills as JSON; el.replay(); 100% wide, 640px tall unless you size it -->
249
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 -->
250
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 -->
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) -->
251
308
  ```
252
309
 
253
310
  With a bundler and no React: `import 'craft-library/elements'`.
254
311
 
255
312
  ## Motion and access
256
313
 
257
- 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, and the token wheel starts formed and still. 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.
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"`).
258
315
 
259
316
  MIT · [Sara Lobo Library](https://saralobolibrary.com)
260
317
 
package/dist/card-load.js CHANGED
@@ -1,3 +1,3 @@
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
  // 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');
@@ -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
  // 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.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
  // 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.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
  // 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.7.2 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
2
- // the one-file build for a <script> tag: registers the ten tags and exposes the mount functions (the 3D pieces' scenes
1
+ /*! Sara Lobo Library · craft-library 0.9.0 · interface pieces by Sara Lobo · https://saralobolibrary.com · MIT */
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 } from './elements.js';
5
- window.CraftLibrary = { mountLike, mountMagnet, mountGlassNav, mountIridescentCard, mountPiggyBank, mountThinking, mountPanoramaReel, mountMapPin, mountTokenWheel };
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 };