@fluxus-ui/icons 0.0.0-stage → 0.2.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.
@@ -0,0 +1,165 @@
1
+ /**
2
+ * What an icon is, and what it looks like in a state. No DOM here: the server,
3
+ * the build and the engine all read an icon through these. (SPEC §14.36)
4
+ */
5
+ interface Pose {
6
+ /** Another outline with the same commands: the part morphs into it. */
7
+ d?: string;
8
+ x?: number;
9
+ y?: number;
10
+ /** Degrees, around the pivot of the part. */
11
+ r?: number;
12
+ s?: number;
13
+ /** How much of the stroke is drawn, 0–1; 'p' follows the progress of the icon. */
14
+ draw?: number | 'p';
15
+ o?: number;
16
+ }
17
+ interface IconPart {
18
+ id: string;
19
+ /** Its outline at rest, on a 16 × 16 grid: absolute commands, numbers apart by single spaces (`M3 4.5 L13 4.5`). */
20
+ d: string;
21
+ /** The pivot of `r` and `s`. Default: the centre of the grid. */
22
+ c?: readonly [number, number];
23
+ /** It sets off this much later than the rest, 0–0.5 of the way. */
24
+ lag?: number;
25
+ /** Filled as well as stroked. */
26
+ fill?: boolean;
27
+ /** Its pose at rest, when it is not the plain one. */
28
+ rest?: Pose;
29
+ /** Its pose in each other state, over the one at rest. */
30
+ on?: Readonly<Record<string, Pose>>;
31
+ }
32
+ interface Kick {
33
+ /** The part it pushes; '*' is all of them. */
34
+ p: string;
35
+ k: 'x' | 'y' | 'r' | 's';
36
+ /** Speed it starts with, units per second. */
37
+ v?: number;
38
+ /** Where it ends; it must look like 0 (a full turn). Default: 0. */
39
+ to?: number;
40
+ /** It waits this long, ms. */
41
+ wait?: number;
42
+ }
43
+ interface IconDef {
44
+ name: string;
45
+ parts: readonly IconPart[];
46
+ /** Pushes by what sets them off: 'hover', 'press' or the name of a state it enters. */
47
+ kicks?: Readonly<Record<string, readonly Kick[]>>;
48
+ }
49
+ declare const REST = "rest";
50
+ interface MarkupOptions {
51
+ state?: string;
52
+ /** 0–1, for the parts that follow it. */
53
+ progress?: number;
54
+ /** Its name for a screen reader; without it the icon is decoration. */
55
+ label?: string;
56
+ className?: string;
57
+ }
58
+ /** The parts of an icon in a state, as markup. */
59
+ declare const partsMarkup: (def: IconDef, state?: string, progress?: number) => string;
60
+ /** An icon as an `<svg>`, in a state: what a server sends, and what the engine leaves at rest. */
61
+ declare const iconMarkup: (def: IconDef, { state, progress, label, className }?: MarkupOptions) => string;
62
+ /** What is wrong with an icon; nothing when it follows the rules. */
63
+ declare function validateIcon(def: IconDef): string[];
64
+
65
+ /**
66
+ * The engine of a live icon: it reads the state from the DOM and takes every
67
+ * part from the pose it is in to the one of that state, with a spring. A push
68
+ * (a hover, a press, a state it enters) is added on top and springs back.
69
+ * At rest it leaves exactly what `iconMarkup` writes. (SPEC §14.36)
70
+ */
71
+
72
+ interface IconOptions {
73
+ /** Honor prefers-reduced-motion (default: true). */
74
+ respectReducedMotion?: boolean;
75
+ }
76
+ interface IconHandle {
77
+ /** Push it as a hover, a press or a state would. */
78
+ kick(name: string): void;
79
+ destroy(): void;
80
+ }
81
+ declare function attachIcon(svg: SVGSVGElement, def: IconDef, options?: IconOptions): IconHandle;
82
+
83
+ declare const arrowDown: IconDef;
84
+
85
+ declare const arrowLeft: IconDef;
86
+
87
+ declare const arrowRight: IconDef;
88
+
89
+ declare const arrowUp: IconDef;
90
+
91
+ /** A bell that rings with the pointer. `on`: something is new, a dot says so and it rings. */
92
+ declare const bell: IconDef;
93
+
94
+ declare const calendar: IconDef;
95
+
96
+ /** A tick in a circle. From `off` the circle is drawn and then the tick is written. */
97
+ declare const check: IconDef;
98
+
99
+ /** It points down; `on`: up. */
100
+ declare const chevron: IconDef;
101
+
102
+ /** A cross that turns a little with the pointer and shrinks when pressed. */
103
+ declare const close: IconDef;
104
+
105
+ /** Two sheets; `done`: the one behind goes and a tick is written on the one in front. */
106
+ declare const copy: IconDef;
107
+
108
+ /** An exclamation in a circle. From `off` it is drawn, and it shakes once. */
109
+ declare const error: IconDef;
110
+
111
+ declare const image: IconDef;
112
+
113
+ declare const inbox: IconDef;
114
+
115
+ declare const list: IconDef;
116
+
117
+ /** A padlock. `open`: the shackle lifts and lets go on one side; with the pointer it lifts a little and drops. */
118
+ declare const lock: IconDef;
119
+
120
+ /** An arrow into a door; with the pointer it goes in a little. */
121
+ declare const login: IconDef;
122
+
123
+ declare const logout: IconDef;
124
+
125
+ /** Three lines that cross into a close mark. `on`: open. */
126
+ declare const menu: IconDef;
127
+
128
+ /** A microphone. `on`: it is listening, the capsule fills. */
129
+ declare const mic: IconDef;
130
+
131
+ /** It wobbles from its tip, as if about to write. */
132
+ declare const pencil: IconDef;
133
+
134
+ /** A play triangle whose two halves part into the bars of pause. `on`: playing. */
135
+ declare const play: IconDef;
136
+
137
+ /** A sway with the pointer; pressed, a quarter turn, which leaves a plus as it was. */
138
+ declare const plus: IconDef;
139
+
140
+ /** An arrow round a circle: a nudge with the pointer, a whole turn when pressed. */
141
+ declare const refresh: IconDef;
142
+
143
+ /** A shield with a tick; it beats with the pointer. */
144
+ declare const shield: IconDef;
145
+
146
+ /** A panel with its side bar folded; `on`: open, and the arrow turns to fold it. */
147
+ declare const sidebar: IconDef;
148
+
149
+ declare const stack: IconDef;
150
+
151
+ /** A tick. `off`: not drawn, and it is written when it comes; `mixed`: a dash. */
152
+ declare const tick: IconDef;
153
+
154
+ /** A bin whose lid lifts when the pointer comes and jumps when it is pressed. */
155
+ declare const trash: IconDef;
156
+
157
+ /** An arrow out of a tray. `busy`: the tray fills with the progress of the icon. `done`: the arrow gives way to a tick. */
158
+ declare const upload: IconDef;
159
+
160
+ declare const user: IconDef;
161
+
162
+ /** A wand and its sparks, which flare one after another. */
163
+ declare const wand: IconDef;
164
+
165
+ export { type IconDef, type IconHandle, type IconOptions, type IconPart, type Kick, type MarkupOptions, type Pose, REST, arrowDown, arrowLeft, arrowRight, arrowUp, attachIcon, bell, calendar, check, chevron, close, copy, error, iconMarkup, image, inbox, list, lock, login, logout, menu, mic, partsMarkup, pencil, play, plus, refresh, shield, sidebar, stack, tick, trash, upload, user, validateIcon, wand };
@@ -0,0 +1,165 @@
1
+ /**
2
+ * What an icon is, and what it looks like in a state. No DOM here: the server,
3
+ * the build and the engine all read an icon through these. (SPEC §14.36)
4
+ */
5
+ interface Pose {
6
+ /** Another outline with the same commands: the part morphs into it. */
7
+ d?: string;
8
+ x?: number;
9
+ y?: number;
10
+ /** Degrees, around the pivot of the part. */
11
+ r?: number;
12
+ s?: number;
13
+ /** How much of the stroke is drawn, 0–1; 'p' follows the progress of the icon. */
14
+ draw?: number | 'p';
15
+ o?: number;
16
+ }
17
+ interface IconPart {
18
+ id: string;
19
+ /** Its outline at rest, on a 16 × 16 grid: absolute commands, numbers apart by single spaces (`M3 4.5 L13 4.5`). */
20
+ d: string;
21
+ /** The pivot of `r` and `s`. Default: the centre of the grid. */
22
+ c?: readonly [number, number];
23
+ /** It sets off this much later than the rest, 0–0.5 of the way. */
24
+ lag?: number;
25
+ /** Filled as well as stroked. */
26
+ fill?: boolean;
27
+ /** Its pose at rest, when it is not the plain one. */
28
+ rest?: Pose;
29
+ /** Its pose in each other state, over the one at rest. */
30
+ on?: Readonly<Record<string, Pose>>;
31
+ }
32
+ interface Kick {
33
+ /** The part it pushes; '*' is all of them. */
34
+ p: string;
35
+ k: 'x' | 'y' | 'r' | 's';
36
+ /** Speed it starts with, units per second. */
37
+ v?: number;
38
+ /** Where it ends; it must look like 0 (a full turn). Default: 0. */
39
+ to?: number;
40
+ /** It waits this long, ms. */
41
+ wait?: number;
42
+ }
43
+ interface IconDef {
44
+ name: string;
45
+ parts: readonly IconPart[];
46
+ /** Pushes by what sets them off: 'hover', 'press' or the name of a state it enters. */
47
+ kicks?: Readonly<Record<string, readonly Kick[]>>;
48
+ }
49
+ declare const REST = "rest";
50
+ interface MarkupOptions {
51
+ state?: string;
52
+ /** 0–1, for the parts that follow it. */
53
+ progress?: number;
54
+ /** Its name for a screen reader; without it the icon is decoration. */
55
+ label?: string;
56
+ className?: string;
57
+ }
58
+ /** The parts of an icon in a state, as markup. */
59
+ declare const partsMarkup: (def: IconDef, state?: string, progress?: number) => string;
60
+ /** An icon as an `<svg>`, in a state: what a server sends, and what the engine leaves at rest. */
61
+ declare const iconMarkup: (def: IconDef, { state, progress, label, className }?: MarkupOptions) => string;
62
+ /** What is wrong with an icon; nothing when it follows the rules. */
63
+ declare function validateIcon(def: IconDef): string[];
64
+
65
+ /**
66
+ * The engine of a live icon: it reads the state from the DOM and takes every
67
+ * part from the pose it is in to the one of that state, with a spring. A push
68
+ * (a hover, a press, a state it enters) is added on top and springs back.
69
+ * At rest it leaves exactly what `iconMarkup` writes. (SPEC §14.36)
70
+ */
71
+
72
+ interface IconOptions {
73
+ /** Honor prefers-reduced-motion (default: true). */
74
+ respectReducedMotion?: boolean;
75
+ }
76
+ interface IconHandle {
77
+ /** Push it as a hover, a press or a state would. */
78
+ kick(name: string): void;
79
+ destroy(): void;
80
+ }
81
+ declare function attachIcon(svg: SVGSVGElement, def: IconDef, options?: IconOptions): IconHandle;
82
+
83
+ declare const arrowDown: IconDef;
84
+
85
+ declare const arrowLeft: IconDef;
86
+
87
+ declare const arrowRight: IconDef;
88
+
89
+ declare const arrowUp: IconDef;
90
+
91
+ /** A bell that rings with the pointer. `on`: something is new, a dot says so and it rings. */
92
+ declare const bell: IconDef;
93
+
94
+ declare const calendar: IconDef;
95
+
96
+ /** A tick in a circle. From `off` the circle is drawn and then the tick is written. */
97
+ declare const check: IconDef;
98
+
99
+ /** It points down; `on`: up. */
100
+ declare const chevron: IconDef;
101
+
102
+ /** A cross that turns a little with the pointer and shrinks when pressed. */
103
+ declare const close: IconDef;
104
+
105
+ /** Two sheets; `done`: the one behind goes and a tick is written on the one in front. */
106
+ declare const copy: IconDef;
107
+
108
+ /** An exclamation in a circle. From `off` it is drawn, and it shakes once. */
109
+ declare const error: IconDef;
110
+
111
+ declare const image: IconDef;
112
+
113
+ declare const inbox: IconDef;
114
+
115
+ declare const list: IconDef;
116
+
117
+ /** A padlock. `open`: the shackle lifts and lets go on one side; with the pointer it lifts a little and drops. */
118
+ declare const lock: IconDef;
119
+
120
+ /** An arrow into a door; with the pointer it goes in a little. */
121
+ declare const login: IconDef;
122
+
123
+ declare const logout: IconDef;
124
+
125
+ /** Three lines that cross into a close mark. `on`: open. */
126
+ declare const menu: IconDef;
127
+
128
+ /** A microphone. `on`: it is listening, the capsule fills. */
129
+ declare const mic: IconDef;
130
+
131
+ /** It wobbles from its tip, as if about to write. */
132
+ declare const pencil: IconDef;
133
+
134
+ /** A play triangle whose two halves part into the bars of pause. `on`: playing. */
135
+ declare const play: IconDef;
136
+
137
+ /** A sway with the pointer; pressed, a quarter turn, which leaves a plus as it was. */
138
+ declare const plus: IconDef;
139
+
140
+ /** An arrow round a circle: a nudge with the pointer, a whole turn when pressed. */
141
+ declare const refresh: IconDef;
142
+
143
+ /** A shield with a tick; it beats with the pointer. */
144
+ declare const shield: IconDef;
145
+
146
+ /** A panel with its side bar folded; `on`: open, and the arrow turns to fold it. */
147
+ declare const sidebar: IconDef;
148
+
149
+ declare const stack: IconDef;
150
+
151
+ /** A tick. `off`: not drawn, and it is written when it comes; `mixed`: a dash. */
152
+ declare const tick: IconDef;
153
+
154
+ /** A bin whose lid lifts when the pointer comes and jumps when it is pressed. */
155
+ declare const trash: IconDef;
156
+
157
+ /** An arrow out of a tray. `busy`: the tray fills with the progress of the icon. `done`: the arrow gives way to a tick. */
158
+ declare const upload: IconDef;
159
+
160
+ declare const user: IconDef;
161
+
162
+ /** A wand and its sparks, which flare one after another. */
163
+ declare const wand: IconDef;
164
+
165
+ export { type IconDef, type IconHandle, type IconOptions, type IconPart, type Kick, type MarkupOptions, type Pose, REST, arrowDown, arrowLeft, arrowRight, arrowUp, attachIcon, bell, calendar, check, chevron, close, copy, error, iconMarkup, image, inbox, list, lock, login, logout, menu, mic, partsMarkup, pencil, play, plus, refresh, shield, sidebar, stack, tick, trash, upload, user, validateIcon, wand };