@wecareu/icons 1.0.5 → 1.0.6
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/package.json +14 -1
- package/src/LottieView.web.tsx +69 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wecareu/icons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Sistema de ícones SVG para WeCareU Design System",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
"dist",
|
|
10
10
|
"src"
|
|
11
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./lottie": {
|
|
19
|
+
"types": "./dist/lottie.d.ts",
|
|
20
|
+
"import": "./dist/lottie.mjs",
|
|
21
|
+
"require": "./dist/lottie.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
12
24
|
"sideEffects": false,
|
|
13
25
|
"scripts": {
|
|
14
26
|
"icons:gen": "node scripts/build-icons.mjs",
|
|
@@ -32,6 +44,7 @@
|
|
|
32
44
|
"@types/react": "^18.2.0",
|
|
33
45
|
"@types/react-native": "^0.72.0",
|
|
34
46
|
"lottie-react-native": "^7.3.4",
|
|
47
|
+
"lottie-web": "^5.12.2",
|
|
35
48
|
"react": "^18.2.0",
|
|
36
49
|
"react-native": "^0.72.0",
|
|
37
50
|
"react-native-svg": "^14.1.0",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import lottie, { AnimationItem } from 'lottie-web';
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import type { ViewStyle } from 'react-native';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
import { LOTTIE_ANIMATIONS, type LottieAnimationName } from './lottie-map';
|
|
7
|
+
|
|
8
|
+
interface LottieProps {
|
|
9
|
+
autoPlay?: boolean;
|
|
10
|
+
colorFilters?: { keypath: string; color: string }[];
|
|
11
|
+
loop?: boolean;
|
|
12
|
+
name: LottieAnimationName;
|
|
13
|
+
size?: number;
|
|
14
|
+
speed?: number;
|
|
15
|
+
style?: ViewStyle;
|
|
16
|
+
testID?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function Lottie({
|
|
20
|
+
name,
|
|
21
|
+
size,
|
|
22
|
+
style,
|
|
23
|
+
autoPlay = true,
|
|
24
|
+
loop = true,
|
|
25
|
+
speed = 1,
|
|
26
|
+
testID
|
|
27
|
+
}: LottieProps): JSX.Element {
|
|
28
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
29
|
+
const animationRef = useRef<AnimationItem | null>(null);
|
|
30
|
+
const source = LOTTIE_ANIMATIONS[name];
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!containerRef.current) return;
|
|
34
|
+
|
|
35
|
+
animationRef.current = lottie.loadAnimation({
|
|
36
|
+
animationData: source,
|
|
37
|
+
autoplay: autoPlay,
|
|
38
|
+
container: containerRef.current,
|
|
39
|
+
loop,
|
|
40
|
+
renderer: 'svg'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (speed !== 1) {
|
|
44
|
+
animationRef.current.setSpeed(speed);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
animationRef.current?.destroy();
|
|
49
|
+
};
|
|
50
|
+
}, [source, autoPlay, loop, speed]);
|
|
51
|
+
|
|
52
|
+
const sizeStyle = size != null ? { height: size, width: size } : {};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<View style={[sizeStyle, style]} testID={testID}>
|
|
56
|
+
<div
|
|
57
|
+
ref={containerRef}
|
|
58
|
+
style={{
|
|
59
|
+
height: '100%',
|
|
60
|
+
width: '100%'
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type { LottieAnimationName };
|
|
68
|
+
export { LOTTIE_ANIMATIONS };
|
|
69
|
+
|