react-useanimations 2.0.8 → 2.0.9-RC
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/.babelrc +4 -0
- package/.editorconfig +15 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +31 -0
- package/.gitattributes +1 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +15 -0
- package/.vscode/settings.json +5 -0
- package/LICENSE +30 -0
- package/README_v1.md +46 -0
- package/package.json +4 -3
- package/{bin → src/bin}/addAnimationFiles.sh +0 -0
- package/{bin → src/bin}/generateStories.sh +0 -0
- package/src/index.tsx +177 -0
- package/{lib → src/lib}/activity/activity.json +0 -0
- package/src/lib/activity/index.ts +4 -0
- package/{lib → src/lib}/airplay/airplay.json +0 -0
- package/src/lib/airplay/index.ts +4 -0
- package/{lib → src/lib}/alertCircle/alertCircle.json +0 -0
- package/src/lib/alertCircle/index.ts +4 -0
- package/{lib → src/lib}/alertOctagon/alertOctagon.json +0 -0
- package/src/lib/alertOctagon/index.ts +4 -0
- package/{lib → src/lib}/alertTriangle/alertTriangle.json +0 -0
- package/src/lib/alertTriangle/index.ts +4 -0
- package/{lib → src/lib}/archive/archive.json +0 -0
- package/src/lib/archive/index.ts +4 -0
- package/{lib → src/lib}/arrowDown/arrowDown.json +0 -0
- package/src/lib/arrowDown/index.ts +4 -0
- package/{lib → src/lib}/arrowDownCircle/arrowDownCircle.json +0 -0
- package/src/lib/arrowDownCircle/index.ts +4 -0
- package/{lib → src/lib}/arrowLeftCircle/arrowLeftCircle.json +0 -0
- package/src/lib/arrowLeftCircle/index.ts +4 -0
- package/{lib → src/lib}/arrowRightCircle/arrowRightCircle.json +0 -0
- package/src/lib/arrowRightCircle/index.ts +4 -0
- package/{lib → src/lib}/arrowUp/arrowUp.json +0 -0
- package/src/lib/arrowUp/index.ts +4 -0
- package/{lib → src/lib}/arrowUpCircle/arrowUpCircle.json +0 -0
- package/src/lib/arrowUpCircle/index.ts +4 -0
- package/{lib → src/lib}/behance/behance.json +0 -0
- package/src/lib/behance/index.ts +4 -0
- package/{lib → src/lib}/bookmark/bookmark.json +0 -0
- package/src/lib/bookmark/index.ts +4 -0
- package/{lib → src/lib}/calendar/calendar.json +0 -0
- package/src/lib/calendar/index.ts +4 -0
- package/{lib → src/lib}/checkBox/checkBox.json +0 -0
- package/src/lib/checkBox/index.ts +4 -0
- package/{lib → src/lib}/checkmark/checkmark.json +0 -0
- package/src/lib/checkmark/index.ts +4 -0
- package/{lib → src/lib}/codepen/codepen.json +0 -0
- package/src/lib/codepen/index.ts +4 -0
- package/{lib → src/lib}/copy/copy.json +0 -0
- package/src/lib/copy/index.ts +4 -0
- package/{lib → src/lib}/download/download.json +0 -0
- package/src/lib/download/index.ts +4 -0
- package/{lib → src/lib}/dribbble/dribbble.json +0 -0
- package/src/lib/dribbble/index.ts +4 -0
- package/{lib → src/lib}/edit/edit.json +0 -0
- package/src/lib/edit/index.ts +4 -0
- package/{lib → src/lib}/error/error.json +0 -0
- package/src/lib/error/index.ts +4 -0
- package/{lib → src/lib}/explore/explore.json +0 -0
- package/src/lib/explore/index.ts +4 -0
- package/{lib → src/lib}/facebook/facebook.json +0 -0
- package/src/lib/facebook/index.ts +4 -0
- package/{lib → src/lib}/folder/folder.json +0 -0
- package/src/lib/folder/index.ts +4 -0
- package/{lib → src/lib}/github/github.json +0 -0
- package/src/lib/github/index.ts +4 -0
- package/{lib → src/lib}/heart/heart.json +0 -0
- package/src/lib/heart/index.ts +4 -0
- package/{lib → src/lib}/help/help.json +0 -0
- package/src/lib/help/index.ts +4 -0
- package/{lib → src/lib}/home/home.json +0 -0
- package/src/lib/home/index.ts +4 -0
- package/src/lib/infinity/index.ts +4 -0
- package/{lib → src/lib}/infinity/infinity.json +0 -0
- package/src/lib/info/index.ts +4 -0
- package/{lib → src/lib}/info/info.json +0 -0
- package/src/lib/instagram/index.ts +4 -0
- package/{lib → src/lib}/instagram/instagram.json +0 -0
- package/src/lib/linkedin/index.ts +4 -0
- package/{lib → src/lib}/linkedin/linkedin.json +0 -0
- package/src/lib/loading/index.ts +4 -0
- package/{lib → src/lib}/loading/loading.json +0 -0
- package/src/lib/loading2/index.ts +4 -0
- package/{lib → src/lib}/loading2/loading2.json +0 -0
- package/src/lib/loading3/index.ts +4 -0
- package/{lib → src/lib}/loading3/loading3.json +0 -0
- package/src/lib/lock/index.ts +4 -0
- package/{lib → src/lib}/lock/lock.json +0 -0
- package/src/lib/mail/index.ts +4 -0
- package/{lib → src/lib}/mail/mail.json +0 -0
- package/src/lib/maximizeMinimize/index.ts +4 -0
- package/{lib → src/lib}/maximizeMinimize/maximizeMinimize.json +0 -0
- package/src/lib/maximizeMinimize2/index.ts +4 -0
- package/{lib → src/lib}/maximizeMinimize2/maximizeMinimize2.json +0 -0
- package/src/lib/menu/index.ts +4 -0
- package/{lib → src/lib}/menu/menu.json +0 -0
- package/src/lib/menu2/index.ts +4 -0
- package/{lib → src/lib}/menu2/menu2.json +0 -0
- package/src/lib/menu3/index.ts +4 -0
- package/{lib → src/lib}/menu3/menu3.json +0 -0
- package/src/lib/menu4/index.ts +4 -0
- package/{lib → src/lib}/menu4/menu4.json +0 -0
- package/src/lib/microphone/index.ts +4 -0
- package/{lib → src/lib}/microphone/microphone.json +0 -0
- package/src/lib/microphone2/index.ts +4 -0
- package/{lib → src/lib}/microphone2/microphone2.json +0 -0
- package/src/lib/notification/index.ts +4 -0
- package/{lib → src/lib}/notification/notification.json +0 -0
- package/src/lib/notification2/index.ts +4 -0
- package/{lib → src/lib}/notification2/notification2.json +0 -0
- package/src/lib/playPause/index.ts +4 -0
- package/{lib → src/lib}/playPause/playPause.json +0 -0
- package/src/lib/playPauseCircle/index.ts +4 -0
- package/{lib → src/lib}/playPauseCircle/playPauseCircle.json +0 -0
- package/src/lib/plusToX/index.ts +4 -0
- package/{lib → src/lib}/plusToX/plusToX.json +0 -0
- package/src/lib/pocket/index.ts +4 -0
- package/{lib → src/lib}/pocket/pocket.json +0 -0
- package/src/lib/radioButton/index.ts +4 -0
- package/{lib → src/lib}/radioButton/radioButton.json +0 -0
- package/src/lib/scrollDown/index.ts +4 -0
- package/{lib → src/lib}/scrollDown/scrollDown.json +0 -0
- package/src/lib/searchToX/index.ts +4 -0
- package/{lib → src/lib}/searchToX/searchToX.json +0 -0
- package/src/lib/settings/index.ts +4 -0
- package/{lib → src/lib}/settings/settings.json +0 -0
- package/src/lib/settings2/index.ts +4 -0
- package/{lib → src/lib}/settings2/settings2.json +0 -0
- package/src/lib/share/index.ts +4 -0
- package/{lib → src/lib}/share/share.json +0 -0
- package/src/lib/skipBack/index.ts +4 -0
- package/{lib → src/lib}/skipBack/skipBack.json +0 -0
- package/src/lib/skipForward/index.ts +4 -0
- package/{lib → src/lib}/skipForward/skipForward.json +0 -0
- package/src/lib/star/index.ts +4 -0
- package/{lib → src/lib}/star/star.json +0 -0
- package/src/lib/thumbUp/index.ts +4 -0
- package/{lib → src/lib}/thumbUp/thumbUp.json +0 -0
- package/src/lib/toggle/index.ts +4 -0
- package/{lib → src/lib}/toggle/toggle.json +0 -0
- package/src/lib/trash/index.ts +4 -0
- package/{lib → src/lib}/trash/trash.json +0 -0
- package/src/lib/trash2/index.ts +4 -0
- package/{lib → src/lib}/trash2/trash2.json +0 -0
- package/src/lib/twitter/index.ts +4 -0
- package/{lib → src/lib}/twitter/twitter.json +0 -0
- package/src/lib/userMinus/index.ts +4 -0
- package/{lib → src/lib}/userMinus/userMinus.json +0 -0
- package/src/lib/userPlus/index.ts +4 -0
- package/{lib → src/lib}/userPlus/userPlus.json +0 -0
- package/src/lib/userX/index.ts +4 -0
- package/{lib → src/lib}/userX/userX.json +0 -0
- package/src/lib/video/index.ts +4 -0
- package/{lib → src/lib}/video/video.json +0 -0
- package/src/lib/video2/index.ts +4 -0
- package/{lib → src/lib}/video2/video2.json +0 -0
- package/src/lib/visibility/index.ts +4 -0
- package/{lib → src/lib}/visibility/visibility.json +0 -0
- package/src/lib/visibility2/index.ts +4 -0
- package/{lib → src/lib}/visibility2/visibility2.json +0 -0
- package/src/lib/volume/index.ts +4 -0
- package/{lib → src/lib}/volume/volume.json +0 -0
- package/src/lib/youtube/index.ts +4 -0
- package/{lib → src/lib}/youtube/youtube.json +0 -0
- package/src/lib/youtube2/index.ts +4 -0
- package/{lib → src/lib}/youtube2/youtube2.json +0 -0
- package/src/lib/zoomIn/index.ts +4 -0
- package/{lib → src/lib}/zoomIn/zoomIn.json +0 -0
- package/src/lib/zoomOut/index.ts +4 -0
- package/{lib → src/lib}/zoomOut/zoomOut.json +0 -0
- package/src/stories/controlled.stories.tsx +257 -0
- package/src/stories/generated.stories.tsx +406 -0
- package/src/stories/variants.stories.tsx +237 -0
- package/{typings.d.ts → src/typings.d.ts} +0 -0
- package/src/utils/constants.ts +93 -0
- package/{utils/getEffect.js → src/utils/getEffect.ts} +9 -12
- package/src/utils/getEvents.ts +81 -0
- package/{utils/index.d.ts → src/utils/index.ts} +0 -0
- package/tsconfig.json +67 -0
- package/useanimations-preview.gif +0 -0
- package/index.d.ts +0 -19
- package/index.js +0 -197
- package/lib/activity/index.d.ts +0 -3
- package/lib/activity/index.js +0 -16
- package/lib/airplay/index.d.ts +0 -3
- package/lib/airplay/index.js +0 -16
- package/lib/alertCircle/index.d.ts +0 -3
- package/lib/alertCircle/index.js +0 -16
- package/lib/alertOctagon/index.d.ts +0 -3
- package/lib/alertOctagon/index.js +0 -16
- package/lib/alertTriangle/index.d.ts +0 -3
- package/lib/alertTriangle/index.js +0 -16
- package/lib/archive/index.d.ts +0 -3
- package/lib/archive/index.js +0 -16
- package/lib/arrowDown/index.d.ts +0 -3
- package/lib/arrowDown/index.js +0 -16
- package/lib/arrowDownCircle/index.d.ts +0 -3
- package/lib/arrowDownCircle/index.js +0 -16
- package/lib/arrowLeftCircle/index.d.ts +0 -3
- package/lib/arrowLeftCircle/index.js +0 -16
- package/lib/arrowRightCircle/index.d.ts +0 -3
- package/lib/arrowRightCircle/index.js +0 -16
- package/lib/arrowUp/index.d.ts +0 -3
- package/lib/arrowUp/index.js +0 -16
- package/lib/arrowUpCircle/index.d.ts +0 -3
- package/lib/arrowUpCircle/index.js +0 -16
- package/lib/behance/index.d.ts +0 -3
- package/lib/behance/index.js +0 -16
- package/lib/bookmark/index.d.ts +0 -3
- package/lib/bookmark/index.js +0 -16
- package/lib/calendar/index.d.ts +0 -3
- package/lib/calendar/index.js +0 -16
- package/lib/checkBox/index.d.ts +0 -3
- package/lib/checkBox/index.js +0 -16
- package/lib/checkmark/index.d.ts +0 -3
- package/lib/checkmark/index.js +0 -16
- package/lib/codepen/index.d.ts +0 -3
- package/lib/codepen/index.js +0 -16
- package/lib/copy/index.d.ts +0 -3
- package/lib/copy/index.js +0 -16
- package/lib/download/index.d.ts +0 -3
- package/lib/download/index.js +0 -16
- package/lib/dribbble/index.d.ts +0 -3
- package/lib/dribbble/index.js +0 -16
- package/lib/edit/index.d.ts +0 -3
- package/lib/edit/index.js +0 -16
- package/lib/error/index.d.ts +0 -3
- package/lib/error/index.js +0 -16
- package/lib/explore/index.d.ts +0 -3
- package/lib/explore/index.js +0 -16
- package/lib/facebook/index.d.ts +0 -3
- package/lib/facebook/index.js +0 -16
- package/lib/folder/index.d.ts +0 -3
- package/lib/folder/index.js +0 -16
- package/lib/github/index.d.ts +0 -3
- package/lib/github/index.js +0 -16
- package/lib/heart/index.d.ts +0 -3
- package/lib/heart/index.js +0 -16
- package/lib/help/index.d.ts +0 -3
- package/lib/help/index.js +0 -16
- package/lib/home/index.d.ts +0 -3
- package/lib/home/index.js +0 -16
- package/lib/infinity/index.d.ts +0 -3
- package/lib/infinity/index.js +0 -16
- package/lib/info/index.d.ts +0 -3
- package/lib/info/index.js +0 -16
- package/lib/instagram/index.d.ts +0 -3
- package/lib/instagram/index.js +0 -16
- package/lib/linkedin/index.d.ts +0 -3
- package/lib/linkedin/index.js +0 -16
- package/lib/loading/index.d.ts +0 -3
- package/lib/loading/index.js +0 -16
- package/lib/loading2/index.d.ts +0 -3
- package/lib/loading2/index.js +0 -16
- package/lib/loading3/index.d.ts +0 -3
- package/lib/loading3/index.js +0 -16
- package/lib/lock/index.d.ts +0 -3
- package/lib/lock/index.js +0 -16
- package/lib/mail/index.d.ts +0 -3
- package/lib/mail/index.js +0 -16
- package/lib/maximizeMinimize/index.d.ts +0 -3
- package/lib/maximizeMinimize/index.js +0 -16
- package/lib/maximizeMinimize2/index.d.ts +0 -3
- package/lib/maximizeMinimize2/index.js +0 -16
- package/lib/menu/index.d.ts +0 -3
- package/lib/menu/index.js +0 -16
- package/lib/menu2/index.d.ts +0 -3
- package/lib/menu2/index.js +0 -16
- package/lib/menu3/index.d.ts +0 -3
- package/lib/menu3/index.js +0 -16
- package/lib/menu4/index.d.ts +0 -3
- package/lib/menu4/index.js +0 -16
- package/lib/microphone/index.d.ts +0 -3
- package/lib/microphone/index.js +0 -16
- package/lib/microphone2/index.d.ts +0 -3
- package/lib/microphone2/index.js +0 -16
- package/lib/notification/index.d.ts +0 -3
- package/lib/notification/index.js +0 -16
- package/lib/notification2/index.d.ts +0 -3
- package/lib/notification2/index.js +0 -16
- package/lib/playPause/index.d.ts +0 -3
- package/lib/playPause/index.js +0 -16
- package/lib/playPauseCircle/index.d.ts +0 -3
- package/lib/playPauseCircle/index.js +0 -16
- package/lib/plusToX/index.d.ts +0 -3
- package/lib/plusToX/index.js +0 -16
- package/lib/pocket/index.d.ts +0 -3
- package/lib/pocket/index.js +0 -16
- package/lib/radioButton/index.d.ts +0 -3
- package/lib/radioButton/index.js +0 -16
- package/lib/scrollDown/index.d.ts +0 -3
- package/lib/scrollDown/index.js +0 -16
- package/lib/searchToX/index.d.ts +0 -3
- package/lib/searchToX/index.js +0 -16
- package/lib/settings/index.d.ts +0 -3
- package/lib/settings/index.js +0 -16
- package/lib/settings2/index.d.ts +0 -3
- package/lib/settings2/index.js +0 -16
- package/lib/share/index.d.ts +0 -3
- package/lib/share/index.js +0 -16
- package/lib/skipBack/index.d.ts +0 -3
- package/lib/skipBack/index.js +0 -16
- package/lib/skipForward/index.d.ts +0 -3
- package/lib/skipForward/index.js +0 -16
- package/lib/star/index.d.ts +0 -3
- package/lib/star/index.js +0 -16
- package/lib/thumbUp/index.d.ts +0 -3
- package/lib/thumbUp/index.js +0 -16
- package/lib/toggle/index.d.ts +0 -3
- package/lib/toggle/index.js +0 -16
- package/lib/trash/index.d.ts +0 -3
- package/lib/trash/index.js +0 -16
- package/lib/trash2/index.d.ts +0 -3
- package/lib/trash2/index.js +0 -16
- package/lib/twitter/index.d.ts +0 -3
- package/lib/twitter/index.js +0 -16
- package/lib/userMinus/index.d.ts +0 -3
- package/lib/userMinus/index.js +0 -16
- package/lib/userPlus/index.d.ts +0 -3
- package/lib/userPlus/index.js +0 -16
- package/lib/userX/index.d.ts +0 -3
- package/lib/userX/index.js +0 -16
- package/lib/video/index.d.ts +0 -3
- package/lib/video/index.js +0 -16
- package/lib/video2/index.d.ts +0 -3
- package/lib/video2/index.js +0 -16
- package/lib/visibility/index.d.ts +0 -3
- package/lib/visibility/index.js +0 -16
- package/lib/visibility2/index.d.ts +0 -3
- package/lib/visibility2/index.js +0 -16
- package/lib/volume/index.d.ts +0 -3
- package/lib/volume/index.js +0 -16
- package/lib/youtube/index.d.ts +0 -3
- package/lib/youtube/index.js +0 -16
- package/lib/youtube2/index.d.ts +0 -3
- package/lib/youtube2/index.js +0 -16
- package/lib/zoomIn/index.d.ts +0 -3
- package/lib/zoomIn/index.js +0 -16
- package/lib/zoomOut/index.d.ts +0 -3
- package/lib/zoomOut/index.js +0 -16
- package/stories/controlled.stories.d.ts +0 -60
- package/stories/controlled.stories.js +0 -231
- package/stories/generated.stories.d.ts +0 -20
- package/stories/generated.stories.js +0 -977
- package/stories/variants.stories.d.ts +0 -70
- package/stories/variants.stories.js +0 -196
- package/utils/constants.d.ts +0 -6
- package/utils/constants.js +0 -1
- package/utils/getEffect.d.ts +0 -3
- package/utils/getEvents.d.ts +0 -12
- package/utils/getEvents.js +0 -96
- package/utils/index.js +0 -23
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withInfo } from '@storybook/addon-info';
|
|
3
|
+
import activity from '../lib/activity';
|
|
4
|
+
import youtube from '../lib/youtube';
|
|
5
|
+
import star from '../lib/star';
|
|
6
|
+
import heart from '../lib/heart';
|
|
7
|
+
import UseAnimation from '..';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Variants',
|
|
11
|
+
component: UseAnimation,
|
|
12
|
+
decorators: [withInfo],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const Stroke = () => (
|
|
16
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
17
|
+
<div style={{ padding: '20px' }}>
|
|
18
|
+
<span>activity</span>
|
|
19
|
+
<UseAnimation
|
|
20
|
+
strokeColor="green"
|
|
21
|
+
size={40}
|
|
22
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
23
|
+
animation={activity}
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
<div style={{ padding: '20px' }}>
|
|
27
|
+
<span>activity</span>
|
|
28
|
+
<UseAnimation
|
|
29
|
+
strokeColor="red"
|
|
30
|
+
size={40}
|
|
31
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
32
|
+
animation={youtube}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
Stroke.story = {
|
|
39
|
+
parameters: {
|
|
40
|
+
info: {
|
|
41
|
+
text: `
|
|
42
|
+
~~~js
|
|
43
|
+
export const Stroke = () => (
|
|
44
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
45
|
+
<div style={{ padding: '20px' }}>
|
|
46
|
+
<span>activity</span>
|
|
47
|
+
<UseAnimation
|
|
48
|
+
strokeColor="green"
|
|
49
|
+
size={40}
|
|
50
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
51
|
+
animation={activity}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
<div style={{ padding: '20px' }}>
|
|
55
|
+
<span>activity</span>
|
|
56
|
+
<UseAnimation
|
|
57
|
+
strokeColor="red"
|
|
58
|
+
size={40}
|
|
59
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
60
|
+
animation={youtube}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
~~~
|
|
66
|
+
`,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const Fill = () => (
|
|
72
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
73
|
+
<div style={{ padding: '20px' }}>
|
|
74
|
+
<span>star</span>
|
|
75
|
+
<UseAnimation
|
|
76
|
+
fillColor="green"
|
|
77
|
+
size={40}
|
|
78
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
79
|
+
animation={star}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
<div style={{ padding: '20px' }}>
|
|
83
|
+
<span>heart</span>
|
|
84
|
+
<UseAnimation
|
|
85
|
+
fillColor="red"
|
|
86
|
+
size={40}
|
|
87
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
88
|
+
animation={heart}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
Fill.story = {
|
|
95
|
+
parameters: {
|
|
96
|
+
info: {
|
|
97
|
+
text: `
|
|
98
|
+
~~~js
|
|
99
|
+
export const Fill = () => (
|
|
100
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
101
|
+
<div style={{ padding: '20px' }}>
|
|
102
|
+
<span>star</span>
|
|
103
|
+
<UseAnimation
|
|
104
|
+
fillColor="green"
|
|
105
|
+
size={40}
|
|
106
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
107
|
+
animation={star}
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
<div style={{ padding: '20px' }}>
|
|
111
|
+
<span>heart</span>
|
|
112
|
+
<UseAnimation
|
|
113
|
+
fillColor="red"
|
|
114
|
+
size={40}
|
|
115
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
116
|
+
animation={heart}
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
~~~
|
|
122
|
+
`,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const CustomCSS = () => (
|
|
128
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
129
|
+
<div style={{ padding: '20px' }}>
|
|
130
|
+
<span>activity</span>
|
|
131
|
+
<UseAnimation
|
|
132
|
+
size={40}
|
|
133
|
+
pathCss="stroke: purple; stroke-width: 2%;"
|
|
134
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
135
|
+
animation={activity}
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
CustomCSS.story = {
|
|
142
|
+
parameters: {
|
|
143
|
+
info: {
|
|
144
|
+
text: `
|
|
145
|
+
~~~js
|
|
146
|
+
export const CustomCSS = () => (
|
|
147
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
148
|
+
<div style={{ padding: '20px' }}>
|
|
149
|
+
<span>activity</span>
|
|
150
|
+
<UseAnimation
|
|
151
|
+
size={40}
|
|
152
|
+
pathCss="stroke: purple; stroke-width: 2%;"
|
|
153
|
+
wrapperStyle={{ marginTop: '5px' }}
|
|
154
|
+
animation={activity}
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
~~~
|
|
160
|
+
`,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const Size = () => (
|
|
166
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
167
|
+
<div style={{ padding: '20px' }}>
|
|
168
|
+
<span>activity</span>
|
|
169
|
+
<UseAnimation size={60} wrapperStyle={{ marginTop: '5px' }} animation={activity} />
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
Size.story = {
|
|
175
|
+
parameters: {
|
|
176
|
+
info: {
|
|
177
|
+
text: `
|
|
178
|
+
~~~js
|
|
179
|
+
export const Size = () => (
|
|
180
|
+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
|
|
181
|
+
<div style={{ padding: '20px' }}>
|
|
182
|
+
<span>activity</span>
|
|
183
|
+
<UseAnimation size={60} wrapperStyle={{ marginTop: '5px' }} animation={activity} />
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
~~~
|
|
188
|
+
`,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const WrapperElement = () => {
|
|
194
|
+
return (
|
|
195
|
+
<UseAnimation
|
|
196
|
+
animation={heart}
|
|
197
|
+
size={60}
|
|
198
|
+
onClick={() => {
|
|
199
|
+
// eslint-disable-next-line
|
|
200
|
+
console.log('additional onClick cb is working');
|
|
201
|
+
}}
|
|
202
|
+
render={(eventProps, animationProps) => (
|
|
203
|
+
<button style={{ padding: '20px' }} type="button" {...eventProps}>
|
|
204
|
+
<div {...animationProps} />
|
|
205
|
+
</button>
|
|
206
|
+
)}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
WrapperElement.story = {
|
|
212
|
+
parameters: {
|
|
213
|
+
info: {
|
|
214
|
+
text: `
|
|
215
|
+
~~~js
|
|
216
|
+
export const WrapperElement = () => {
|
|
217
|
+
return (
|
|
218
|
+
<UseAnimation
|
|
219
|
+
animation={heart}
|
|
220
|
+
size={60}
|
|
221
|
+
onClick={() => {
|
|
222
|
+
// eslint-disable-next-line
|
|
223
|
+
console.log('additional onClick cb is working');
|
|
224
|
+
}}
|
|
225
|
+
render={(eventProps, animationProps) => (
|
|
226
|
+
<button style={{ padding: '20px' }} type="button" {...eventProps}>
|
|
227
|
+
<div {...animationProps} />
|
|
228
|
+
</button>
|
|
229
|
+
)}
|
|
230
|
+
/>
|
|
231
|
+
);
|
|
232
|
+
};
|
|
233
|
+
~~~
|
|
234
|
+
`,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type AnimationEffect =
|
|
2
|
+
| 'CLICK_PLAY_AND_BACKWARDS'
|
|
3
|
+
| 'HOVER_PLAY_AND_STOP'
|
|
4
|
+
| 'HOVER_PLAY_AND_BACKWARDS'
|
|
5
|
+
| 'CLICK_PLAY'
|
|
6
|
+
| 'LOOP_PLAY'
|
|
7
|
+
| 'CLICK_PLAY_AND_SEGMENTS';
|
|
8
|
+
|
|
9
|
+
export type Animation = {
|
|
10
|
+
animationData: any;
|
|
11
|
+
animationKey: AnimationKey;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type AnimationKey =
|
|
15
|
+
| 'activity'
|
|
16
|
+
| 'airplay'
|
|
17
|
+
| 'alertCircle'
|
|
18
|
+
| 'alertOctagon'
|
|
19
|
+
| 'alertTriangle'
|
|
20
|
+
| 'archive'
|
|
21
|
+
| 'arrowDown'
|
|
22
|
+
| 'arrowDownCircle'
|
|
23
|
+
| 'arrowLeftCircle'
|
|
24
|
+
| 'arrowRightCircle'
|
|
25
|
+
| 'arrowUp'
|
|
26
|
+
| 'arrowUpCircle'
|
|
27
|
+
| 'bookmark'
|
|
28
|
+
| 'behance'
|
|
29
|
+
| 'calendar'
|
|
30
|
+
| 'checkBox'
|
|
31
|
+
| 'checkmark'
|
|
32
|
+
| 'codepen'
|
|
33
|
+
| 'copy'
|
|
34
|
+
| 'download'
|
|
35
|
+
| 'dribbble'
|
|
36
|
+
| 'edit'
|
|
37
|
+
| 'error'
|
|
38
|
+
| 'explore'
|
|
39
|
+
| 'facebook'
|
|
40
|
+
| 'folder'
|
|
41
|
+
| 'github'
|
|
42
|
+
| 'heart'
|
|
43
|
+
| 'help'
|
|
44
|
+
| 'home'
|
|
45
|
+
| 'infinity'
|
|
46
|
+
| 'info'
|
|
47
|
+
| 'instagram'
|
|
48
|
+
| 'linkedin'
|
|
49
|
+
| 'loading'
|
|
50
|
+
| 'loading2'
|
|
51
|
+
| 'loading3'
|
|
52
|
+
| 'lock'
|
|
53
|
+
| 'mail'
|
|
54
|
+
| 'maximizeMinimize'
|
|
55
|
+
| 'maximizeMinimize2'
|
|
56
|
+
| 'menu'
|
|
57
|
+
| 'menu2'
|
|
58
|
+
| 'menu3'
|
|
59
|
+
| 'menu4'
|
|
60
|
+
| 'microphone'
|
|
61
|
+
| 'microphone2'
|
|
62
|
+
| 'notification'
|
|
63
|
+
| 'notification2'
|
|
64
|
+
| 'playPause'
|
|
65
|
+
| 'playPauseCircle'
|
|
66
|
+
| 'plusToX'
|
|
67
|
+
| 'pocket'
|
|
68
|
+
| 'radioButton'
|
|
69
|
+
| 'scrollDown'
|
|
70
|
+
| 'searchToX'
|
|
71
|
+
| 'settings'
|
|
72
|
+
| 'settings2'
|
|
73
|
+
| 'share'
|
|
74
|
+
| 'skipBack'
|
|
75
|
+
| 'skipForward'
|
|
76
|
+
| 'star'
|
|
77
|
+
| 'thumbUp'
|
|
78
|
+
| 'toggle'
|
|
79
|
+
| 'trash'
|
|
80
|
+
| 'trash2'
|
|
81
|
+
| 'twitter'
|
|
82
|
+
| 'userMinus'
|
|
83
|
+
| 'userPlus'
|
|
84
|
+
| 'userX'
|
|
85
|
+
| 'video'
|
|
86
|
+
| 'video2'
|
|
87
|
+
| 'visibility'
|
|
88
|
+
| 'visibility2'
|
|
89
|
+
| 'volume'
|
|
90
|
+
| 'youtube'
|
|
91
|
+
| 'youtube2'
|
|
92
|
+
| 'zoomIn'
|
|
93
|
+
| 'zoomOut';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AnimationKey, AnimationEffect } from '.';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
type Animations = {
|
|
4
|
+
[Key in AnimationKey]: AnimationEffect;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const animations: Animations = {
|
|
8
8
|
activity: 'LOOP_PLAY',
|
|
9
9
|
airplay: 'LOOP_PLAY',
|
|
10
10
|
alertCircle: 'LOOP_PLAY',
|
|
@@ -83,12 +83,9 @@ var animations = {
|
|
|
83
83
|
youtube: 'HOVER_PLAY_AND_STOP',
|
|
84
84
|
youtube2: 'HOVER_PLAY_AND_STOP',
|
|
85
85
|
zoomIn: 'LOOP_PLAY',
|
|
86
|
-
zoomOut: 'LOOP_PLAY'
|
|
86
|
+
zoomOut: 'LOOP_PLAY',
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
return animations[animationKey] || '';
|
|
91
|
-
};
|
|
89
|
+
const getEffect = (animationKey: AnimationKey) => animations[animationKey] || '';
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
exports["default"] = _default;
|
|
91
|
+
export default getEffect;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AnimationEffect } from './constants';
|
|
2
|
+
|
|
3
|
+
const getClickAndPlaySegmentsEvents = (animation: any) => ({
|
|
4
|
+
onClick: () => animation.playSegments([0, 60], true),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const getClickPlayEvents = (animation: any) => ({
|
|
8
|
+
onClick: () => {
|
|
9
|
+
animation.stop();
|
|
10
|
+
animation.play();
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const getHoverPlayAndStop = (animation: any) => ({
|
|
15
|
+
onMouseEnter: () => animation.play(),
|
|
16
|
+
onMouseLeave: () => animation.stop(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const getHoverPlayBackwardsEvents = (animation: any) => ({
|
|
20
|
+
onMouseEnter: () => {
|
|
21
|
+
animation.setDirection(1);
|
|
22
|
+
animation.play();
|
|
23
|
+
},
|
|
24
|
+
onMouseLeave: () => {
|
|
25
|
+
animation.setDirection(-1);
|
|
26
|
+
animation.play();
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const getClickAndPlayBackwardsEvents = (animation: any, reverse: boolean) => {
|
|
31
|
+
let directionMenu = 1;
|
|
32
|
+
|
|
33
|
+
// EG CHECKBOX WHICH NEED TO BE CHECKED AS INITIAL STATE, LET'S PLAY THE ANIMATION ASAP AUTOMATICALLY
|
|
34
|
+
if (reverse) {
|
|
35
|
+
animation.setDirection(directionMenu);
|
|
36
|
+
animation.play();
|
|
37
|
+
directionMenu *= -1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
onClick: () => {
|
|
42
|
+
animation.setDirection(directionMenu);
|
|
43
|
+
animation.play();
|
|
44
|
+
directionMenu *= -1;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getEvents = ({
|
|
50
|
+
animation,
|
|
51
|
+
reverse,
|
|
52
|
+
animEffect,
|
|
53
|
+
}: {
|
|
54
|
+
animation: any;
|
|
55
|
+
reverse: boolean;
|
|
56
|
+
animEffect: AnimationEffect;
|
|
57
|
+
}) => {
|
|
58
|
+
if (animEffect === 'CLICK_PLAY_AND_SEGMENTS') {
|
|
59
|
+
return getClickAndPlaySegmentsEvents(animation);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (animEffect === 'CLICK_PLAY') {
|
|
63
|
+
return getClickPlayEvents(animation);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (animEffect === 'HOVER_PLAY_AND_STOP') {
|
|
67
|
+
return getHoverPlayAndStop(animation);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (animEffect === 'HOVER_PLAY_AND_BACKWARDS') {
|
|
71
|
+
return getHoverPlayBackwardsEvents(animation);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (animEffect === 'CLICK_PLAY_AND_BACKWARDS') {
|
|
75
|
+
return getClickAndPlayBackwardsEvents(animation, reverse);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return getClickPlayEvents(animation);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default getEvents;
|
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
5
|
+
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
6
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
7
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
8
|
+
"allowJs": true, /* Allow javascript files to be compiled. */
|
|
9
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
10
|
+
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
11
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
12
|
+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
13
|
+
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
14
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
15
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
16
|
+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
17
|
+
// "composite": true, /* Enable project compilation */
|
|
18
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
19
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
20
|
+
"noEmit": false, /* Do not emit outputs. */
|
|
21
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
22
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
23
|
+
"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
24
|
+
/* Strict Type-Checking Options */
|
|
25
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
26
|
+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
27
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
28
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
29
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
30
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
31
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
32
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
33
|
+
/* Additional Checks */
|
|
34
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
35
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
36
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
37
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
38
|
+
/* Module Resolution Options */
|
|
39
|
+
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
40
|
+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
41
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
42
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
43
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
44
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
45
|
+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
46
|
+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
47
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
48
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
49
|
+
/* Source Map Options */
|
|
50
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
51
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
52
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
53
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
54
|
+
/* Experimental Options */
|
|
55
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
56
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
57
|
+
/* Advanced Options */
|
|
58
|
+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
59
|
+
},
|
|
60
|
+
"include": [
|
|
61
|
+
"src"
|
|
62
|
+
],
|
|
63
|
+
"exclude": [
|
|
64
|
+
"node_modules",
|
|
65
|
+
"dist"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
Binary file
|
package/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
import type { AnimationConfig } from 'lottie-web';
|
|
3
|
-
import type { Animation } from './utils';
|
|
4
|
-
declare type Props = {
|
|
5
|
-
animation: Animation;
|
|
6
|
-
reverse?: boolean;
|
|
7
|
-
strokeColor?: string;
|
|
8
|
-
fillColor?: string;
|
|
9
|
-
pathCss?: string;
|
|
10
|
-
options?: Partial<AnimationConfig>;
|
|
11
|
-
size?: number;
|
|
12
|
-
loop?: AnimationConfig['loop'];
|
|
13
|
-
autoplay?: AnimationConfig['autoplay'];
|
|
14
|
-
speed?: number;
|
|
15
|
-
wrapperStyle?: React.CSSProperties;
|
|
16
|
-
render?: (eventProps: any, animationProps: any) => ReactElement;
|
|
17
|
-
} & React.HTMLProps<HTMLDivElement>;
|
|
18
|
-
declare const UseAnimations: React.FC<Props>;
|
|
19
|
-
export default UseAnimations;
|