morphico 0.4.0 → 0.6.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.
Files changed (77) hide show
  1. package/README.md +147 -63
  2. package/dist/esm/all.js +50 -0
  3. package/dist/esm/clip.js +285 -0
  4. package/dist/esm/engine.js +25 -0
  5. package/dist/esm/face.js +152 -0
  6. package/dist/esm/geometry.js +459 -0
  7. package/dist/esm/icon.js +41 -0
  8. package/dist/esm/index.js +51 -0
  9. package/dist/esm/morph.js +107 -0
  10. package/dist/esm/roundness.js +37 -0
  11. package/dist/esm/sets/battery.js +87 -0
  12. package/dist/esm/sets/bell.js +101 -0
  13. package/dist/esm/sets/characters.js +64 -0
  14. package/dist/esm/sets/check-mark.js +74 -0
  15. package/dist/esm/sets/checkbox.js +91 -0
  16. package/dist/esm/sets/chevron.js +70 -0
  17. package/dist/esm/sets/condensed.js +138 -0
  18. package/dist/esm/sets/copy.js +87 -0
  19. package/dist/esm/sets/eye.js +105 -0
  20. package/dist/esm/sets/faces.js +482 -0
  21. package/dist/esm/sets/folder.js +112 -0
  22. package/dist/esm/sets/handwritten.js +137 -0
  23. package/dist/esm/sets/lock.js +75 -0
  24. package/dist/esm/sets/lucide.js +66 -0
  25. package/dist/esm/sets/media.js +109 -0
  26. package/dist/esm/sets/menu.js +84 -0
  27. package/dist/esm/sets/mic.js +102 -0
  28. package/dist/esm/sets/radio.js +84 -0
  29. package/dist/esm/sets/round.js +245 -0
  30. package/dist/esm/sets/shapes.js +461 -0
  31. package/dist/esm/sets/slim.js +149 -0
  32. package/dist/esm/sets/square.js +150 -0
  33. package/dist/esm/sets/symbols.js +154 -0
  34. package/dist/esm/sets/theme.js +107 -0
  35. package/dist/esm/sets/toggle.js +73 -0
  36. package/dist/esm/sets/volume.js +89 -0
  37. package/dist/esm/sets/weather.js +691 -0
  38. package/dist/esm/sets/wifi.js +68 -0
  39. package/dist/esm/svg.js +31 -0
  40. package/dist/esm/text.js +89 -0
  41. package/dist/esm/types.js +3 -0
  42. package/dist/morphico.js +3991 -3787
  43. package/dist/types/{iconSets.d.ts → all.d.ts} +0 -2
  44. package/dist/types/clip.d.ts +8 -18
  45. package/dist/types/face.d.ts +2 -6
  46. package/dist/types/icon.d.ts +6 -11
  47. package/dist/types/index.d.ts +4 -5
  48. package/dist/types/morph.d.ts +3 -3
  49. package/dist/types/roundness.d.ts +8 -0
  50. package/dist/types/sets/battery.d.ts +1 -1
  51. package/dist/types/sets/bell.d.ts +1 -1
  52. package/dist/types/sets/characters.d.ts +3 -2
  53. package/dist/types/sets/checkbox.d.ts +1 -1
  54. package/dist/types/sets/chevron.d.ts +1 -1
  55. package/dist/types/sets/condensed.d.ts +1 -1
  56. package/dist/types/sets/copy.d.ts +1 -1
  57. package/dist/types/sets/eye.d.ts +1 -1
  58. package/dist/types/sets/folder.d.ts +1 -1
  59. package/dist/types/sets/handwritten.d.ts +1 -1
  60. package/dist/types/sets/lock.d.ts +1 -1
  61. package/dist/types/sets/media.d.ts +1 -1
  62. package/dist/types/sets/menu.d.ts +1 -1
  63. package/dist/types/sets/mic.d.ts +1 -1
  64. package/dist/types/sets/radio.d.ts +1 -1
  65. package/dist/types/sets/round.d.ts +1 -1
  66. package/dist/types/sets/shapes.d.ts +4 -1
  67. package/dist/types/sets/slim.d.ts +1 -1
  68. package/dist/types/sets/square.d.ts +1 -1
  69. package/dist/types/sets/symbols.d.ts +38 -0
  70. package/dist/types/sets/theme.d.ts +1 -1
  71. package/dist/types/sets/toggle.d.ts +1 -1
  72. package/dist/types/sets/volume.d.ts +1 -1
  73. package/dist/types/sets/weather.d.ts +1 -1
  74. package/dist/types/sets/wifi.d.ts +1 -1
  75. package/dist/types/text.d.ts +9 -20
  76. package/package.json +95 -3
  77. package/dist/morphico.mjs +0 -4642
