@supermousejs/labs 2.3.0 → 2.4.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 +86 -15
- package/dist/index.d.ts +11 -4
- package/dist/index.mjs +269 -162
- package/dist/index.umd.js +9 -9
- package/package.json +9 -5
- package/CHANGELOG.md +0 -103
- package/meta.json +0 -148
- package/src/SmartIcon.ts +0 -200
- package/src/SmartRing.ts +0 -105
- package/src/Sparkles.ts +0 -168
- package/src/TextRing.ts +0 -159
- package/src/index.ts +0 -4
- package/tsconfig.json +0 -4
- package/vite.config.ts +0 -24
package/README.md
CHANGED
|
@@ -1,45 +1,116 @@
|
|
|
1
1
|
# @supermousejs/labs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Experimentental state machines and effects for supermouse
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @supermousejs/labs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## SmartIcon
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
Advanced state machine that morphs SVGs based on semantic context.
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
10
16
|
|
|
11
17
|
```ts
|
|
12
|
-
import {
|
|
13
|
-
|
|
18
|
+
import { Supermouse } from "@supermousejs/core";
|
|
19
|
+
import { SmartIcon } from '@supermousejs/labs';
|
|
20
|
+
const app = new Supermouse();
|
|
21
|
+
app.use(SmartIcon({ icons: { ... } }));
|
|
14
22
|
```
|
|
15
23
|
|
|
16
|
-
###
|
|
24
|
+
### Options
|
|
25
|
+
|
|
26
|
+
| Name | Type | Default | Description |
|
|
27
|
+
| --- | --- | --- | --- |
|
|
28
|
+
| icons | Record<string, string> | {} | Map of state names to SVG strings. |
|
|
29
|
+
| defaultState | string | 'default' | Initial semantic state used before any hover interaction resolves. |
|
|
30
|
+
| useSemanticTags | boolean | true | Resolve smart states from semantic HTML tags such as links and buttons. |
|
|
31
|
+
| transitionDuration | number | 200 | Morph transition time in ms. |
|
|
32
|
+
| switchDelay | number | 80 | Minimum ms a state must be requested before committing to the next icon. |
|
|
33
|
+
| size | number | 24 | Size of the icon container. |
|
|
34
|
+
| color | string | 'currentColor' | Color applied to the icon container. SVGs that use `currentColor` will inherit it. If empty, the icon keeps its original fill. |
|
|
35
|
+
| offset | [number, number] | [0, 0] | Fixed offset from the pointer position. |
|
|
36
|
+
| anchor | string | 'center' | Alignment (center, top-left, top-right, bottom-left, bottom-right). |
|
|
37
|
+
| followStrategy | 'smooth' | 'raw' | 'smooth' | Whether the icon smoothly follows the pointer or snaps to it. |
|
|
38
|
+
| rotateWithVelocity | boolean | false | Rotate the icon based on movement velocity. |
|
|
39
|
+
|
|
40
|
+
## SmartRing
|
|
17
41
|
|
|
18
42
|
A reactive ring that distorts with velocity and adapts to stuck elements.
|
|
19
43
|
|
|
44
|
+
### Usage
|
|
45
|
+
|
|
20
46
|
```ts
|
|
21
|
-
import {
|
|
22
|
-
|
|
47
|
+
import { Supermouse } from "@supermousejs/core";
|
|
48
|
+
import { SmartRing } from '@supermousejs/labs';
|
|
49
|
+
const app = new Supermouse();
|
|
50
|
+
app.use(SmartRing({ size: 24, color: '#f59e0b', enableSkew: true }));
|
|
23
51
|
```
|
|
24
52
|
|
|
25
|
-
###
|
|
53
|
+
### Options
|
|
54
|
+
|
|
55
|
+
| Name | Type | Default | Description |
|
|
56
|
+
| --- | --- | --- | --- |
|
|
57
|
+
| size | number | 20 | Base diameter. |
|
|
58
|
+
| hoverSize | number | 40 | Diameter when hovering interactive elements. |
|
|
59
|
+
| color | string | '#ffffff' | Border color. |
|
|
60
|
+
| fill | string | 'transparent' | Background fill color. |
|
|
61
|
+
| borderWidth | number | 2 | Border thickness in pixels. |
|
|
62
|
+
| mixBlendMode | string | 'difference' | CSS mix-blend-mode applied to the ring element. |
|
|
63
|
+
| enableSkew | boolean | false | Distort the ring based on velocity (stretch and rotate). |
|
|
64
|
+
|
|
65
|
+
## Sparkles
|
|
26
66
|
|
|
27
67
|
Emits particle trails based on movement velocity.
|
|
28
68
|
|
|
69
|
+
### Usage
|
|
70
|
+
|
|
29
71
|
```ts
|
|
30
|
-
import {
|
|
31
|
-
|
|
72
|
+
import { Supermouse } from "@supermousejs/core";
|
|
73
|
+
import { Sparkles } from '@supermousejs/labs';
|
|
74
|
+
const app = new Supermouse();
|
|
75
|
+
app.use(Sparkles({ color: '#f59e0b', frequency: 10 }));
|
|
32
76
|
```
|
|
33
77
|
|
|
34
|
-
###
|
|
78
|
+
### Options
|
|
79
|
+
|
|
80
|
+
| Name | Type | Default | Description |
|
|
81
|
+
| --- | --- | --- | --- |
|
|
82
|
+
| color | string | '#ff00ff' | Particle color. |
|
|
83
|
+
| count | number | 30 | Number of particles in the pool. |
|
|
84
|
+
| frequency | number | 10 | Pixels of movement required to spawn a particle. Lower values for a denser trail. |
|
|
85
|
+
| decay | number | 2.5 | Fade rate (0-1 per second). Higher values make for faster fading. |
|
|
86
|
+
| scatter | number | 5 | Random position offset for particle spawning. |
|
|
87
|
+
|
|
88
|
+
## TextRing
|
|
35
89
|
|
|
36
90
|
Rotates text around the cursor position.
|
|
37
91
|
|
|
92
|
+
### Usage
|
|
93
|
+
|
|
38
94
|
```ts
|
|
39
|
-
import {
|
|
40
|
-
|
|
95
|
+
import { Supermouse } from "@supermousejs/core";
|
|
96
|
+
import { TextRing } from '@supermousejs/labs';
|
|
97
|
+
const app = new Supermouse();
|
|
98
|
+
app.use(TextRing({ text: 'LOADING • ', radius: 40 }));
|
|
41
99
|
```
|
|
42
100
|
|
|
101
|
+
### Options
|
|
102
|
+
|
|
103
|
+
| Name | Type | Default | Description |
|
|
104
|
+
| --- | --- | --- | --- |
|
|
105
|
+
| text | string | 'SUPERMOUSE • SUPERMOUSE • ' | Text content. |
|
|
106
|
+
| radius | number | 60 | Ring radius in pixels. |
|
|
107
|
+
| fontSize | number | 12 | Text size in pixels. |
|
|
108
|
+
| speed | number | 30 | Rotation speed in degrees per second. |
|
|
109
|
+
| color | string | 'currentColor' | Text color. |
|
|
110
|
+
| opacity | number | 1 | Opacity of the rendered ring container. |
|
|
111
|
+
| className | string | '' | Optional CSS class added to the container. |
|
|
112
|
+
| spread | boolean | true | Stretch the text to fit the entire circle using cross-browser letter-spacing. |
|
|
113
|
+
|
|
43
114
|
## Documentation
|
|
44
115
|
|
|
45
116
|
Full documentation and interactive playground available at [supermouse](https://supermouse.js.org) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { ValueOrGetter } from '../packages/core/src';
|
|
|
3
3
|
|
|
4
4
|
export declare const SmartIcon: (options: SmartIconOptions) => SupermousePlugin;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare type SmartIconAnchor = "center" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
declare interface SmartIconMap {
|
|
9
9
|
[key: string]: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -16,7 +16,10 @@ export declare interface SmartIconOptions {
|
|
|
16
16
|
defaultState?: string;
|
|
17
17
|
useSemanticTags?: boolean;
|
|
18
18
|
transitionDuration?: number;
|
|
19
|
+
/** Minimum ms a state must be requested before committing. Default 80. */
|
|
20
|
+
switchDelay?: number;
|
|
19
21
|
size?: ValueOrGetter<number>;
|
|
22
|
+
/** Color applied to icons that use `currentColor` in their SVG. */
|
|
20
23
|
color?: ValueOrGetter<string>;
|
|
21
24
|
offset?: [number, number];
|
|
22
25
|
anchor?: ValueOrGetter<SmartIconAnchor>;
|
|
@@ -44,9 +47,9 @@ export declare interface SparklesOptions {
|
|
|
44
47
|
name?: string;
|
|
45
48
|
isEnabled?: boolean;
|
|
46
49
|
color?: ValueOrGetter<string>;
|
|
47
|
-
/** Number of particles
|
|
50
|
+
/** Number of particles in the pool. Default 30. */
|
|
48
51
|
count?: number;
|
|
49
|
-
/** How fast particles fade out (0
|
|
52
|
+
/** How fast particles fade out (0–1 per second). Default 2.5 (matches old 0.05 per frame at 50fps). */
|
|
50
53
|
decay?: number;
|
|
51
54
|
/** Pixels of movement required to spawn a particle. Lower = denser trail. Default 10. */
|
|
52
55
|
frequency?: number;
|
|
@@ -54,6 +57,10 @@ export declare interface SparklesOptions {
|
|
|
54
57
|
scatter?: number;
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The SVG `textlength`/`lengthAdjust` attributes don't work/work reliably on Firefox-based browsers.
|
|
62
|
+
* So this implementation uses a workaround. Report: https://bugzilla.mozilla.org/show_bug.cgi?id=569722
|
|
63
|
+
*/
|
|
57
64
|
export declare const TextRing: (options?: TextRingOptions) => SupermousePlugin;
|
|
58
65
|
|
|
59
66
|
export declare interface TextRingOptions {
|