@thesvg/ui-react 4.2.0 → 4.3.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 +23 -4
- package/dist/_anim.cjs +73 -21
- package/dist/_anim.d.ts +4 -2
- package/dist/_anim.js +72 -20
- package/dist/_make.cjs +1 -1
- package/dist/_make.d.ts +1 -1
- package/dist/_make.js +1 -1
- package/dist/icon-swap.cjs +8 -0
- package/dist/icon-swap.d.ts +9 -0
- package/dist/icon-swap.js +7 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,14 +62,25 @@ import { BellIcon, BellGlassIcon } from "@thesvg/ui-react/bell";
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
##
|
|
65
|
+
## Motion
|
|
66
66
|
|
|
67
|
-
Add `animated` to
|
|
67
|
+
Add `animated` to give an icon motion. It works on every look.
|
|
68
68
|
|
|
69
69
|
```tsx
|
|
70
|
-
<SunIcon animated />
|
|
70
|
+
<SunIcon animated /> {/* draw */}
|
|
71
|
+
<LoaderCircleIcon animated="spin" />
|
|
72
|
+
<BellIcon animated="ring" />
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
| `animated` | Motion |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `true` or `"draw"` | Pops in with a spring and draws the strokes one after another, once |
|
|
78
|
+
| `"pop"` | The spring only, once |
|
|
79
|
+
| `"bounce"` | A short hop, once |
|
|
80
|
+
| `"ring"` | A swing from the top, once. Made for a bell |
|
|
81
|
+
| `"spin"` | Turns forever. Made for loaders |
|
|
82
|
+
| `"pulse"` | Breathes forever. Made for a heart |
|
|
83
|
+
|
|
73
84
|
`ThemeIcon` is a ready-made switcher icon: a sun for light, a moon for dark and a display for system. It plays the motion each time the theme changes.
|
|
74
85
|
|
|
75
86
|
```tsx
|
|
@@ -78,7 +89,15 @@ import { ThemeIcon } from "@thesvg/ui-react";
|
|
|
78
89
|
<ThemeIcon theme={theme} size={20} /> {/* "light" | "dark" | "system" */}
|
|
79
90
|
```
|
|
80
91
|
|
|
81
|
-
|
|
92
|
+
`IconSwap` cross-fades between two icons with a small turn and scale, for a toggle like menu and close, or play and pause:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { IconSwap, MenuIcon, XIcon } from "@thesvg/ui-react";
|
|
96
|
+
|
|
97
|
+
<IconSwap active={open} off={MenuIcon} on={XIcon} size={20} />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
It is plain CSS inside the SVG: no animation library, and it stands still for people who prefer reduced motion. Import only the icons you use, for example `import { BellIcon } from "@thesvg/ui-react/bell"`. The motion code is one small helper (about 1.6 KB gzipped) shared by every icon, and an icon you never animate carries no motion CSS.
|
|
82
101
|
|
|
83
102
|
## Looks
|
|
84
103
|
|
package/dist/_anim.cjs
CHANGED
|
@@ -1,31 +1,83 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Motion for UI icons, in plain CSS inside the svg: no animation library, and it works in React, Vue, Svelte and in a
|
|
2
|
+
// standalone svg file. A preset is a name:
|
|
3
|
+
// draw pop in with a spring and draw the strokes one after another, once (what `animated` alone means)
|
|
4
|
+
// pop the spring only, once
|
|
5
|
+
// bounce a short hop, once
|
|
6
|
+
// ring a swing from the top, once (a bell)
|
|
7
|
+
// spin turns forever (a loader)
|
|
8
|
+
// pulse breathes forever (a heart)
|
|
3
9
|
// Plain ES module with no dependencies: package-builder copies it into every package as _anim.js.
|
|
4
|
-
const
|
|
10
|
+
const PRESETS = ["draw", "pop", "bounce", "ring", "spin", "pulse"];
|
|
11
|
+
|
|
12
|
+
// Icons that also ship a ready-made `<look>-animated.svg`, with the preset each one uses.
|
|
13
|
+
const ANIMATED = {
|
|
14
|
+
sun: "draw",
|
|
15
|
+
moon: "draw",
|
|
16
|
+
"theme-system": "draw",
|
|
17
|
+
"loader-circle": "spin",
|
|
18
|
+
"refresh-cw": "spin",
|
|
19
|
+
heart: "pulse",
|
|
20
|
+
bell: "ring",
|
|
21
|
+
};
|
|
22
|
+
const ANIMATED_SLUGS = Object.keys(ANIMATED);
|
|
5
23
|
|
|
6
24
|
const SHAPES = /<(path|circle|rect|line|polyline|polygon|ellipse)(?=[\s/>])/g;
|
|
7
25
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
26
|
+
const FRAMES = {
|
|
27
|
+
pop: "@keyframes ua-pop{from{transform:scale(0) rotate(-90deg);opacity:0}to{transform:none;opacity:1}}",
|
|
28
|
+
bounce: "@keyframes ua-bounce{0%{transform:translateY(0)}35%{transform:translateY(-3.5px)}65%{transform:translateY(.6px)}100%{transform:translateY(0)}}",
|
|
29
|
+
ring: "@keyframes ua-ring{0%{transform:rotate(0)}15%{transform:rotate(16deg)}30%{transform:rotate(-13deg)}45%{transform:rotate(9deg)}60%{transform:rotate(-6deg)}75%{transform:rotate(3deg)}100%{transform:rotate(0)}}",
|
|
30
|
+
spin: "@keyframes ua-spin{to{transform:rotate(360deg)}}",
|
|
31
|
+
pulse: "@keyframes ua-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.14)}}",
|
|
32
|
+
draw: "@keyframes ua-draw{to{stroke-dashoffset:0}}",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const MOTION = {
|
|
36
|
+
draw: "animation:ua-pop .6s cubic-bezier(.34,1.56,.64,1) both",
|
|
37
|
+
pop: "animation:ua-pop .6s cubic-bezier(.34,1.56,.64,1) both",
|
|
38
|
+
bounce: "animation:ua-bounce .7s cubic-bezier(.28,.84,.42,1) both",
|
|
39
|
+
ring: "transform-origin:12px 3px;animation:ua-ring 1s ease-in-out both",
|
|
40
|
+
spin: "animation:ua-spin .9s linear infinite",
|
|
41
|
+
pulse: "animation:ua-pulse 1.4s ease-in-out infinite",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const preset = (p) => (PRESETS.includes(p) ? p : "draw");
|
|
45
|
+
|
|
46
|
+
const css = (cls, name) => {
|
|
47
|
+
let out = "." + cls + "{transform-box:view-box;transform-origin:12px 12px;" + MOTION[name] + "}";
|
|
48
|
+
out += "@media (prefers-reduced-motion:reduce){." + cls + "{animation:none!important}";
|
|
49
|
+
if (name === "draw") {
|
|
50
|
+
out += "." + cls + ">g[stroke]>*{animation:none!important;stroke-dasharray:none!important;stroke-dashoffset:0!important}";
|
|
51
|
+
}
|
|
52
|
+
out += "}";
|
|
53
|
+
if (name === "draw") {
|
|
54
|
+
out += "." + cls + ">g[stroke]>*{stroke-dasharray:1 1;stroke-dashoffset:1;animation:ua-draw .55s ease-out forwards}";
|
|
55
|
+
for (let i = 1; i <= 12; i++) out += "." + cls + ">g[stroke]>:nth-child(" + i + "){animation-delay:" + (0.04 + i * 0.045).toFixed(3) + "s}";
|
|
56
|
+
out += FRAMES.draw;
|
|
57
|
+
}
|
|
58
|
+
return out + FRAMES[name === "draw" ? "pop" : name];
|
|
19
59
|
};
|
|
20
60
|
|
|
21
|
-
const wrap = (html, cls
|
|
61
|
+
const wrap = (html, cls, name) =>
|
|
62
|
+
"<style>" + css(cls, name) + '</style><g class="' + cls + '">' + (name === "draw" ? html.replace(SHAPES, '<$1 pathLength="1"') : html) + "</g>";
|
|
22
63
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Inner markup of an icon, wrapped so it moves. `kind` is a preset name, or true for draw. uid keeps two icons on a page apart.
|
|
66
|
+
* @param {string} html
|
|
67
|
+
* @param {string | number} uid
|
|
68
|
+
* @param {string | boolean} [kind]
|
|
69
|
+
* @returns {{ cls: string, html: string }}
|
|
70
|
+
*/
|
|
71
|
+
const animate = (html, uid, kind = "draw") => {
|
|
25
72
|
const cls = "ua-" + uid;
|
|
26
|
-
return { cls, html: wrap(html, cls) };
|
|
73
|
+
return { cls, html: wrap(html, cls, preset(kind)) };
|
|
27
74
|
};
|
|
28
75
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
76
|
+
/**
|
|
77
|
+
* A whole standalone svg file, moving on load.
|
|
78
|
+
* @param {string} svg
|
|
79
|
+
* @param {string} [kind]
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
const animateSvg = (svg, kind = "draw") => svg.replace(/^(<svg[^>]*>)([\s\S]*)(<\/svg>)\s*$/, (_m, open, body, close) => open + wrap(body, "ua", preset(kind)) + close);
|
|
83
|
+
module.exports = { animate, animateSvg, ANIMATED, ANIMATED_SLUGS, PRESETS };
|
package/dist/_anim.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export declare const animate: (html: string, uid: string | number) => { cls: string; html: string };
|
|
2
|
-
export declare const animateSvg: (svg: string) => string;
|
|
1
|
+
export declare const animate: (html: string, uid: string | number, kind?: string | boolean) => { cls: string; html: string };
|
|
2
|
+
export declare const animateSvg: (svg: string, kind?: string) => string;
|
|
3
3
|
export declare const ANIMATED_SLUGS: string[];
|
|
4
|
+
export declare const ANIMATED: Record<string, string>;
|
|
5
|
+
export declare const PRESETS: string[];
|
package/dist/_anim.js
CHANGED
|
@@ -1,30 +1,82 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Motion for UI icons, in plain CSS inside the svg: no animation library, and it works in React, Vue, Svelte and in a
|
|
2
|
+
// standalone svg file. A preset is a name:
|
|
3
|
+
// draw pop in with a spring and draw the strokes one after another, once (what `animated` alone means)
|
|
4
|
+
// pop the spring only, once
|
|
5
|
+
// bounce a short hop, once
|
|
6
|
+
// ring a swing from the top, once (a bell)
|
|
7
|
+
// spin turns forever (a loader)
|
|
8
|
+
// pulse breathes forever (a heart)
|
|
3
9
|
// Plain ES module with no dependencies: package-builder copies it into every package as _anim.js.
|
|
4
|
-
export const
|
|
10
|
+
export const PRESETS = ["draw", "pop", "bounce", "ring", "spin", "pulse"];
|
|
11
|
+
|
|
12
|
+
// Icons that also ship a ready-made `<look>-animated.svg`, with the preset each one uses.
|
|
13
|
+
export const ANIMATED = {
|
|
14
|
+
sun: "draw",
|
|
15
|
+
moon: "draw",
|
|
16
|
+
"theme-system": "draw",
|
|
17
|
+
"loader-circle": "spin",
|
|
18
|
+
"refresh-cw": "spin",
|
|
19
|
+
heart: "pulse",
|
|
20
|
+
bell: "ring",
|
|
21
|
+
};
|
|
22
|
+
export const ANIMATED_SLUGS = Object.keys(ANIMATED);
|
|
5
23
|
|
|
6
24
|
const SHAPES = /<(path|circle|rect|line|polyline|polygon|ellipse)(?=[\s/>])/g;
|
|
7
25
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
26
|
+
const FRAMES = {
|
|
27
|
+
pop: "@keyframes ua-pop{from{transform:scale(0) rotate(-90deg);opacity:0}to{transform:none;opacity:1}}",
|
|
28
|
+
bounce: "@keyframes ua-bounce{0%{transform:translateY(0)}35%{transform:translateY(-3.5px)}65%{transform:translateY(.6px)}100%{transform:translateY(0)}}",
|
|
29
|
+
ring: "@keyframes ua-ring{0%{transform:rotate(0)}15%{transform:rotate(16deg)}30%{transform:rotate(-13deg)}45%{transform:rotate(9deg)}60%{transform:rotate(-6deg)}75%{transform:rotate(3deg)}100%{transform:rotate(0)}}",
|
|
30
|
+
spin: "@keyframes ua-spin{to{transform:rotate(360deg)}}",
|
|
31
|
+
pulse: "@keyframes ua-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.14)}}",
|
|
32
|
+
draw: "@keyframes ua-draw{to{stroke-dashoffset:0}}",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const MOTION = {
|
|
36
|
+
draw: "animation:ua-pop .6s cubic-bezier(.34,1.56,.64,1) both",
|
|
37
|
+
pop: "animation:ua-pop .6s cubic-bezier(.34,1.56,.64,1) both",
|
|
38
|
+
bounce: "animation:ua-bounce .7s cubic-bezier(.28,.84,.42,1) both",
|
|
39
|
+
ring: "transform-origin:12px 3px;animation:ua-ring 1s ease-in-out both",
|
|
40
|
+
spin: "animation:ua-spin .9s linear infinite",
|
|
41
|
+
pulse: "animation:ua-pulse 1.4s ease-in-out infinite",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const preset = (p) => (PRESETS.includes(p) ? p : "draw");
|
|
45
|
+
|
|
46
|
+
const css = (cls, name) => {
|
|
47
|
+
let out = "." + cls + "{transform-box:view-box;transform-origin:12px 12px;" + MOTION[name] + "}";
|
|
48
|
+
out += "@media (prefers-reduced-motion:reduce){." + cls + "{animation:none!important}";
|
|
49
|
+
if (name === "draw") {
|
|
50
|
+
out += "." + cls + ">g[stroke]>*{animation:none!important;stroke-dasharray:none!important;stroke-dashoffset:0!important}";
|
|
51
|
+
}
|
|
52
|
+
out += "}";
|
|
53
|
+
if (name === "draw") {
|
|
54
|
+
out += "." + cls + ">g[stroke]>*{stroke-dasharray:1 1;stroke-dashoffset:1;animation:ua-draw .55s ease-out forwards}";
|
|
55
|
+
for (let i = 1; i <= 12; i++) out += "." + cls + ">g[stroke]>:nth-child(" + i + "){animation-delay:" + (0.04 + i * 0.045).toFixed(3) + "s}";
|
|
56
|
+
out += FRAMES.draw;
|
|
57
|
+
}
|
|
58
|
+
return out + FRAMES[name === "draw" ? "pop" : name];
|
|
19
59
|
};
|
|
20
60
|
|
|
21
|
-
const wrap = (html, cls
|
|
61
|
+
const wrap = (html, cls, name) =>
|
|
62
|
+
"<style>" + css(cls, name) + '</style><g class="' + cls + '">' + (name === "draw" ? html.replace(SHAPES, '<$1 pathLength="1"') : html) + "</g>";
|
|
22
63
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Inner markup of an icon, wrapped so it moves. `kind` is a preset name, or true for draw. uid keeps two icons on a page apart.
|
|
66
|
+
* @param {string} html
|
|
67
|
+
* @param {string | number} uid
|
|
68
|
+
* @param {string | boolean} [kind]
|
|
69
|
+
* @returns {{ cls: string, html: string }}
|
|
70
|
+
*/
|
|
71
|
+
export const animate = (html, uid, kind = "draw") => {
|
|
25
72
|
const cls = "ua-" + uid;
|
|
26
|
-
return { cls, html: wrap(html, cls) };
|
|
73
|
+
return { cls, html: wrap(html, cls, preset(kind)) };
|
|
27
74
|
};
|
|
28
75
|
|
|
29
|
-
/**
|
|
30
|
-
|
|
76
|
+
/**
|
|
77
|
+
* A whole standalone svg file, moving on load.
|
|
78
|
+
* @param {string} svg
|
|
79
|
+
* @param {string} [kind]
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
export const animateSvg = (svg, kind = "draw") => svg.replace(/^(<svg[^>]*>)([\s\S]*)(<\/svg>)\s*$/, (_m, open, body, close) => open + wrap(body, "ua", preset(kind)) + close);
|
package/dist/_make.cjs
CHANGED
|
@@ -11,7 +11,7 @@ const make = (html, name, ids) => {
|
|
|
11
11
|
const scope = scoper(ids);
|
|
12
12
|
const Icon = forwardRef(({ size = 24, shadow = 0, animated = false, style, ...props }, ref) => {
|
|
13
13
|
const uid = useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
14
|
-
return createElement("svg", { ref, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: size, height: size, overflow: "visible", style: liftOf(shadow, size) ? { ...style, filter: liftOf(shadow, size) } : style, "aria-hidden": props["aria-label"] ? undefined : true, ...props, dangerouslySetInnerHTML: { __html: scope(animated ? animate(html, uid).html : html, uid) } });
|
|
14
|
+
return createElement("svg", { ref, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: size, height: size, overflow: "visible", style: liftOf(shadow, size) ? { ...style, filter: liftOf(shadow, size) } : style, "aria-hidden": props["aria-label"] ? undefined : true, ...props, dangerouslySetInnerHTML: { __html: scope(animated ? animate(html, uid, animated).html : html, uid) } });
|
|
15
15
|
});
|
|
16
16
|
Icon.displayName = name;
|
|
17
17
|
return Icon;
|
package/dist/_make.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ForwardRefExoticComponent, RefAttributes, SVGProps } from "react";
|
|
2
|
-
export interface UiIconProps extends Omit<SVGProps<SVGSVGElement>, "ref"> { size?: number | string; /** Lift shadow under the icon: true, or an opacity from 0 to 1. Works on every look. */ shadow?: boolean | number; /**
|
|
2
|
+
export interface UiIconProps extends Omit<SVGProps<SVGSVGElement>, "ref"> { size?: number | string; /** Lift shadow under the icon: true, or an opacity from 0 to 1. Works on every look. */ shadow?: boolean | number; /** Motion: true or "draw" pops in and draws the strokes once. Also pop, bounce, ring (once) and spin, pulse (forever). */ animated?: boolean | "draw" | "pop" | "bounce" | "ring" | "spin" | "pulse" }
|
|
3
3
|
export type UiIcon = ForwardRefExoticComponent<UiIconProps & RefAttributes<SVGSVGElement>>;
|
|
4
4
|
export declare const make: (html: string, name: string, ids: string[]) => UiIcon;
|
package/dist/_make.js
CHANGED
|
@@ -11,7 +11,7 @@ export const make = (html, name, ids) => {
|
|
|
11
11
|
const scope = scoper(ids);
|
|
12
12
|
const Icon = forwardRef(({ size = 24, shadow = 0, animated = false, style, ...props }, ref) => {
|
|
13
13
|
const uid = useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
14
|
-
return createElement("svg", { ref, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: size, height: size, overflow: "visible", style: liftOf(shadow, size) ? { ...style, filter: liftOf(shadow, size) } : style, "aria-hidden": props["aria-label"] ? undefined : true, ...props, dangerouslySetInnerHTML: { __html: scope(animated ? animate(html, uid).html : html, uid) } });
|
|
14
|
+
return createElement("svg", { ref, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: size, height: size, overflow: "visible", style: liftOf(shadow, size) ? { ...style, filter: liftOf(shadow, size) } : style, "aria-hidden": props["aria-label"] ? undefined : true, ...props, dangerouslySetInnerHTML: { __html: scope(animated ? animate(html, uid, animated).html : html, uid) } });
|
|
15
15
|
});
|
|
16
16
|
Icon.displayName = name;
|
|
17
17
|
return Icon;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { createElement } = require("react");
|
|
3
|
+
const CSS = ".ui-swap{position:relative;display:inline-block}.ui-swap>svg{position:absolute;inset:0;transition:opacity .22s ease,transform .4s cubic-bezier(.34,1.56,.64,1)}.ui-swap>svg[data-on=false]{opacity:0;transform:rotate(90deg) scale(.3)}.ui-swap>svg[data-on=true]{opacity:1;transform:none}@media (prefers-reduced-motion:reduce){.ui-swap>svg{transition:none}}";
|
|
4
|
+
exports.IconSwap = ({ active = false, on: On, off: Off, size = 24, className, ...props }) =>
|
|
5
|
+
createElement("span", { className: "ui-swap" + (className ? " " + className : ""), style: { width: size, height: size } },
|
|
6
|
+
createElement("style", null, CSS),
|
|
7
|
+
createElement(Off, { ...props, size, "data-on": String(!active) }),
|
|
8
|
+
createElement(On, { ...props, size, "data-on": String(active) }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { UiIcon, UiIconProps } from "./_make.js";
|
|
3
|
+
export interface IconSwapProps extends UiIconProps {
|
|
4
|
+
/** false shows the `off` icon, true shows the `on` icon. The change cross-fades with a small turn and scale. */
|
|
5
|
+
active?: boolean;
|
|
6
|
+
on: UiIcon;
|
|
7
|
+
off: UiIcon;
|
|
8
|
+
}
|
|
9
|
+
export declare const IconSwap: (props: IconSwapProps) => ReactElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
const CSS = ".ui-swap{position:relative;display:inline-block}.ui-swap>svg{position:absolute;inset:0;transition:opacity .22s ease,transform .4s cubic-bezier(.34,1.56,.64,1)}.ui-swap>svg[data-on=false]{opacity:0;transform:rotate(90deg) scale(.3)}.ui-swap>svg[data-on=true]{opacity:1;transform:none}@media (prefers-reduced-motion:reduce){.ui-swap>svg{transition:none}}";
|
|
3
|
+
export const IconSwap = ({ active = false, on: On, off: Off, size = 24, className, ...props }) =>
|
|
4
|
+
createElement("span", { className: "ui-swap" + (className ? " " + className : ""), style: { width: size, height: size } },
|
|
5
|
+
createElement("style", null, CSS),
|
|
6
|
+
createElement(Off, { ...props, size, "data-on": String(!active) }),
|
|
7
|
+
createElement(On, { ...props, size, "data-on": String(active) }));
|
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { UiIcon, UiIconProps } from "./_make.js";
|
|
2
2
|
export type { ThemeIconProps } from "./theme-icon.js";
|
|
3
|
+
export type { IconSwapProps } from "./icon-swap.js";
|
|
3
4
|
export { ActivityIcon, ActivityGlassIcon, ActivityDuotoneIcon, ActivityOffsetIcon, ActivityFillIcon, ActivityGlassOutlineIcon, ActivityDepthIcon } from "./activity.js";
|
|
4
5
|
export { AgentErrorIcon, AgentErrorGlassIcon, AgentErrorDuotoneIcon, AgentErrorOffsetIcon, AgentErrorFillIcon, AgentErrorGlassOutlineIcon, AgentErrorDepthIcon } from "./agent-error.js";
|
|
5
6
|
export { AgentPauseIcon, AgentPauseGlassIcon, AgentPauseDuotoneIcon, AgentPauseOffsetIcon, AgentPauseFillIcon, AgentPauseGlassOutlineIcon, AgentPauseDepthIcon } from "./agent-pause.js";
|
|
@@ -374,3 +375,4 @@ export { WrenchIcon, WrenchGlassIcon, WrenchDuotoneIcon, WrenchOffsetIcon, Wrenc
|
|
|
374
375
|
export { XIcon, XGlassIcon, XDuotoneIcon, XOffsetIcon, XFillIcon, XGlassOutlineIcon, XDepthIcon } from "./x.js";
|
|
375
376
|
export { ZapIcon, ZapGlassIcon, ZapDuotoneIcon, ZapOffsetIcon, ZapFillIcon, ZapGlassOutlineIcon, ZapDepthIcon } from "./zap.js";
|
|
376
377
|
export { ThemeIcon } from "./theme-icon.js";
|
|
378
|
+
export { IconSwap } from "./icon-swap.js";
|
package/dist/index.js
CHANGED
|
@@ -372,3 +372,4 @@ export { WrenchIcon, WrenchGlassIcon, WrenchDuotoneIcon, WrenchOffsetIcon, Wrenc
|
|
|
372
372
|
export { XIcon, XGlassIcon, XDuotoneIcon, XOffsetIcon, XFillIcon, XGlassOutlineIcon, XDepthIcon } from "./x.js";
|
|
373
373
|
export { ZapIcon, ZapGlassIcon, ZapDuotoneIcon, ZapOffsetIcon, ZapFillIcon, ZapGlassOutlineIcon, ZapDepthIcon } from "./zap.js";
|
|
374
374
|
export { ThemeIcon } from "./theme-icon.js";
|
|
375
|
+
export { IconSwap } from "./icon-swap.js";
|