package/README.md CHANGED
@@ -1,122 +1,207 @@
1
1
  # morphico
2
2
 
3
- Morphing line-art icons for the web: digits (and later other icon states) that smoothly change from one to another by interpolating SVG path data. No runtime dependencies.
3
+ Morphing SVG for the web: icons, digits, cut-outs and faces that smoothly change from one state to another — play
4
+ turns into pause, 4 turns into 5, a star-shaped photo turns into a heart, a smile turns into a frown. Small, no
5
+ dependencies, works in any framework or none.
4
6
 
5
- > **Status:** early development (0.x): the API may still change.
7
+ > **Status:** 0.x — the API may still change before 1.0.
6
8
 
7
- ## Install
9
+ ## Quick start
10
+
11
+ Save this as an `.html` file and open it — no install, no build:
12
+
13
+ ```html
14
+ <!doctype html>
15
+ <button id="player" style="font-size: 48px; border: 0; background: none; color: #333; cursor: pointer"></button>
16
+
17
+ <script src="https://cdn.jsdelivr.net/npm/morphico"></script>
18
+ <script>
19
+ const { icon, iconSets } = morphico;
20
+
21
+ const button = document.querySelector('#player');
22
+ const player = icon(button, 'play', { set: iconSets.media }); // draw a "play" icon into the button
23
+
24
+ let playing = false;
25
+ button.addEventListener('click', () => {
26
+ playing = !playing;
27
+ player.to(playing ? 'pause' : 'play'); // morph to the other icon
28
+ });
29
+ </script>
30
+ ```
31
+
32
+ The icon is `1em` big and takes the CSS `color`, like text. (For a real site, pin a version in the URL:
33
+ `https://cdn.jsdelivr.net/npm/morphico@<version>`.)
34
+
35
+ With a bundler (Vite, webpack, esbuild …), install it and import what you use:
8
36
 
9
37
  ```sh
10
38
  npm install morphico
11
39
  ```
12
40
 
13
41
  ```ts
14
- import { icon, text } from 'morphico';
42
+ import { icon } from 'morphico';
43
+ import { iconsMedia } from 'morphico/sets/media'; // every set is its own import
44
+
45
+ const player = icon(document.querySelector('#player'), 'play', { set: iconsMedia });
46
+ player.to('pause');
15
47
  ```
16
48
 
17
- Or from a CDN, as a classic script with the global `morphico`:
49
+ ## The four parts
18
50
 
