@supermousejs/icon 2.0.1 → 2.0.2
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/CHANGELOG.md +9 -0
- package/README.md +4 -0
- package/package.json +3 -3
- package/src/index.ts +51 -51
- package/tsconfig.json +17 -17
- package/vite.config.ts +25 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @supermousejs/icon
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ae219a0: Update READMEs with correct link to documentation
|
|
8
|
+
- Updated dependencies [ae219a0]
|
|
9
|
+
- @supermousejs/utils@2.0.2
|
|
10
|
+
- @supermousejs/core@2.0.2
|
|
11
|
+
|
|
3
12
|
## 2.0.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supermousejs/icon",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"main": "dist/index.umd.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@supermousejs/core": "2.0.
|
|
9
|
-
"@supermousejs/utils": "2.0.
|
|
8
|
+
"@supermousejs/core": "2.0.2",
|
|
9
|
+
"@supermousejs/utils": "2.0.2"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {},
|
|
12
12
|
"peerDependencies": {},
|
package/src/index.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import type { ValueOrGetter } from '@supermousejs/core';
|
|
2
|
-
import { definePlugin, normalize, dom, Layers } from '@supermousejs/utils';
|
|
3
|
-
|
|
4
|
-
export interface IconOptions {
|
|
5
|
-
name?: string;
|
|
6
|
-
isEnabled?: boolean;
|
|
7
|
-
/** SVG Content String */
|
|
8
|
-
svg: string;
|
|
9
|
-
/** Size in pixels (default 24) */
|
|
10
|
-
size?: ValueOrGetter<number>;
|
|
11
|
-
/** CSS Color (default black) */
|
|
12
|
-
color?: ValueOrGetter<string>;
|
|
13
|
-
opacity?: ValueOrGetter<number>;
|
|
14
|
-
/** Offset [x, y] from cursor center */
|
|
15
|
-
offset?: [number, number];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Icon = (options: IconOptions) => {
|
|
19
|
-
const getSize = normalize(options.size, 24);
|
|
20
|
-
const getOpacity = normalize(options.opacity, 1);
|
|
21
|
-
const getColor = normalize(options.color, 'black');
|
|
22
|
-
const [offX, offY] = options.offset || [0, 0];
|
|
23
|
-
|
|
24
|
-
return definePlugin<HTMLDivElement, IconOptions>({
|
|
25
|
-
name: options.name || 'icon',
|
|
26
|
-
|
|
27
|
-
create: () => {
|
|
28
|
-
const el = dom.createActor('div') as HTMLDivElement;
|
|
29
|
-
el.style.zIndex = Layers.CURSOR;
|
|
30
|
-
el.style.display = 'flex';
|
|
31
|
-
el.style.alignItems = 'center';
|
|
32
|
-
el.style.justifyContent = 'center';
|
|
33
|
-
el.innerHTML = options.svg;
|
|
34
|
-
return el;
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
styles: {
|
|
38
|
-
color: 'color'
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
update: (app, el) => {
|
|
42
|
-
const size = getSize(app.state);
|
|
43
|
-
dom.setStyle(el, 'width', `${size}px`);
|
|
44
|
-
dom.setStyle(el, 'height', `${size}px`);
|
|
45
|
-
dom.setStyle(el, 'opacity', String(getOpacity(app.state)));
|
|
46
|
-
dom.setStyle(el, 'color', getColor(app.state));
|
|
47
|
-
|
|
48
|
-
const { x, y } = app.state.smooth;
|
|
49
|
-
dom.setTransform(el, x + offX, y + offY, 0);
|
|
50
|
-
}
|
|
51
|
-
}, options);
|
|
1
|
+
import type { ValueOrGetter } from '@supermousejs/core';
|
|
2
|
+
import { definePlugin, normalize, dom, Layers } from '@supermousejs/utils';
|
|
3
|
+
|
|
4
|
+
export interface IconOptions {
|
|
5
|
+
name?: string;
|
|
6
|
+
isEnabled?: boolean;
|
|
7
|
+
/** SVG Content String */
|
|
8
|
+
svg: string;
|
|
9
|
+
/** Size in pixels (default 24) */
|
|
10
|
+
size?: ValueOrGetter<number>;
|
|
11
|
+
/** CSS Color (default black) */
|
|
12
|
+
color?: ValueOrGetter<string>;
|
|
13
|
+
opacity?: ValueOrGetter<number>;
|
|
14
|
+
/** Offset [x, y] from cursor center */
|
|
15
|
+
offset?: [number, number];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Icon = (options: IconOptions) => {
|
|
19
|
+
const getSize = normalize(options.size, 24);
|
|
20
|
+
const getOpacity = normalize(options.opacity, 1);
|
|
21
|
+
const getColor = normalize(options.color, 'black');
|
|
22
|
+
const [offX, offY] = options.offset || [0, 0];
|
|
23
|
+
|
|
24
|
+
return definePlugin<HTMLDivElement, IconOptions>({
|
|
25
|
+
name: options.name || 'icon',
|
|
26
|
+
|
|
27
|
+
create: () => {
|
|
28
|
+
const el = dom.createActor('div') as HTMLDivElement;
|
|
29
|
+
el.style.zIndex = Layers.CURSOR;
|
|
30
|
+
el.style.display = 'flex';
|
|
31
|
+
el.style.alignItems = 'center';
|
|
32
|
+
el.style.justifyContent = 'center';
|
|
33
|
+
el.innerHTML = options.svg;
|
|
34
|
+
return el;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
styles: {
|
|
38
|
+
color: 'color'
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
update: (app, el) => {
|
|
42
|
+
const size = getSize(app.state);
|
|
43
|
+
dom.setStyle(el, 'width', `${size}px`);
|
|
44
|
+
dom.setStyle(el, 'height', `${size}px`);
|
|
45
|
+
dom.setStyle(el, 'opacity', String(getOpacity(app.state)));
|
|
46
|
+
dom.setStyle(el, 'color', getColor(app.state));
|
|
47
|
+
|
|
48
|
+
const { x, y } = app.state.smooth;
|
|
49
|
+
dom.setTransform(el, x + offX, y + offY, 0);
|
|
50
|
+
}
|
|
51
|
+
}, options);
|
|
52
52
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"src"
|
|
5
|
-
],
|
|
6
|
-
"compilerOptions": {
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"baseUrl": ".",
|
|
9
|
-
"paths": {
|
|
10
|
-
"@supermousejs/core": [
|
|
11
|
-
"../core/src/index.ts"
|
|
12
|
-
],
|
|
13
|
-
"@supermousejs/utils": [
|
|
14
|
-
"../utils/src/index.ts"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"src"
|
|
5
|
+
],
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@supermousejs/core": [
|
|
11
|
+
"../core/src/index.ts"
|
|
12
|
+
],
|
|
13
|
+
"@supermousejs/utils": [
|
|
14
|
+
"../utils/src/index.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
18
|
}
|
package/vite.config.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import dts from 'vite-plugin-dts';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = path.dirname(__filename);
|
|
8
|
-
|
|
9
|
-
export default defineConfig({
|
|
10
|
-
build: {
|
|
11
|
-
lib: {
|
|
12
|
-
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
13
|
-
name: 'SupermouseIcon',
|
|
14
|
-
fileName: (format) => format === 'es' ? 'index.mjs' : 'index.umd.js',
|
|
15
|
-
},
|
|
16
|
-
rollupOptions: {
|
|
17
|
-
external: ['@supermousejs/core', '@supermousejs/utils'],
|
|
18
|
-
output: {
|
|
19
|
-
globals: {
|
|
20
|
-
'@supermousejs/core': 'SupermouseCore'
|
|
21
|
-
, '@supermousejs/utils': 'SupermouseUtils'}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
plugins: [dts({ rollupTypes: true })]
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import dts from 'vite-plugin-dts';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
build: {
|
|
11
|
+
lib: {
|
|
12
|
+
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
13
|
+
name: 'SupermouseIcon',
|
|
14
|
+
fileName: (format) => format === 'es' ? 'index.mjs' : 'index.umd.js',
|
|
15
|
+
},
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
external: ['@supermousejs/core', '@supermousejs/utils'],
|
|
18
|
+
output: {
|
|
19
|
+
globals: {
|
|
20
|
+
'@supermousejs/core': 'SupermouseCore'
|
|
21
|
+
, '@supermousejs/utils': 'SupermouseUtils'}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
plugins: [dts({ rollupTypes: true })]
|
|
26
26
|
});
|