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.
- package/README.md +147 -63
- package/dist/esm/all.js +50 -0
- package/dist/esm/clip.js +285 -0
- package/dist/esm/engine.js +25 -0
- package/dist/esm/face.js +152 -0
- package/dist/esm/geometry.js +459 -0
- package/dist/esm/icon.js +41 -0
- package/dist/esm/index.js +51 -0
- package/dist/esm/morph.js +107 -0
- package/dist/esm/roundness.js +37 -0
- package/dist/esm/sets/battery.js +87 -0
- package/dist/esm/sets/bell.js +101 -0
- package/dist/esm/sets/characters.js +64 -0
- package/dist/esm/sets/check-mark.js +74 -0
- package/dist/esm/sets/checkbox.js +91 -0
- package/dist/esm/sets/chevron.js +70 -0
- package/dist/esm/sets/condensed.js +138 -0
- package/dist/esm/sets/copy.js +87 -0
- package/dist/esm/sets/eye.js +105 -0
- package/dist/esm/sets/faces.js +482 -0
- package/dist/esm/sets/folder.js +112 -0
- package/dist/esm/sets/handwritten.js +137 -0
- package/dist/esm/sets/lock.js +75 -0
- package/dist/esm/sets/lucide.js +66 -0
- package/dist/esm/sets/media.js +109 -0
- package/dist/esm/sets/menu.js +84 -0
- package/dist/esm/sets/mic.js +102 -0
- package/dist/esm/sets/radio.js +84 -0
- package/dist/esm/sets/round.js +245 -0
- package/dist/esm/sets/shapes.js +461 -0
- package/dist/esm/sets/slim.js +149 -0
- package/dist/esm/sets/square.js +150 -0
- package/dist/esm/sets/symbols.js +154 -0
- package/dist/esm/sets/theme.js +107 -0
- package/dist/esm/sets/toggle.js +73 -0
- package/dist/esm/sets/volume.js +89 -0
- package/dist/esm/sets/weather.js +691 -0
- package/dist/esm/sets/wifi.js +68 -0
- package/dist/esm/svg.js +31 -0
- package/dist/esm/text.js +89 -0
- package/dist/esm/types.js +3 -0
- package/dist/morphico.js +3991 -3787
- package/dist/types/{iconSets.d.ts → all.d.ts} +0 -2
- package/dist/types/clip.d.ts +8 -18
- package/dist/types/face.d.ts +2 -6
- package/dist/types/icon.d.ts +6 -11
- package/dist/types/index.d.ts +4 -5
- package/dist/types/morph.d.ts +3 -3
- package/dist/types/roundness.d.ts +8 -0
- package/dist/types/sets/battery.d.ts +1 -1
- package/dist/types/sets/bell.d.ts +1 -1
- package/dist/types/sets/characters.d.ts +3 -2
- package/dist/types/sets/checkbox.d.ts +1 -1
- package/dist/types/sets/chevron.d.ts +1 -1
- package/dist/types/sets/condensed.d.ts +1 -1
- package/dist/types/sets/copy.d.ts +1 -1
- package/dist/types/sets/eye.d.ts +1 -1
- package/dist/types/sets/folder.d.ts +1 -1
- package/dist/types/sets/handwritten.d.ts +1 -1
- package/dist/types/sets/lock.d.ts +1 -1
- package/dist/types/sets/media.d.ts +1 -1
- package/dist/types/sets/menu.d.ts +1 -1
- package/dist/types/sets/mic.d.ts +1 -1
- package/dist/types/sets/radio.d.ts +1 -1
- package/dist/types/sets/round.d.ts +1 -1
- package/dist/types/sets/shapes.d.ts +4 -1
- package/dist/types/sets/slim.d.ts +1 -1
- package/dist/types/sets/square.d.ts +1 -1
- package/dist/types/sets/symbols.d.ts +38 -0
- package/dist/types/sets/theme.d.ts +1 -1
- package/dist/types/sets/toggle.d.ts +1 -1
- package/dist/types/sets/volume.d.ts +1 -1
- package/dist/types/sets/weather.d.ts +1 -1
- package/dist/types/sets/wifi.d.ts +1 -1
- package/dist/types/text.d.ts +9 -20
- package/package.json +95 -3
- package/dist/morphico.mjs +0 -4642
|
@@ -24,5 +24,3 @@ export declare const iconSets: {
|
|
|
24
24
|
battery: IconSet;
|
|
25
25
|
};
|
|
26
26
|
export type IconSetName = keyof typeof iconSets;
|
|
27
|
-
/** A set given by name or as a set object, optionally with sharper corners (`roundness` 0 = sharp … 1 = own). */
|
|
28
|
-
export declare const resolveIconSet: (set?: IconSetName | IconSet, roundness?: number) => IconSet;
|
package/dist/types/clip.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MorphOptions, MorphResult } from './morph.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ClipShape } from './sets/shapes.js';
|
|
3
3
|
/** A length: a number = % (of the element's width for x and size, of its height for y), or `'40%'` / `'120px'`. */
|
|
4
4
|
export type Length = number | string;
|
|
5
5
|
/** Only a band along the shape's edge shows. */
|
|
@@ -15,7 +15,7 @@ export interface ClipChanges {
|
|
|
15
15
|
x?: Length;
|
|
16
16
|
/** Centre of the shape, from the element's top edge (default 50 = the middle). */
|
|
17
17
|
y?: Length;
|
|
18
|
-
/** Side of the shape's square (default:
|
|
18
|
+
/** Side of the shape's square (default: 70 % of the element's shorter side). */
|
|
19
19
|
size?: Length;
|
|
20
20
|
/** Turn in degrees, clockwise; absolute (`rotation: 360` ends one full turn from 0). */
|
|
21
21
|
rotation?: number;
|
|
@@ -26,32 +26,22 @@ export interface ClipChanges {
|
|
|
26
26
|
/** `true` = the other way round: the shape (or band) is a hole, the rest of the element shows (not animated). */
|
|
27
27
|
inverted?: boolean;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
30
|
-
/** The shape set (default: the built-in shapes, based on Lucide). */
|
|
31
|
-
set?: IconSet;
|
|
32
|
-
/** The shape shown first (default `'circle'`). */
|
|
33
|
-
state?: string;
|
|
34
|
-
}
|
|
29
|
+
export type ClipOptions = ClipChanges & MorphOptions;
|
|
35
30
|
export interface ClipChangeOptions extends ClipChanges, MorphOptions {
|
|
36
31
|
/** Called when the change ends, with the same result the promise resolves to. */
|
|
37
32
|
onEnd?: (result: MorphResult) => void;
|
|
38
33
|
}
|
|
39
34
|
export interface Clip {
|
|
40
|
-
/** The shape shown, or being morphed to. */
|
|
41
|
-
readonly state: string;
|
|
42
35
|
/**
|
|
43
36
|
* Morphs to the shape `state` and animates the given changes along (move, resize, turn, roundness), or — called with
|
|
44
37
|
* only an object — animates those changes and keeps the shape. The promise resolves when it ends; an interrupted
|
|
45
|
-
* change resolves with `interrupted: true`. Without animation when the user prefers reduced motion
|
|
38
|
+
* change resolves with `interrupted: true`. Without animation when the user prefers reduced motion; `duration: 0`
|
|
39
|
+
* jumps (e.g. while a slider is dragged).
|
|
46
40
|
*/
|
|
47
|
-
to(state:
|
|
41
|
+
to(state: ClipShape, options?: ClipChangeOptions): Promise<MorphResult>;
|
|
48
42
|
to(changes: ClipChangeOptions): Promise<MorphResult>;
|
|
49
|
-
/** Jumps (no animation), e.g. while a slider is dragged. Stops a running change (it resolves as interrupted). */
|
|
50
|
-
set(changes: ClipChanges & {
|
|
51
|
-
state?: string;
|
|
52
|
-
}): void;
|
|
53
43
|
/** Stops, removes the hidden <svg> and gives the element back its own clip-path / mask. */
|
|
54
44
|
destroy(): void;
|
|
55
45
|
}
|
|
56
|
-
/** Cuts `element` out by a morphing shape. */
|
|
57
|
-
export declare const clip: (element: HTMLElement | SVGElement, options?: ClipOptions) => Clip;
|
|
46
|
+
/** Cuts `element` out by a morphing shape, `init` first. */
|
|
47
|
+
export declare const clip: (element: HTMLElement | SVGElement, init: ClipShape, options?: ClipOptions) => Clip;
|
package/dist/types/face.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { MorphOptions, MorphResult } from './morph.js';
|
|
2
2
|
import type { FaceExpression } from './sets/faces.js';
|
|
3
3
|
export interface FaceOptions extends MorphOptions {
|
|
4
|
-
/** The expression shown first (default `'normal'`). */
|
|
5
|
-
state?: FaceExpression;
|
|
6
4
|
/** Color of the pupils (default `'white'`). Brows, eyes and mouth take the CSS `color`. */
|
|
7
5
|
pupilColor?: string;
|
|
8
6
|
/** Blink by itself every few seconds (default `true`). Off when the user prefers reduced motion. */
|
|
@@ -15,8 +13,6 @@ export interface FaceChangeOptions extends MorphOptions {
|
|
|
15
13
|
onEnd?: (result: MorphResult) => void;
|
|
16
14
|
}
|
|
17
15
|
export interface Face {
|
|
18
|
-
/** The expression shown, or being morphed to. */
|
|
19
|
-
readonly state: FaceExpression;
|
|
20
16
|
/**
|
|
21
17
|
* Morphs to another expression. The promise resolves when the morph ends; an interrupted morph resolves with
|
|
22
18
|
* `interrupted: true`. Without animation when the user prefers reduced motion.
|
|
@@ -27,5 +23,5 @@ export interface Face {
|
|
|
27
23
|
/** Stops everything and removes the face from the page. */
|
|
28
24
|
destroy(): void;
|
|
29
25
|
}
|
|
30
|
-
/** Adds a morphing face (an <svg>) to `element
|
|
31
|
-
export declare const face: (element: Element, options?: FaceOptions) => Face;
|
|
26
|
+
/** Adds a morphing face (an <svg>) to `element`, showing the expression `init` first. */
|
|
27
|
+
export declare const face: (element: Element, init: FaceExpression, options?: FaceOptions) => Face;
|
package/dist/types/icon.d.ts
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import type { IconSetName } from './iconSets.js';
|
|
2
1
|
import type { MorphOptions, MorphResult } from './morph.js';
|
|
3
2
|
import type { StyleOptions } from './svg.js';
|
|
4
3
|
import type { IconSet } from './types.js';
|
|
5
4
|
export interface IconOptions extends MorphOptions, StyleOptions {
|
|
6
|
-
/**
|
|
7
|
-
set
|
|
5
|
+
/** The set, e.g. `digitsRound` from `'morphico/sets/round'` or `iconsWeather` from `'morphico/sets/weather'`. */
|
|
6
|
+
set: IconSet;
|
|
8
7
|
/** Corner roundness: 0 = sharp … 1 = the icon's own corners (default, also the maximum). Icon sets only. */
|
|
9
8
|
roundness?: number;
|
|
10
|
-
/** The state shown first (default: empty, `' '`). */
|
|
11
|
-
state?: string;
|
|
12
9
|
/** CSS width and height of the icon (default `'1em'`: it follows the font size). */
|
|
13
10
|
size?: string;
|
|
14
11
|
}
|
|
15
|
-
export interface
|
|
12
|
+
export interface IconChangeOptions extends MorphOptions {
|
|
16
13
|
/** Called when the morph ends, with the same result the promise resolves to. */
|
|
17
14
|
onEnd?: (result: MorphResult) => void;
|
|
18
15
|
}
|
|
19
16
|
export interface Icon {
|
|
20
|
-
/** The state shown, or being morphed to. */
|
|
21
|
-
readonly state: string;
|
|
22
17
|
/**
|
|
23
18
|
* Morphs to `state` (`'0'`…`'9'`, `'-'`, or `' '` for empty). The promise resolves when the morph ends;
|
|
24
19
|
* an interrupted morph resolves with `interrupted: true`. Without animation when the user prefers reduced motion.
|
|
25
20
|
*/
|
|
26
|
-
to(state: string, options?:
|
|
21
|
+
to(state: string, options?: IconChangeOptions): Promise<MorphResult>;
|
|
27
22
|
/** Stops any morph and removes the icon from the page. */
|
|
28
23
|
destroy(): void;
|
|
29
24
|
}
|
|
30
|
-
/** Adds a morphing icon (an <svg>) to `element
|
|
31
|
-
export declare const icon: (element: Element, options
|
|
25
|
+
/** Adds a morphing icon (an <svg>) to `element`, showing `init` first (`''` or `' '` = empty). */
|
|
26
|
+
export declare const icon: (element: Element, init: string, options: IconOptions) => Icon;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,18 +2,17 @@ export { clip } from './clip.js';
|
|
|
2
2
|
export { easings } from './engine.js';
|
|
3
3
|
export { face } from './face.js';
|
|
4
4
|
export { icon } from './icon.js';
|
|
5
|
-
export { iconSets } from './iconSets.js';
|
|
6
5
|
export { faceExpressionNames } from './sets/faces.js';
|
|
6
|
+
export { clipShapeNames } from './sets/shapes.js';
|
|
7
7
|
export { text } from './text.js';
|
|
8
8
|
export type { Clip, ClipChangeOptions, ClipChanges, ClipOptions, ClipOutline, Length } from './clip.js';
|
|
9
9
|
export type { Easing } from './engine.js';
|
|
10
10
|
export type { Face, FaceChangeOptions, FaceOptions } from './face.js';
|
|
11
|
-
export type {
|
|
12
|
-
export type { IconSetName } from './iconSets.js';
|
|
11
|
+
export type { Icon, IconChangeOptions, IconOptions } from './icon.js';
|
|
13
12
|
export type { EasingName, MorphOptions, MorphResult } from './morph.js';
|
|
14
13
|
export type { FaceExpression } from './sets/faces.js';
|
|
14
|
+
export type { ClipShape } from './sets/shapes.js';
|
|
15
15
|
export type { StyleOptions } from './svg.js';
|
|
16
|
-
export type {
|
|
17
|
-
export type { IconSet, TextLayout } from './types.js';
|
|
16
|
+
export type { Text, TextChangeOptions, TextOptions } from './text.js';
|
|
18
17
|
/** Package version, e.g. "0.1.0" (tools/build.ts replaces 'dev'). */
|
|
19
18
|
export declare const version: string;
|
package/dist/types/morph.d.ts
CHANGED
|
@@ -3,20 +3,20 @@ import type { Easing } from './engine.js';
|
|
|
3
3
|
import type { IconSet, PathNumbers } from './types.js';
|
|
4
4
|
export type EasingName = keyof typeof easings;
|
|
5
5
|
export interface MorphOptions {
|
|
6
|
-
/** Length of a morph in milliseconds (default
|
|
6
|
+
/** Length of a morph in milliseconds (default 300). */
|
|
7
7
|
duration?: number;
|
|
8
8
|
/** An easing name or your own function `(progress) => easedProgress` (default `'easeInOutCubic'`). */
|
|
9
9
|
easing?: EasingName | Easing;
|
|
10
10
|
}
|
|
11
11
|
export interface MorphResult {
|
|
12
|
-
/** The state the morph was heading to. */
|
|
12
|
+
/** The state the morph was heading to (for text(): the text). */
|
|
13
13
|
state: string;
|
|
14
14
|
/** `true` when a newer morph (or `destroy()`) took over before this one finished. */
|
|
15
15
|
interrupted: boolean;
|
|
16
16
|
}
|
|
17
17
|
/** The empty state: nothing is drawn. Shapes grow out of it and shrink into it while fading. */
|
|
18
18
|
export declare const EMPTY_STATE = " ";
|
|
19
|
-
export declare const DEFAULT_DURATION =
|
|
19
|
+
export declare const DEFAULT_DURATION = 300;
|
|
20
20
|
export declare const shapesOf: (iconSet: IconSet) => Record<string, PathNumbers>;
|
|
21
21
|
export declare const hasState: (iconSet: IconSet, state: string) => boolean;
|
|
22
22
|
export declare const prefersReducedMotion: () => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IconSet } from './types.js';
|
|
2
|
+
/** The set, optionally with sharper corners (`roundness` 0 = sharp … 1 = its own). */
|
|
3
|
+
export declare const resolveIconSet: (iconSet: IconSet, roundness?: number) => IconSet;
|
|
4
|
+
/** The `set` option checked: a set object (names like `'weather'` were accepted before 0.5.0 — say what to do now). */
|
|
5
|
+
export declare const checkedIconSet: (set: unknown, functionName: string) => IconSet;
|
|
6
|
+
/** The second argument: what is shown first. Before 0.5.0 the options came second (with the first state inside) — say
|
|
7
|
+
* so instead of failing somewhere deeper. */
|
|
8
|
+
export declare const checkedInit: (init: unknown, functionName: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsBattery: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsBell: IconSet;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { SymbolStyle } from './symbols.js';
|
|
1
2
|
import type { IconSet, TextLayout } from '../types.js';
|
|
2
|
-
/** Adds `-` `/` `.` `,` `:` to a digit set (which needs a text layout) as morphing states. */
|
|
3
|
+
/** Adds `-` `/` `.` `,` `:` and the symbols (in `symbolStyle`) to a digit set (which needs a text layout) as morphing states. */
|
|
3
4
|
export declare const withTextCharacters: (iconSet: IconSet & {
|
|
4
5
|
textLayout: TextLayout;
|
|
5
|
-
}) => IconSet;
|
|
6
|
+
}, symbolStyle: SymbolStyle) => IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsCheckbox: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsChevron: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const digitsCondensed: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsCopy: IconSet;
|
package/dist/types/sets/eye.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsEye: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsFolder: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const digitsHandwritten: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsLock: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsMedia: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsMenu: IconSet;
|
package/dist/types/sets/mic.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsMic: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsRadio: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const digitsRound: IconSet;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { IconSet, Stroke } from '../types.js';
|
|
2
|
+
/** The names of clip()'s shapes (TypeScript checks the outlines below have exactly these). */
|
|
3
|
+
export declare const clipShapeNames: readonly ['circle', 'ellipse', 'heart', 'sparkle', 'astroid', 'bookmark', 'shield', 'moon', 'tag', 'square', 'badge', 'triangle', 'droplet', 'pentagon', 'hexagon', 'octagon', 'squircle', 'star', 'rectangle-horizontal', 'message-circle', 'message-square', 'cloud', 'puzzle', 'club'];
|
|
4
|
+
export type ClipShape = typeof clipShapeNames[number];
|
|
2
5
|
/** The shapes as Lucide draws them (Lucide coordinates); the set's states are made from these. */
|
|
3
|
-
export declare const lucideShapeOutlines: Record<
|
|
6
|
+
export declare const lucideShapeOutlines: Record<ClipShape, Stroke[]>;
|
|
4
7
|
/** The shape set of clip(): states `circle`, `ellipse`, `heart` … `puzzle` (see `lucideShapeOutlines`). */
|
|
5
8
|
export declare const clipShapes: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const digitsSlim: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const digitsSquare: IconSet;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PairLayout, Stroke } from '../types.js';
|
|
2
|
+
/** Where a set's digits stand (middle of the line) and how its corners look. */
|
|
3
|
+
export interface SymbolStyle {
|
|
4
|
+
left: number;
|
|
5
|
+
right: number;
|
|
6
|
+
top: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
/** `'round'` = elliptical bowls; a number = rounded corners with that radius. */
|
|
9
|
+
corners: 'round' | number;
|
|
10
|
+
}
|
|
11
|
+
/** The pieces of one symbol: piece 1, and the optional pieces 2 and 3 (left out = a copy of piece 1, invisible). */
|
|
12
|
+
export type SymbolPieces = [Stroke[], Stroke[]?, Stroke[]?];
|
|
13
|
+
/** The symbols of a set, plus alternative tracings (the same look drawn in another order) used by some pairs. */
|
|
14
|
+
export interface SymbolDrawings {
|
|
15
|
+
pieces: Record<string, SymbolPieces>;
|
|
16
|
+
firstPieceTracings: Record<string, Stroke[]>;
|
|
17
|
+
secondPieceTracings: Record<string, Stroke[]>;
|
|
18
|
+
thirdPieceTracings: Record<string, Stroke[]>;
|
|
19
|
+
}
|
|
20
|
+
type PairLayouts = Record<string, Record<string, PairLayout>>;
|
|
21
|
+
/**
|
|
22
|
+
* How symbol pairs lay out their pieces (first, second, third piece), from the user's ratings (2026-11-03; pairs rated
|
|
23
|
+
* good use the default and are left out):
|
|
24
|
+
* - `+` → `€` / `£`: the upright bar bends into the C / the £'s line, the cross bar becomes the bar (tracings swap
|
|
25
|
+
* which of the two pieces draws which bar).
|
|
26
|
+
* - `%` → `$` / `€` / `£`: the slash runs from the top right, where S, C and the £'s hook start; the rings are pressed
|
|
27
|
+
* flat onto the bars (`flatten`, as digits onto `-`); the lower ring, where `$` / `£` have no bar, is erased like a pen
|
|
28
|
+
* in the first 60 % (`draw`, as the weather's rays) instead of shrinking into a dot.
|
|
29
|
+
* - `£` ↔ `€`: the £'s base is drawn out to the left first, ending at the right like the C (with `$` it ends at the
|
|
30
|
+
* left like the S).
|
|
31
|
+
* - `£` / `+` → `€`: both bars of `€` come out of the one bar of `£` / `+` (the crossbar / the cross bar), which
|
|
32
|
+
* traces its third piece as a hidden copy of that bar (user: the two lines must merge into one; growing out of the
|
|
33
|
+
* resting point in the middle showed as a blob, drawing the lower bar in like a pen didn't merge).
|
|
34
|
+
*/
|
|
35
|
+
export declare const symbolPairLayouts: [PairLayouts, PairLayouts, PairLayouts];
|
|
36
|
+
/** `+` `%` `$` `€` `£` drawn in a set's style. */
|
|
37
|
+
export declare const symbolStrokes: (style: SymbolStyle) => SymbolDrawings;
|
|
38
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsTheme: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsToggle: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsVolume: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsWeather: IconSet;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IconSet } from '../types.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const iconsWifi: IconSet;
|
package/dist/types/text.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { MorphOptions } from './morph.js';
|
|
1
|
+
import type { MorphOptions, MorphResult } from './morph.js';
|
|
3
2
|
import type { StyleOptions } from './svg.js';
|
|
4
3
|
import type { IconSet } from './types.js';
|
|
5
4
|
export interface TextOptions extends MorphOptions, StyleOptions {
|
|
6
|
-
/** A
|
|
7
|
-
set
|
|
8
|
-
/** The text shown first (default: empty). */
|
|
9
|
-
value?: string;
|
|
5
|
+
/** A digit set, e.g. `digitsRound` from `'morphico/sets/round'`. */
|
|
6
|
+
set: IconSet;
|
|
10
7
|
/** CSS height of the line (default `'1em'`: it follows the font size). */
|
|
11
8
|
size?: string;
|
|
12
9
|
/** Width of a digit cell in grid units, where a digit is 16 high (default: the set's own). */
|
|
@@ -14,28 +11,20 @@ export interface TextOptions extends MorphOptions, StyleOptions {
|
|
|
14
11
|
/** Gap between cells in grid units (default: the set's own). The CSS variable `--morphico-spacing` overrides it. */
|
|
15
12
|
spacing?: number;
|
|
16
13
|
}
|
|
17
|
-
export interface
|
|
18
|
-
/** The text the change was heading to. */
|
|
19
|
-
value: string;
|
|
20
|
-
/** `true` when a newer `set()` (or `destroy()`) took over before every digit finished. */
|
|
21
|
-
interrupted: boolean;
|
|
22
|
-
}
|
|
23
|
-
export interface SetOptions extends MorphOptions {
|
|
14
|
+
export interface TextChangeOptions extends MorphOptions {
|
|
24
15
|
/** Called when every changed digit has finished, with the same result the promise resolves to. */
|
|
25
|
-
onEnd?: (result:
|
|
16
|
+
onEnd?: (result: MorphResult) => void;
|
|
26
17
|
}
|
|
27
18
|
export interface Text {
|
|
28
|
-
/** The text shown, or being morphed to (after unsupported characters were removed). */
|
|
29
|
-
readonly value: string;
|
|
30
19
|
/**
|
|
31
|
-
*
|
|
20
|
+
* Morphs to `value`. Unsupported characters are removed first. If the length and every cell's width stay the same,
|
|
32
21
|
* the changed characters morph; otherwise the line is rebuilt without animation. Cells: digits, space and `-` are
|
|
33
22
|
* one width, `:` `.` `,` half of it, `/` 0.7 of it — so `5` ↔ `-` or `.` ↔ `,` morph, `5` ↔ `:` rebuilds.
|
|
34
23
|
* Pad with spaces (e.g. `String(count).padStart(3, ' ')`) to keep counters morphing.
|
|
35
24
|
*/
|
|
36
|
-
|
|
25
|
+
to(value: string, options?: TextChangeOptions): Promise<MorphResult>;
|
|
37
26
|
/** Stops all morphs and removes the line from the page. */
|
|
38
27
|
destroy(): void;
|
|
39
28
|
}
|
|
40
|
-
/** Adds a line of morphing characters (a <span> of <svg> cells) to `element
|
|
41
|
-
export declare const text: (element: Element, options
|
|
29
|
+
/** Adds a line of morphing characters (a <span> of <svg> cells) to `element`, showing `init` first. */
|
|
30
|
+
export declare const text: (element: Element, init: string, options: TextOptions) => Text;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "morphico",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Morphing line-art icons: smooth SVG path transitions between digits and other states. No dependencies.",
|
|
5
5
|
"license": "MIT AND ISC",
|
|
6
6
|
"author": "Raycho Ivanov",
|
|
@@ -16,10 +16,102 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/types/index.d.ts",
|
|
19
|
-
"default": "./dist/
|
|
19
|
+
"default": "./dist/esm/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./all": {
|
|
22
|
+
"types": "./dist/types/all.d.ts",
|
|
23
|
+
"default": "./dist/esm/all.js"
|
|
24
|
+
},
|
|
25
|
+
"./sets/round": {
|
|
26
|
+
"types": "./dist/types/sets/round.d.ts",
|
|
27
|
+
"default": "./dist/esm/sets/round.js"
|
|
28
|
+
},
|
|
29
|
+
"./sets/square": {
|
|
30
|
+
"types": "./dist/types/sets/square.d.ts",
|
|
31
|
+
"default": "./dist/esm/sets/square.js"
|
|
32
|
+
},
|
|
33
|
+
"./sets/condensed": {
|
|
34
|
+
"types": "./dist/types/sets/condensed.d.ts",
|
|
35
|
+
"default": "./dist/esm/sets/condensed.js"
|
|
36
|
+
},
|
|
37
|
+
"./sets/slim": {
|
|
38
|
+
"types": "./dist/types/sets/slim.d.ts",
|
|
39
|
+
"default": "./dist/esm/sets/slim.js"
|
|
40
|
+
},
|
|
41
|
+
"./sets/handwritten": {
|
|
42
|
+
"types": "./dist/types/sets/handwritten.d.ts",
|
|
43
|
+
"default": "./dist/esm/sets/handwritten.js"
|
|
44
|
+
},
|
|
45
|
+
"./sets/media": {
|
|
46
|
+
"types": "./dist/types/sets/media.d.ts",
|
|
47
|
+
"default": "./dist/esm/sets/media.js"
|
|
48
|
+
},
|
|
49
|
+
"./sets/menu": {
|
|
50
|
+
"types": "./dist/types/sets/menu.d.ts",
|
|
51
|
+
"default": "./dist/esm/sets/menu.js"
|
|
52
|
+
},
|
|
53
|
+
"./sets/checkbox": {
|
|
54
|
+
"types": "./dist/types/sets/checkbox.d.ts",
|
|
55
|
+
"default": "./dist/esm/sets/checkbox.js"
|
|
56
|
+
},
|
|
57
|
+
"./sets/radio": {
|
|
58
|
+
"types": "./dist/types/sets/radio.d.ts",
|
|
59
|
+
"default": "./dist/esm/sets/radio.js"
|
|
60
|
+
},
|
|
61
|
+
"./sets/folder": {
|
|
62
|
+
"types": "./dist/types/sets/folder.d.ts",
|
|
63
|
+
"default": "./dist/esm/sets/folder.js"
|
|
64
|
+
},
|
|
65
|
+
"./sets/theme": {
|
|
66
|
+
"types": "./dist/types/sets/theme.d.ts",
|
|
67
|
+
"default": "./dist/esm/sets/theme.js"
|
|
68
|
+
},
|
|
69
|
+
"./sets/weather": {
|
|
70
|
+
"types": "./dist/types/sets/weather.d.ts",
|
|
71
|
+
"default": "./dist/esm/sets/weather.js"
|
|
72
|
+
},
|
|
73
|
+
"./sets/eye": {
|
|
74
|
+
"types": "./dist/types/sets/eye.d.ts",
|
|
75
|
+
"default": "./dist/esm/sets/eye.js"
|
|
76
|
+
},
|
|
77
|
+
"./sets/volume": {
|
|
78
|
+
"types": "./dist/types/sets/volume.d.ts",
|
|
79
|
+
"default": "./dist/esm/sets/volume.js"
|
|
80
|
+
},
|
|
81
|
+
"./sets/toggle": {
|
|
82
|
+
"types": "./dist/types/sets/toggle.d.ts",
|
|
83
|
+
"default": "./dist/esm/sets/toggle.js"
|
|
84
|
+
},
|
|
85
|
+
"./sets/lock": {
|
|
86
|
+
"types": "./dist/types/sets/lock.d.ts",
|
|
87
|
+
"default": "./dist/esm/sets/lock.js"
|
|
88
|
+
},
|
|
89
|
+
"./sets/bell": {
|
|
90
|
+
"types": "./dist/types/sets/bell.d.ts",
|
|
91
|
+
"default": "./dist/esm/sets/bell.js"
|
|
92
|
+
},
|
|
93
|
+
"./sets/mic": {
|
|
94
|
+
"types": "./dist/types/sets/mic.d.ts",
|
|
95
|
+
"default": "./dist/esm/sets/mic.js"
|
|
96
|
+
},
|
|
97
|
+
"./sets/chevron": {
|
|
98
|
+
"types": "./dist/types/sets/chevron.d.ts",
|
|
99
|
+
"default": "./dist/esm/sets/chevron.js"
|
|
100
|
+
},
|
|
101
|
+
"./sets/copy": {
|
|
102
|
+
"types": "./dist/types/sets/copy.d.ts",
|
|
103
|
+
"default": "./dist/esm/sets/copy.js"
|
|
104
|
+
},
|
|
105
|
+
"./sets/wifi": {
|
|
106
|
+
"types": "./dist/types/sets/wifi.d.ts",
|
|
107
|
+
"default": "./dist/esm/sets/wifi.js"
|
|
108
|
+
},
|
|
109
|
+
"./sets/battery": {
|
|
110
|
+
"types": "./dist/types/sets/battery.d.ts",
|
|
111
|
+
"default": "./dist/esm/sets/battery.js"
|
|
20
112
|
}
|
|
21
113
|
},
|
|
22
|
-
"module": "./dist/
|
|
114
|
+
"module": "./dist/esm/index.js",
|
|
23
115
|
"types": "./dist/types/index.d.ts",
|
|
24
116
|
"jsdelivr": "./dist/morphico.js",
|
|
25
117
|
"unpkg": "./dist/morphico.js",
|