19
- ```html
20
- <script src="https://cdn.jsdelivr.net/npm/morphico"></script>
21
- <script>
22
- const { icon, text, clip } = morphico;
23
- </script>
51
+ All four work the same way: **create** with `(element, what to show first, options)`, **change** with `to()`,
52
+ **remove** with `destroy()`. `to()` returns a promise that resolves when the morph ends.
53
+
54
+ | | Create | Change |
55
+ | --- | --- | --- |
56
+ | [**icon**](#one-icon-iconelement-init-options) — one icon or digit | `icon(el, 'play', { set: iconsMedia })` | `.to('pause')` |
57
+ | [**text**](#a-line-of-characters-textelement-init-options) — a line of digits, e.g. a clock | `text(el, '04:59', { set: digitsRound })` | `.to('05:00')` |
58
+ | [**clip**](#a-cut-out-clipelement-init-options) — any element cut out by a shape | `clip(el, 'star')` | `.to('heart')` |
59
+ | [**face**](#a-face-faceelement-init-options) — a face with feelings | `face(el, 'normal')` | `.to('smiling')`, `.blink()` |
60
+
61
+ ```ts
62
+ await clock.to('05:00'); // wait for the morph to end
63
+ clock.to('05:01', { duration: 600 }); // options for one change
64
+ clock.destroy(); // remove it (e.g. when a component unmounts)
65
+ ```
66
+
67
+ ### In React
68
+
69
+ ```tsx
70
+ import { useEffect, useRef } from 'react';
71
+ import { icon, type Icon } from 'morphico';
72
+ import { iconsMedia } from 'morphico/sets/media';
73
+
74
+ export function PlayIcon({ playing }: { playing: boolean }) {
75
+ const element = useRef<HTMLSpanElement>(null);
76
+ const player = useRef<Icon | null>(null);
77
+
78
+ useEffect(() => { // create once, remove on unmount
79
+ player.current = icon(element.current!, playing ? 'pause' : 'play', { set: iconsMedia });
80
+ return () => player.current?.destroy();
81
+ }, []);
82
+
83
+ useEffect(() => { player.current?.to(playing ? 'pause' : 'play'); }, [playing]); // morph on change
84
+
85
+ return <span ref={element} />;
86
+ }
24
87
  ```
25
88
 
26
- ## One icon: `icon(element, options)`
89
+ ## Install details
90
+
91
+ Every set is a separate file, so a bundler only ships the sets and functions a page uses — e.g. `icon()` with one
92
+ icon set is about 13–21 KB gzipped, everything about 63 KB. `clip()` and `face()` bring their own shapes /
93
+ expressions. To pick sets by name at run time, `import { iconSets } from 'morphico/all'` (`iconSets.weather` …; this
94
+ imports every set).
95
+
96
+ The classic script from the CDN (`https://cdn.jsdelivr.net/npm/morphico`) is one file with everything: the global
97
+ `morphico` has `icon`, `text`, `clip`, `face` and the sets by name in `morphico.iconSets`.
98
+
99
+ ## One icon: `icon(element, init, options)`
27
100
 
28
101
  ```ts
29
- const digit = icon(document.querySelector('#digit'), { state: '4' });
102
+ import { icon } from 'morphico';
103
+ import { digitsRound } from 'morphico/sets/round';
104
+
105
+ const digit = icon(document.querySelector('#digit'), '4', { set: digitsRound });
30
106
 
31
107
  await digit.to('7'); // the promise resolves when the morph ends
32
108
  digit.to('8', { onEnd: (result) => {} }); // or pass a callback
33
109
  digit.destroy(); // stops and removes it (e.g. when a component unmounts)
34
110
  ```
35
111
 
