/
AnimationExample.tsx
167 lines (161 loc) · 4.73 KB
/
AnimationExample.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import React from 'react'
import notification from 'samples/js/helpers/notification'
import { getContainer, getMessage, getType } from 'samples/js/helpers/randomize'
import Store from 'src/store'
import { iNotification } from 'src/typings'
function AnimationInExample() {
return (
<div className="row">
<div className="col-lg-6 offset-lg-3 column col-md-10 offset-md-1 col-sm-12">
<h6>Animation Entrance</h6>
<div>
Entrance <code className="white-code">animation</code> can be customised by specifying CSS
classes
</div>
<div>
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__bounceIn'])}
>
Bounce In
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__fadeIn'])}
>
Fade In
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__flipInX'])}
>
Flip In X
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__flipInY'])}
>
Flip In Y
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__zoomIn'])}
>
Zoom In
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__flash'])}
>
Flash
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(true, ['animate__animated animate__jackInTheBox'])}
>
Jack In The Box
</button>
</div>
</div>
</div>
)
}
function AnimationOutExample() {
return (
<div className="row">
<div className="col-lg-6 offset-lg-3 column col-md-10 offset-md-1 col-sm-12">
<h6>Animation Exit</h6>
<div>
Exit <code className="white-code">animation</code> can be customised by specifying CSS
classes
</div>
<div>
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(false, ['animate__animated animate__bounceOut'])}
>
Bounce Out
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(false, ['animate__animated animate__fadeOut'])}
>
Fade Out
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(false, ['animate__animated animate__flipOutX'])}
>
Flip Out X
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(false, ['animate__animated animate__flipOutY'])}
>
Flip Out Y
</button>
{' '}
<button
type="button"
className="btn btn-outline-secondary"
onClick={() => add(false, ['animate__animated animate__zoomOut'])}
>
Zoom Out
</button>
{' '}
</div>
</div>
</div>
)
}
function add(isEntranceAnimation: boolean, htmlClasses: string[]) {
const type = getType()
const object: Partial<iNotification> = {}
if (isEntranceAnimation) {
return Store.addNotification(
Object.assign(object, notification, {
animationIn: htmlClasses,
container: getContainer(),
message: getMessage(type),
type
})
)
}
return Store.addNotification(
Object.assign(object, notification, {
slidingExit: { delay: 300 },
animationOut: htmlClasses,
container: getContainer(),
message: getMessage(type),
type
})
)
}
export default function AnimationWrapper() {
return (
<div>
<AnimationInExample/>
<AnimationOutExample/>
</div>
)
}