36
- States of the digit sets: `'0'`…`'9'`, `'-'` `'/'` `'.'` `','` `':'`, and `' '` (empty: nothing drawn, shapes grow
37
- out of it and fade). A digit morphing into `-` `/` `.` `,` is pressed flat onto it; into `:` it splits into the two dots.
112
+ Digit sets: `digitsRound` (`morphico/sets/round`), `digitsSquare` (`/square`), `digitsCondensed` (`/condensed`),
113
+ `digitsSlim` (`/slim`), `digitsHandwritten` (`/handwritten`). Their states: `'0'`…`'9'`, `'-'` `'/'` `'.'` `','` `':'`, the symbols `'+'` `'%'` `'$'` `'€'` `'£'` (drawn in each
114
+ set's own style), and `' '` (empty: nothing drawn, shapes grow out of it and fade). A digit morphing into `-` `/` `.` `,` is pressed flat onto it; into `:` it splits into the two dots.
38
115
 
39
116
  Icon sets (based on [Lucide](https://lucide.dev)):
40
117
 
41
- | Set | States |
118
+ | Import from `morphico/sets/…` | States |
42
119
  | --- | --- |
43
- | `media` | `play`, `pause`, `stop` |
44
- | `menu` | `menu` (☰), `close` (✕), `back` (←) |
45
- | `checkbox` | `unchecked` (☐), `checked` (☑), `checked-big` (✓ breaking out of the box) |
46
- | `radio` | `unchecked` (○), `checked` (✓ in a circle), `checked-big` (✓ breaking out of the circle) |
47
- | `folder` | `closed`, `open` |
48
- | `theme` | `light` (sun), `dark` (moon) |
49
- | `weather` | `sunny`, `frosty`, `partly-cloudy`, `showers`, `cloudy`, `thunder`, `rain`, `snow`, `drizzle` |
50
- | `eye` | `visible`, `hidden` (slashed) |
51
- | `volume` | `muted` (✕), `low` (no waves), `medium`, `high` |
52
- | `toggle` | `plus`, `minus`, `close` (✕), `check` |
53
- | `lock` | `locked`, `unlocked` |
54
- | `bell` | `on`, `off` (slashed) |
55
- | `mic` | `on`, `off` (slashed) |
56
- | `chevron` | `up`, `right`, `down`, `left` |
57
- | `copy` | `copy`, `copied` (✓) |
58
- | `wifi` | `none`, `low`, `medium`, `high` |
59
- | `battery` | `empty`, `low`, `medium`, `full` |
120
+ | `media` → `iconsMedia` | `play`, `pause`, `stop` |
121
+ | `menu` → `iconsMenu` | `menu` (☰), `close` (✕), `back` (←) |
122
+ | `checkbox` → `iconsCheckbox` | `unchecked` (☐), `checked` (☑), `checked-big` (✓ breaking out of the box) |
123
+ | `radio` → `iconsRadio` | `unchecked` (○), `checked` (✓ in a circle), `checked-big` (✓ breaking out of the circle) |
124
+ | `folder` → `iconsFolder` | `closed`, `open` |
125
+ | `theme` → `iconsTheme` | `light` (sun), `dark` (moon) |
126
+ | `weather` → `iconsWeather` | `sunny`, `frosty`, `partly-cloudy`, `showers`, `cloudy`, `thunder`, `rain`, `snow`, `drizzle` |
127
+ | `eye` → `iconsEye` | `visible`, `hidden` (slashed) |
128
+ | `volume` → `iconsVolume` | `muted` (✕), `low` (no waves), `medium`, `high` |
129
+ | `toggle` → `iconsToggle` | `plus`, `minus`, `close` (✕), `check` |
130
+ | `lock` → `iconsLock` | `locked`, `unlocked` |
131
+ | `bell` → `iconsBell` | `on`, `off` (slashed) |
132
+ | `mic` → `iconsMic` | `on`, `off` (slashed) |
133
+ | `chevron` → `iconsChevron` | `up`, `right`, `down`, `left` |
134
+ | `copy` → `iconsCopy` | `copy`, `copied` (✓) |
135
+ | `wifi` → `iconsWifi` | `none`, `low`, `medium`, `high` |
136
+ | `battery` → `iconsBattery` | `empty`, `low`, `medium`, `full` |
60
137
 
61
138
  ```ts
62
- const player = icon(button, { set: 'media', state: 'play' });
139
+ import { iconsMedia } from 'morphico/sets/media';
140
+
141
+ const player = icon(button, 'play', { set: iconsMedia });
63
142
  player.to('pause');
64
143
  ```
65
144
 
66
- ## A line of characters: `text(element, options)`
145
+ ## A line of characters: `text(element, init, options)`
67
146
 
68
147
  ```ts
69
- const clock = text(document.querySelector('#clock'), { value: '04:59' });
148
+ import { text } from 'morphico';
149
+ import { digitsRound } from 'morphico/sets/round';
70
150
 
71
- clock.set('05:00'); // only the digits that changed morph
151
+ const clock = text(document.querySelector('#clock'), '04:59', { set: digitsRound });
152
+
153
+ await clock.to('05:00'); // only the digits that changed morph
72
154
  clock.destroy();
155
+
156
+ const price = text(document.querySelector('#price'), '€49.99', { set: digitsRound });
157
+ price.to('€39.99'); // a promotion: 4 → 3 morphs, the rest stays
73
158
  ```
74
159
 
75
- - Supported characters: digits `0`–`9`, space, `-` `:` `.` `,` `/` — all of them morph.
76
- **Any other character is removed** (with the regex `/[^0-9 :.,\/-]/g`): `'12:09 AM'` shows `12:09 `.
77
- - Cells: digits, space and `-` have one width, `:` `.` `,` half of it, `/` 0.7 of it. A change morphs when the length
160
+ - Supported characters: digits `0`–`9`, space, `-` `:` `.` `,` `/`, and `+` `%` `$` `€` `£` (prices and discounts:
161
+ `€39.99`, `-20%`) — all of them morph. **Any other character is removed** (with the regex `/[^0-9 :.,\/+%$€£-]/g`): `'12:09 AM'` shows `12:09 `.
162
+ - Cells: digits, space, `-` and the symbols have one width, `:` `.` `,` half of it, `/` 0.7 of it. A change morphs when the length
78
163
  and every cell's width stay the same (`5` ↔ `-`, `.` ↔ `,`); otherwise the line is rebuilt without animation
79
- (`5` ↔ `:`). Pad counters with spaces to keep them morphing: `counter.set(String(count).padStart(3, ' '))`.
164
+ (`5` ↔ `:`). Pad counters with spaces to keep them morphing: `counter.to(String(count).padStart(3, ' '))`.
80
165
  - Digits sit on the text baseline, and every cell has the same width, so clocks don't jiggle.
81
166
 
82
- ## A cut-out: `clip(element, options)`
167
+ ## A cut-out: `clip(element, init, options)`
83
168
 
84
169
  Cuts any element (an `<img>`, a `<div>`, a `<main>` …) out by a shape, and morphs, moves, resizes and turns it.
85
170
 
86
171
  ```ts
87
- const photo = clip(document.querySelector('#photo'), { state: 'star', x: 50, y: 50, size: '80%' });
172
+ const photo = clip(document.querySelector('#photo'), 'star', { x: 50, y: 50, size: '80%' });
88
173
 
89
174
  await photo.to('heart'); // morph
90
175
  photo.to('shield', { rotation: 360, x: 30, size: '120px' }); // morph + turn + move together
91
176
  photo.to({ x: 70, y: '150px' }); // move only, the shape stays
92
- photo.set({ rotation: 15 }); // jump, no animation (e.g. while dragging a slider)
93
- photo.set({ outline: { width: 16 } }); // only a 16 px band along the edge shows
94
- photo.set({ inverted: true }); // the other way round: the shape is a hole
177
+ photo.to({ rotation: 15, duration: 0 }); // jump, no animation (e.g. while dragging a slider)
178
+ photo.to({ outline: { width: 16 } }); // only a 16 px band along the edge shows
179
+ photo.to({ inverted: true }); // the other way round: the shape is a hole
95
180
  photo.destroy(); // the element is whole again
96
181
  ```
97
182
 
98
183
  Shapes (based on [Lucide](https://lucide.dev)): `circle`, `ellipse`, `heart`, `sparkle`, `astroid`, `bookmark`,
99
184
  `shield`, `moon`, `tag`, `square`, `badge`, `triangle`, `droplet`, `pentagon`, `hexagon`, `octagon`, `squircle`,
100
185
  `star`, `rectangle-horizontal`, `message-circle`, `message-square`, `cloud`, `puzzle`, `club`. A diamond is the `square`
101
- turned 45°, a portrait rectangle `rectangle-horizontal` turned 90° (`rotation`).
186
+ turned 45°, a portrait rectangle `rectangle-horizontal` turned 90° (`rotation`). The names are also exported as
187
+ `clipShapeNames` (type `ClipShape`: editors suggest them and TypeScript catches typos).
102
188
 
103
189
  | Option | Default | |
104
190
  | --- | --- | --- |
105
- | `state` | `'circle'` | The shape |
106
191
  | `x`, `y` | `50` | The shape's **centre**. A number is %, or a string `'40%'` / `'120px'` (% of the element's width for `x`, height for `y`) |
107
- | `size` | fits | The side of the shape's square (% of the element's width, or px). The shape keeps its own proportions inside that square. Default: the largest square that fits the element |
192
+ | `size` | 70 % | The side of the shape's square (% of the element's width, or px). The shape keeps its own proportions inside that square. Default: 70 % of the element's shorter side, so the shape sits in the middle with room around it |
108
193
  | `rotation` | `0` | Degrees, clockwise, **absolute**: `rotation: 360` ends one full turn from 0. The shape turns rigidly, also in a wide or tall element |
109
194
  | `roundness` | `1` | Corners: `0` = sharp … `1` = the shape's own (the maximum) |
110
195
  | `outline` | `false` | `{ width, band }`: only a band of `width` px along the edge shows; `band`: `'inside'` (default), `'centre'` or `'outside'` the edge. Not animated |
111
196
  | `inverted` | `false` | `true`: the other way round — the shape (or band) is a hole, the rest of the element shows. Not animated |
112
- | `duration`, `easing` | `400`, `'easeInOutCubic'` | As for icons; also per `to()` call |
197
+ | `duration`, `easing` | `300`, `'easeInOutCubic'` | As for icons; also per `to()` call |
113
198
 
114
- Everything except `outline` and `inverted` animates together in `to()`. How it works: a filled shape uses CSS `clip-path: url(#…)`,
199
+ Everything except `outline` and `inverted` (they switch at once) animates together in `to()`; `duration: 0` jumps. How it works: a filled shape uses CSS `clip-path: url(#…)`,
115
200
  an outlined one `mask: url(#…)` (clip-path has no line width); the `<clipPath>` / `<mask>` sit in a small hidden
116
201
  `<svg>` that `clip()` adds to the page. It follows the element's size (`ResizeObserver`). Overflow beyond the element is
117
202
  cut off, as with any clip-path.
118
203
 
119
- ## A face: `face(element, options)`
204
+ ## A face: `face(element, init, options)`
120
205
 
121
206
  A face of 7 soft pieces — 2 brows, 2 eyes, 2 pupils and a mouth — that morphs between feelings and blinks.
122
207
 
@@ -127,12 +212,11 @@ A face of 7 soft pieces — 2 brows, 2 eyes, 2 pupils and a mouth — that morph
127
212
  ```ts
128
213
  import { face } from 'morphico';
129
214
 
130
- const robot = face(document.querySelector('#robot'), { state: 'normal' });
215
+ const robot = face(document.querySelector('#robot'), 'normal');
131
216
 
132
217
  await robot.to('smiling'); // morph
133
- robot.to('angry', { duration: 300, onEnd: (result) => console.log(result) });
218
+ robot.to('angry', { duration: 300 });
134
219
  robot.blink(); // close and open the eyes once, on top of any expression
135
- robot.state; // 'angry'
136
220
  robot.destroy(); // removes the face, stops blinking
137
221
  ```
138
222
 
@@ -144,11 +228,10 @@ morphs into any other. `wink-left` / `wink-right` = the eye that closes, as seen
144
228
 
145
229
  | Option | Default | |
146
230
  | --- | --- | --- |
147
- | `state` | `'normal'` | The expression shown first |
148
231
  | `pupilColor` | `'white'` | Colour of the pupils. Brows, eyes and mouth take the CSS `color` |
149
232
  | `blink` | `true` | Blink by itself every few seconds |
150
233
  | `size` | `'100%'` | CSS width and height of the face (by default it fills the element) |
151
- | `duration`, `easing` | `500`, `'easeInOutCubic'` | As for icons; also per `to()` call |
234
+ | `duration`, `easing` | `300`, `'easeInOutCubic'` | As for icons; also per `to()` call |
152
235
 
153
236
  The face draws no background: a disc, card or anything else behind it is the element's own CSS. The pupils only show
154
237
  inside the eyes (an eyelid covers them). With reduced motion the face changes without animation and doesn't blink.
@@ -157,10 +240,9 @@ inside the eyes (an eyelid covers them). With reduced motion the face changes wi
157
240
 
158
241
  | Option | For | Default | |
159
242
  | --- | --- | --- | --- |
160
- | `set` | both | `'round'` | digits: `'round'`, `'square'`, `'condensed'`, `'slim'`, `'handwritten'`; icons (`icon()` only): `'media'`, `'menu'`, `'checkbox'`, `'radio'`, `'folder'`, `'theme'`, `'weather'`, `'eye'`, `'volume'`, `'toggle'`, `'lock'`, `'bell'`, `'mic'`, `'chevron'`, `'copy'`, `'wifi'`, `'battery'` |
161
- | `state` / `value` | icon / text | empty | What is shown first |
243
+ | `set` | both | **required** | A set object: a digit set (`digitsRound` …) for `text()`, any set for `icon()` — see above |
162
244
  | `size` | both | `'1em'` | CSS size (icon: width and height; text: height). `1em` follows the font size |
163
- | `duration` | both | `400` | Milliseconds |
245
+ | `duration` | both | `300` | Milliseconds |
164
246
  | `easing` | both | `'easeInOutCubic'` | `'linear'`, `'easeInOutCubic'`, `'easeOutBack'`, `'easeOutElastic'`, or a function `(progress) => easedProgress` |
165
247
  | `strokeWidth` | both | per set | Line width. A number is in grid units (an icon is 24 × 24; digits use about 1.1–1.6, icon sets 1.78) and scales with the size; a CSS length (`'2px'`, `'0.1rem'`, `'0.08em'`) stays that wide at any size |
166
248
  | `lineCap` | both | per set | `'round'`, `'butt'`, `'square'` |
@@ -170,17 +252,19 @@ inside the eyes (an eyelid covers them). With reduced motion the face changes wi
170
252
  | `cellWidth` | text | per set | Width of a digit cell in grid units (a digit is 16 high) |
171
253
  | `spacing` | text | per set | Gap between cells in grid units |
172
254
 
173
- `duration` and `easing` can also be passed to a single `to()` / `set()` call.
255
+ `duration` and `easing` can also be passed to a single `to()` call.
174
256
 
175
257
  ## Behaviour
176
258
 
177
259
  - **Colour** comes from the CSS `color` (`currentColor`).
178
260
  - **Spacing** can be set in CSS too: `--morphico-spacing: 0.15em`.
179
- - **Interrupting:** calling `to()` / `set()` during a morph starts the new morph from the shape on screen.
261
+ - **Interrupting:** calling `to()` during a morph starts the new morph from the shape on screen.
180
262
  The earlier promise resolves with `{ interrupted: true }`; promises never stay pending.
181
263
  - **Reduced motion:** when the user's system asks for reduced motion, shapes change without animation.
182
- - **Accessibility:** the icon / line has `role="img"` and an `aria-label` with the current value.
183
- - **Server-side rendering:** importing does not touch the DOM; only `icon()` / `text()` / `clip()` / `face()` do.
264
+ - **Accessibility:** icons, text lines and faces have `role="img"` and an `aria-label` with what they show.
265
+ - **Server-side rendering:** importing does not touch the DOM; only calling `icon()` / `text()` / `clip()` / `face()` does
266
+ (in React: inside `useEffect`).
267
+ - **TypeScript:** types are included (`Icon`, `IconOptions`, `Text`, `Clip`, `Face`, `ClipShape`, `FaceExpression` …).
184
268
 
185
269
  ## Development
186
270
 
@@ -0,0 +1,50 @@
1
+ /*! morphico v0.6.0 | MIT License, Copyright (c) 2026 Raycho Ivanov (see LICENSE) */
2
+ // Every built-in set by name — `import { iconSets } from 'morphico/all'` (and `morphico.iconSets` in the classic script).
3
+ // Imports every set: for pages that pick sets at run time. Others import single sets (`morphico/sets/<name>`), so a
4
+ // bundler only keeps those.
5
+ import { iconsCheckbox } from './sets/checkbox.js';
6
+ import { digitsCondensed } from './sets/condensed.js';
7
+ import { iconsFolder } from './sets/folder.js';
8
+ import { digitsHandwritten } from './sets/handwritten.js';
9
+ import { iconsMedia } from './sets/media.js';
10
+ import { iconsRadio } from './sets/radio.js';
11
+ import { iconsMenu } from './sets/menu.js';
12
+ import { digitsRound } from './sets/round.js';
13
+ import { digitsSlim } from './sets/slim.js';
14
+ import { digitsSquare } from './sets/square.js';
15
+ import { iconsTheme } from './sets/theme.js';
16
+ import { iconsWeather } from './sets/weather.js';
17
+ import { iconsEye } from './sets/eye.js';
18
+ import { iconsVolume } from './sets/volume.js';
19
+ import { iconsToggle } from './sets/toggle.js';
20
+ import { iconsLock } from './sets/lock.js';
21
+ import { iconsBell } from './sets/bell.js';
22
+ import { iconsMic } from './sets/mic.js';
23
+ import { iconsChevron } from './sets/chevron.js';
24
+ import { iconsCopy } from './sets/copy.js';
25
+ import { iconsWifi } from './sets/wifi.js';
26
+ import { iconsBattery } from './sets/battery.js';
27
+ export const iconSets = {
28
+ round: digitsRound,
29
+ square: digitsSquare,
30
+ condensed: digitsCondensed,
31
+ slim: digitsSlim,
32
+ handwritten: digitsHandwritten,
33
+ media: iconsMedia,
34
+ menu: iconsMenu,
35
+ checkbox: iconsCheckbox,
36
+ radio: iconsRadio,
37
+ folder: iconsFolder,
38
+ theme: iconsTheme,
39
+ weather: iconsWeather,
40
+ eye: iconsEye,
41
+ volume: iconsVolume,
42
+ toggle: iconsToggle,
43
+ lock: iconsLock,
44
+ bell: iconsBell,
45
+ mic: iconsMic,
46
+ chevron: iconsChevron,
47
+ copy: iconsCopy,
48
+ wifi: iconsWifi,
49
+ battery: iconsBattery,
50
+ };