@tactics/toddle-styleguide 1.0.1 → 1.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/App.tsx CHANGED
@@ -62,6 +62,7 @@ import {SelectLinkPreview} from './src/components/molecules/select-link/select-l
62
62
  import {MoreInfoButtonPreview} from './src/components/molecules/more-info-button/more-info-button.preview';
63
63
  import {LanguageButtonPreview} from './src/components/molecules/language-button/language-button.preview';
64
64
  import {ModalPreview} from './src/components/templates/modal/modal.preview';
65
+ import {LoadingIndicatorPreview} from './src/components/organisms/loading-indicator/loading-indicator.preview';
65
66
 
66
67
  const Stack = createNativeStackNavigator();
67
68
 
@@ -235,6 +236,10 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
235
236
  onPress={() => navigation.push('language-button')}
236
237
  />
237
238
  <ReactBtn title="Modal" onPress={() => navigation.push('modal')} />
239
+ <ReactBtn
240
+ title="Loading indicator"
241
+ onPress={() => navigation.push('loading-indicator')}
242
+ />
238
243
  </ScrollView>
239
244
  );
240
245
  };
@@ -384,6 +389,9 @@ function App() {
384
389
  {() => <LanguageButtonPreview />}
385
390
  </Stack.Screen>
386
391
  <Stack.Screen name="modal">{() => <ModalPreview />}</Stack.Screen>
392
+ <Stack.Screen name="loading-indicator" options={{headerShown: false}}>
393
+ {() => <LoadingIndicatorPreview />}
394
+ </Stack.Screen>
387
395
  </Stack.Navigator>
388
396
  </NavigationContainer>
389
397
  </ThemeCtx.Provider>
package/index.d.ts CHANGED
@@ -48,6 +48,7 @@ import { MyChildListItem } from './src/components/organisms/my-child-list-item/m
48
48
  import { MoreInfoButton } from './src/components/molecules/more-info-button/more-info-button.component';
49
49
  import { LanguageButton } from './src/components/molecules/language-button/language-button.component';
50
50
  import { Modal } from './src/components/templates/modal/modal.component';
51
+ import { LoadingIndicator } from './src/components/organisms/loading-indicator/loading-indicator.component';
51
52
  import { BubbleAlignment } from './src/types/bubble-alignment.enum';
52
53
  import { KeyBoardTypes } from './src/types/keyboard-types.enum';
53
54
  import { Size } from './src/types/size.enum';
@@ -56,4 +57,4 @@ import { Initials } from './src/models/initials.model';
56
57
  import { ToddleDateTime } from './src/utilities/toddle-datetime/toddle-datetime.class';
57
58
  import { ThemeCtx } from './src/context/theme.context';
58
59
  import { Scale } from './src/theme/scale/index';
59
- export { Initials, BubbleAlignment, KeyBoardTypes, Size, Scale, VisualState, ThemeCtx, ToddleDateTime, Avatar, Button, CancelLink, Check, Checkbox, ChildListItem, ContactItem, FilterTab, SplitContainer, ImageBubble, Info, Pill, Popover, PressableIcon, QuickFilter, Search, SelectListItem, Snackbar, Tag, TextBubble, TextInput, TimeTracker, WideButton, Icon, Calendar, IncrementInput, Swipe, Logo, DaySelect, BlockedMessage, DepartmentLogo, ContactRole, Timeline, SelectPicker, CalendarSelect, DateInput, FilterRange, Footer, DefaultSelect, PasswordInput, MessageInput, Heading1, Heading2, Heading3, Heading4, AllCapsHeading, Paragraph, SmallText, TinyText, SelectLink, MyChildListItem, MoreInfoButton, LanguageButton, Modal, };
60
+ export { Initials, BubbleAlignment, KeyBoardTypes, Size, Scale, VisualState, ThemeCtx, ToddleDateTime, Avatar, Button, CancelLink, Check, Checkbox, ChildListItem, ContactItem, FilterTab, SplitContainer, ImageBubble, Info, Pill, Popover, PressableIcon, QuickFilter, Search, SelectListItem, Snackbar, Tag, TextBubble, TextInput, TimeTracker, WideButton, Icon, Calendar, IncrementInput, Swipe, Logo, DaySelect, BlockedMessage, DepartmentLogo, ContactRole, Timeline, SelectPicker, CalendarSelect, DateInput, FilterRange, Footer, DefaultSelect, PasswordInput, MessageInput, Heading1, Heading2, Heading3, Heading4, AllCapsHeading, Paragraph, SmallText, TinyText, SelectLink, MyChildListItem, MoreInfoButton, LanguageButton, Modal, LoadingIndicator, };
package/index.tsx CHANGED
@@ -66,6 +66,7 @@ import {MyChildListItem} from './src/components/organisms/my-child-list-item/my-
66
66
  import {MoreInfoButton} from './src/components/molecules/more-info-button/more-info-button.component';
67
67
  import {LanguageButton} from './src/components/molecules/language-button/language-button.component';
68
68
  import {Modal} from './src/components/templates/modal/modal.component';
69
+ import {LoadingIndicator} from './src/components/organisms/loading-indicator/loading-indicator.component';
69
70
 
70
71
  // Exports of enums
71
72
  import {BubbleAlignment} from './src/types/bubble-alignment.enum';
@@ -148,4 +149,5 @@ export {
148
149
  MoreInfoButton,
149
150
  LanguageButton,
150
151
  Modal,
152
+ LoadingIndicator,
151
153
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -1700,7 +1700,7 @@ exports[`Test for the calendar component renders a calendar where you can select
1700
1700
  }
1701
1701
  >
1702
1702
  <View
1703
- accessibilityLabel="today Vrijdag 17 Februari 2023 "
1703
+ accessibilityLabel=" Vrijdag 17 Februari 2023 "
1704
1704
  accessibilityRole="button"
1705
1705
  accessibilityState={
1706
1706
  {
@@ -1720,10 +1720,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1720
1720
  style={
1721
1721
  {
1722
1722
  "alignItems": "center",
1723
- "borderColor": "#7B93DB",
1724
- "borderRadius": 21,
1725
- "borderStyle": "solid",
1726
- "borderWidth": 1,
1727
1723
  "height": 42,
1728
1724
  "justifyContent": "center",
1729
1725
  "opacity": 1,
@@ -1743,9 +1739,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1743
1739
  "lineHeight": 22.4,
1744
1740
  "marginTop": 4,
1745
1741
  },
1746
- {
1747
- "color": "#7B93DB",
1748
- },
1749
1742
  ]
1750
1743
  }
1751
1744
  >
@@ -2417,7 +2410,7 @@ exports[`Test for the calendar component renders a calendar where you can select
2417
2410
  }
2418
2411
  >
2419
2412
  <View
2420
- accessibilityLabel=" Maandag 27 Februari 2023 "
2413
+ accessibilityLabel="today Maandag 27 Februari 2023 "
2421
2414
  accessibilityRole="button"
2422
2415
  accessibilityState={
2423
2416
  {
@@ -2437,6 +2430,10 @@ exports[`Test for the calendar component renders a calendar where you can select
2437
2430
  style={
2438
2431
  {
2439
2432
  "alignItems": "center",
2433
+ "borderColor": "#7B93DB",
2434
+ "borderRadius": 21,
2435
+ "borderStyle": "solid",
2436
+ "borderWidth": 1,
2440
2437
  "height": 42,
2441
2438
  "justifyContent": "center",
2442
2439
  "opacity": 1,
@@ -2456,6 +2453,9 @@ exports[`Test for the calendar component renders a calendar where you can select
2456
2453
  "lineHeight": 22.4,
2457
2454
  "marginTop": 4,
2458
2455
  },
2456
+ {
2457
+ "color": "#7B93DB",
2458
+ },
2459
2459
  ]
2460
2460
  }
2461
2461
  >
@@ -4639,8 +4639,7 @@ exports[`Test for the calendar component renders a calendar where you can select
4639
4639
  }
4640
4640
  >
4641
4641
  <View
4642
- accessibilityLabel="today Vrijdag 17 Februari 2023 "
4643
- accessibilityRole="button"
4642
+ accessibilityLabel=" Vrijdag 17 Februari 2023 "
4644
4643
  accessibilityState={
4645
4644
  {
4646
4645
  "disabled": false,
@@ -4659,10 +4658,6 @@ exports[`Test for the calendar component renders a calendar where you can select
4659
4658
  style={
4660
4659
  {
4661
4660
  "alignItems": "center",
4662
- "borderColor": "#7B93DB",
4663
- "borderRadius": 21,
4664
- "borderStyle": "solid",
4665
- "borderWidth": 1,
4666
4661
  "height": 42,
4667
4662
  "justifyContent": "center",
4668
4663
  "opacity": 1,
@@ -4683,7 +4678,7 @@ exports[`Test for the calendar component renders a calendar where you can select
4683
4678
  "marginTop": 4,
4684
4679
  },
4685
4680
  {
4686
- "color": "#7B93DB",
4681
+ "color": "#9AA5B1",
4687
4682
  },
4688
4683
  ]
4689
4684
  }
@@ -5374,7 +5369,8 @@ exports[`Test for the calendar component renders a calendar where you can select
5374
5369
  }
5375
5370
  >
5376
5371
  <View
5377
- accessibilityLabel=" Maandag 27 Februari 2023 "
5372
+ accessibilityLabel="today Maandag 27 Februari 2023 "
5373
+ accessibilityRole="button"
5378
5374
  accessibilityState={
5379
5375
  {
5380
5376
  "disabled": false,
@@ -5393,6 +5389,10 @@ exports[`Test for the calendar component renders a calendar where you can select
5393
5389
  style={
5394
5390
  {
5395
5391
  "alignItems": "center",
5392
+ "borderColor": "#7B93DB",
5393
+ "borderRadius": 21,
5394
+ "borderStyle": "solid",
5395
+ "borderWidth": 1,
5396
5396
  "height": 42,
5397
5397
  "justifyContent": "center",
5398
5398
  "opacity": 1,
@@ -5413,7 +5413,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5413
5413
  "marginTop": 4,
5414
5414
  },
5415
5415
  {
5416
- "color": "#9AA5B1",
5416
+ "color": "#7B93DB",
5417
5417
  },
5418
5418
  ]
5419
5419
  }
@@ -0,0 +1,474 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`loading indicator test should render a default loading indicator 1`] = `
4
+ <View
5
+ collapsable={false}
6
+ style={
7
+ {
8
+ "alignItems": "center",
9
+ "display": "flex",
10
+ "flexDirection": "row",
11
+ "justifyContent": "center",
12
+ }
13
+ }
14
+ >
15
+ <View
16
+ style={
17
+ {
18
+ "alignItems": "center",
19
+ "display": "flex",
20
+ "flexDirection": "row",
21
+ "height": 10,
22
+ "justifyContent": "center",
23
+ "margin": 2,
24
+ "width": 10,
25
+ }
26
+ }
27
+ >
28
+ <View
29
+ collapsable={false}
30
+ style={
31
+ {
32
+ "backgroundColor": "black",
33
+ "borderRadius": 9999,
34
+ "height": 0,
35
+ "position": "absolute",
36
+ "width": 0,
37
+ }
38
+ }
39
+ />
40
+ </View>
41
+ <View
42
+ style={
43
+ {
44
+ "alignItems": "center",
45
+ "display": "flex",
46
+ "flexDirection": "row",
47
+ "height": 10,
48
+ "justifyContent": "center",
49
+ "margin": 2,
50
+ "width": 10,
51
+ }
52
+ }
53
+ >
54
+ <View
55
+ collapsable={false}
56
+ style={
57
+ {
58
+ "backgroundColor": "black",
59
+ "borderRadius": 9999,
60
+ "height": 0,
61
+ "position": "absolute",
62
+ "width": 0,
63
+ }
64
+ }
65
+ />
66
+ </View>
67
+ <View
68
+ style={
69
+ {
70
+ "alignItems": "center",
71
+ "display": "flex",
72
+ "flexDirection": "row",
73
+ "height": 10,
74
+ "justifyContent": "center",
75
+ "margin": 2,
76
+ "width": 10,
77
+ }
78
+ }
79
+ >
80
+ <View
81
+ collapsable={false}
82
+ style={
83
+ {
84
+ "backgroundColor": "black",
85
+ "borderRadius": 9999,
86
+ "height": 0,
87
+ "position": "absolute",
88
+ "width": 0,
89
+ }
90
+ }
91
+ />
92
+ </View>
93
+ </View>
94
+ `;
95
+
96
+ exports[`loading indicator test should render a flashing loading indicator with a dot size of 12px 1`] = `
97
+ <View
98
+ collapsable={false}
99
+ style={
100
+ {
101
+ "alignItems": "center",
102
+ "display": "flex",
103
+ "flexDirection": "row",
104
+ "justifyContent": "center",
105
+ }
106
+ }
107
+ >
108
+ <View
109
+ style={
110
+ {
111
+ "alignItems": "center",
112
+ "display": "flex",
113
+ "flexDirection": "row",
114
+ "height": 12,
115
+ "justifyContent": "center",
116
+ "margin": 2,
117
+ "width": 12,
118
+ }
119
+ }
120
+ >
121
+ <View
122
+ collapsable={false}
123
+ style={
124
+ {
125
+ "backgroundColor": "black",
126
+ "borderRadius": 9999,
127
+ "height": 12,
128
+ "opacity": 12,
129
+ "position": "absolute",
130
+ "width": 12,
131
+ }
132
+ }
133
+ />
134
+ </View>
135
+ <View
136
+ style={
137
+ {
138
+ "alignItems": "center",
139
+ "display": "flex",
140
+ "flexDirection": "row",
141
+ "height": 12,
142
+ "justifyContent": "center",
143
+ "margin": 2,
144
+ "width": 12,
145
+ }
146
+ }
147
+ >
148
+ <View
149
+ collapsable={false}
150
+ style={
151
+ {
152
+ "backgroundColor": "black",
153
+ "borderRadius": 9999,
154
+ "height": 12,
155
+ "opacity": 12,
156
+ "position": "absolute",
157
+ "width": 12,
158
+ }
159
+ }
160
+ />
161
+ </View>
162
+ <View
163
+ style={
164
+ {
165
+ "alignItems": "center",
166
+ "display": "flex",
167
+ "flexDirection": "row",
168
+ "height": 12,
169
+ "justifyContent": "center",
170
+ "margin": 2,
171
+ "width": 12,
172
+ }
173
+ }
174
+ >
175
+ <View
176
+ collapsable={false}
177
+ style={
178
+ {
179
+ "backgroundColor": "black",
180
+ "borderRadius": 9999,
181
+ "height": 12,
182
+ "opacity": 12,
183
+ "position": "absolute",
184
+ "width": 12,
185
+ }
186
+ }
187
+ />
188
+ </View>
189
+ </View>
190
+ `;
191
+
192
+ exports[`loading indicator test should render a ping loading indicator with a size of 14px and a spacing of 4px 1`] = `
193
+ <View
194
+ collapsable={false}
195
+ style={
196
+ {
197
+ "alignItems": "center",
198
+ "display": "flex",
199
+ "flexDirection": "row",
200
+ "justifyContent": "center",
201
+ }
202
+ }
203
+ >
204
+ <View
205
+ style={
206
+ {
207
+ "alignItems": "center",
208
+ "display": "flex",
209
+ "flexDirection": "row",
210
+ "height": 14,
211
+ "justifyContent": "center",
212
+ "margin": 4,
213
+ "width": 14,
214
+ }
215
+ }
216
+ >
217
+ <View
218
+ collapsable={false}
219
+ style={
220
+ {
221
+ "backgroundColor": "black",
222
+ "borderRadius": 9999,
223
+ "height": 14,
224
+ "opacity": 1,
225
+ "position": "absolute",
226
+ "transform": [
227
+ {
228
+ "scale": 0,
229
+ },
230
+ ],
231
+ "width": 14,
232
+ }
233
+ }
234
+ />
235
+ </View>
236
+ <View
237
+ style={
238
+ {
239
+ "alignItems": "center",
240
+ "display": "flex",
241
+ "flexDirection": "row",
242
+ "height": 14,
243
+ "justifyContent": "center",
244
+ "margin": 4,
245
+ "width": 14,
246
+ }
247
+ }
248
+ >
249
+ <View
250
+ collapsable={false}
251
+ style={
252
+ {
253
+ "backgroundColor": "black",
254
+ "borderRadius": 9999,
255
+ "height": 14,
256
+ "opacity": 1,
257
+ "position": "absolute",
258
+ "transform": [
259
+ {
260
+ "scale": 0,
261
+ },
262
+ ],
263
+ "width": 14,
264
+ }
265
+ }
266
+ />
267
+ </View>
268
+ <View
269
+ style={
270
+ {
271
+ "alignItems": "center",
272
+ "display": "flex",
273
+ "flexDirection": "row",
274
+ "height": 14,
275
+ "justifyContent": "center",
276
+ "margin": 4,
277
+ "width": 14,
278
+ }
279
+ }
280
+ >
281
+ <View
282
+ collapsable={false}
283
+ style={
284
+ {
285
+ "backgroundColor": "black",
286
+ "borderRadius": 9999,
287
+ "height": 14,
288
+ "opacity": 1,
289
+ "position": "absolute",
290
+ "transform": [
291
+ {
292
+ "scale": 0,
293
+ },
294
+ ],
295
+ "width": 14,
296
+ }
297
+ }
298
+ />
299
+ </View>
300
+ </View>
301
+ `;
302
+
303
+ exports[`loading indicator test should render a typing loading indicator with a red color and a delay of 200 1`] = `
304
+ <View
305
+ collapsable={false}
306
+ style={
307
+ {
308
+ "alignItems": "center",
309
+ "display": "flex",
310
+ "flexDirection": "row",
311
+ "justifyContent": "center",
312
+ }
313
+ }
314
+ >
315
+ <View
316
+ style={
317
+ {
318
+ "alignItems": "center",
319
+ "display": "flex",
320
+ "flexDirection": "row",
321
+ "height": 10,
322
+ "justifyContent": "center",
323
+ "margin": 2,
324
+ "width": 10,
325
+ }
326
+ }
327
+ >
328
+ <View
329
+ collapsable={false}
330
+ style={
331
+ {
332
+ "backgroundColor": "red",
333
+ "borderRadius": 9999,
334
+ "height": 10,
335
+ "position": "absolute",
336
+ "top": 0,
337
+ "width": 10,
338
+ }
339
+ }
340
+ />
341
+ </View>
342
+ <View
343
+ style={
344
+ {
345
+ "alignItems": "center",
346
+ "display": "flex",
347
+ "flexDirection": "row",
348
+ "height": 10,
349
+ "justifyContent": "center",
350
+ "margin": 2,
351
+ "width": 10,
352
+ }
353
+ }
354
+ >
355
+ <View
356
+ collapsable={false}
357
+ style={
358
+ {
359
+ "backgroundColor": "red",
360
+ "borderRadius": 9999,
361
+ "height": 10,
362
+ "position": "absolute",
363
+ "top": 0,
364
+ "width": 10,
365
+ }
366
+ }
367
+ />
368
+ </View>
369
+ <View
370
+ style={
371
+ {
372
+ "alignItems": "center",
373
+ "display": "flex",
374
+ "flexDirection": "row",
375
+ "height": 10,
376
+ "justifyContent": "center",
377
+ "margin": 2,
378
+ "width": 10,
379
+ }
380
+ }
381
+ >
382
+ <View
383
+ collapsable={false}
384
+ style={
385
+ {
386
+ "backgroundColor": "red",
387
+ "borderRadius": 9999,
388
+ "height": 10,
389
+ "position": "absolute",
390
+ "top": 0,
391
+ "width": 10,
392
+ }
393
+ }
394
+ />
395
+ </View>
396
+ </View>
397
+ `;
398
+
399
+ exports[`loading indicator test should render an elastic loading indicator with 2 dots 1`] = `
400
+ <View
401
+ collapsable={false}
402
+ style={
403
+ {
404
+ "alignItems": "center",
405
+ "display": "flex",
406
+ "flexDirection": "row",
407
+ "justifyContent": "center",
408
+ }
409
+ }
410
+ >
411
+ <View
412
+ style={
413
+ {
414
+ "alignItems": "center",
415
+ "display": "flex",
416
+ "flexDirection": "row",
417
+ "height": 10,
418
+ "justifyContent": "center",
419
+ "margin": 2,
420
+ "width": 10,
421
+ }
422
+ }
423
+ >
424
+ <View
425
+ collapsable={false}
426
+ style={
427
+ {
428
+ "backgroundColor": "black",
429
+ "borderRadius": 9999,
430
+ "height": 10,
431
+ "position": "absolute",
432
+ "transform": [
433
+ {
434
+ "scaleY": 1,
435
+ },
436
+ ],
437
+ "width": 10,
438
+ }
439
+ }
440
+ />
441
+ </View>
442
+ <View
443
+ style={
444
+ {
445
+ "alignItems": "center",
446
+ "display": "flex",
447
+ "flexDirection": "row",
448
+ "height": 10,
449
+ "justifyContent": "center",
450
+ "margin": 2,
451
+ "width": 10,
452
+ }
453
+ }
454
+ >
455
+ <View
456
+ collapsable={false}
457
+ style={
458
+ {
459
+ "backgroundColor": "black",
460
+ "borderRadius": 9999,
461
+ "height": 10,
462
+ "position": "absolute",
463
+ "transform": [
464
+ {
465
+ "scaleY": 1,
466
+ },
467
+ ],
468
+ "width": 10,
469
+ }
470
+ }
471
+ />
472
+ </View>
473
+ </View>
474
+ `;
@@ -0,0 +1,3 @@
1
+ import { Animated } from 'react-native';
2
+ export declare const animationStyle: (animation: string | undefined, node: Animated.Value, delay: number, size: number | undefined) => any;
3
+ export declare const styles: (animation: string | undefined, color: string | undefined, size: number | undefined, dynamicSize: Animated.Value | undefined) => any;
@@ -0,0 +1,164 @@
1
+ import {Animated} from 'react-native';
2
+
3
+ export const animationStyle = (
4
+ animation: string | undefined,
5
+ node: Animated.Value,
6
+ delay: number,
7
+ size: number | undefined
8
+ ): any => {
9
+ const pulse = Animated.sequence([
10
+ Animated.timing(node, {
11
+ toValue: Number(size),
12
+ delay,
13
+ duration: 400,
14
+ useNativeDriver: false,
15
+ }),
16
+ Animated.timing(node, {
17
+ toValue: 0,
18
+ duration: 400,
19
+ useNativeDriver: false,
20
+ }),
21
+ ]);
22
+
23
+ const elastic = Animated.sequence([
24
+ Animated.timing(node, {
25
+ toValue: 1.5,
26
+ delay,
27
+ duration: 400,
28
+ useNativeDriver: false,
29
+ }),
30
+ Animated.timing(node, {
31
+ toValue: 1,
32
+ duration: 400,
33
+ useNativeDriver: false,
34
+ }),
35
+ ]);
36
+
37
+ const flashing = Animated.sequence([
38
+ Animated.timing(node, {
39
+ toValue: 1,
40
+ delay,
41
+ duration: 400,
42
+ useNativeDriver: false,
43
+ }),
44
+ Animated.timing(node, {
45
+ toValue: 0,
46
+ duration: 400,
47
+ useNativeDriver: false,
48
+ }),
49
+ Animated.timing(node, {
50
+ toValue: 1,
51
+ duration: 400,
52
+ useNativeDriver: false,
53
+ }),
54
+ ]);
55
+
56
+ const typing = Animated.sequence([
57
+ Animated.timing(node, {
58
+ toValue: -Number(size),
59
+ delay,
60
+ duration: 400,
61
+ useNativeDriver: false,
62
+ }),
63
+ Animated.timing(node, {
64
+ toValue: 0,
65
+ duration: 400,
66
+ useNativeDriver: false,
67
+ }),
68
+ ]);
69
+
70
+ const ping = Animated.sequence([
71
+ Animated.timing(node, {
72
+ toValue: 0,
73
+ delay,
74
+ duration: 1200,
75
+ useNativeDriver: false,
76
+ }),
77
+ ]);
78
+
79
+ switch (animation) {
80
+ case 'pulse':
81
+ return pulse;
82
+ case 'elastic':
83
+ return elastic;
84
+ case 'flashing':
85
+ return flashing;
86
+ case 'typing':
87
+ return typing;
88
+ case 'ping':
89
+ return ping;
90
+ default:
91
+ return pulse;
92
+ }
93
+ };
94
+
95
+ export const styles = (
96
+ animation: string | undefined,
97
+ color: string | undefined,
98
+ size: number | undefined,
99
+ dynamicSize: Animated.Value | undefined
100
+ ): any => {
101
+ const pulse = {
102
+ position: 'absolute',
103
+ backgroundColor: color,
104
+ height: dynamicSize,
105
+ width: dynamicSize,
106
+ borderRadius: 9999,
107
+ };
108
+
109
+ const elastic = {
110
+ position: 'absolute',
111
+ backgroundColor: color,
112
+ height: size,
113
+ width: size,
114
+ transform: [{scaleY: dynamicSize}],
115
+ borderRadius: 9999,
116
+ };
117
+ const flashing = {
118
+ position: 'absolute',
119
+ backgroundColor: color,
120
+ height: size,
121
+ width: size,
122
+ opacity: dynamicSize,
123
+ borderRadius: 9999,
124
+ };
125
+ const typing = {
126
+ position: 'absolute',
127
+ top: dynamicSize,
128
+ backgroundColor: color,
129
+ height: size,
130
+ width: size,
131
+ borderRadius: 9999,
132
+ };
133
+ const ping = {
134
+ position: 'absolute',
135
+ opacity: dynamicSize,
136
+ transform: [
137
+ {
138
+ scale: dynamicSize?.interpolate({
139
+ inputRange: [0, 1],
140
+ outputRange: [1, 0],
141
+ }),
142
+ },
143
+ ],
144
+ backgroundColor: color,
145
+ height: size,
146
+ width: size,
147
+ borderRadius: 9999,
148
+ };
149
+
150
+ switch (animation) {
151
+ case 'pulse':
152
+ return pulse;
153
+ case 'elastic':
154
+ return elastic;
155
+ case 'flashing':
156
+ return flashing;
157
+ case 'typing':
158
+ return typing;
159
+ case 'ping':
160
+ return ping;
161
+ default:
162
+ return pulse;
163
+ }
164
+ };
@@ -0,0 +1 @@
1
+ export declare const LoadingDotsContainer: () => JSX.Element;
@@ -0,0 +1,65 @@
1
+ import React, {useState} from 'react';
2
+ import {Animated} from 'react-native';
3
+ import {useLoadingContext} from '../../../context/loading-dots.context';
4
+ import {Dot} from './dot.component';
5
+ import {animationStyle} from './animation-style.animate';
6
+
7
+ export const LoadingDotsContainer = (): JSX.Element => {
8
+ const {animation, dots, size, delay} = useLoadingContext();
9
+
10
+ const animatedValues = (animation: string | undefined) => {
11
+ switch (animation) {
12
+ case 'pulse':
13
+ return Number(0);
14
+ case 'elastic':
15
+ return Number(1);
16
+ case 'flashing':
17
+ return Number(size);
18
+ case 'typing':
19
+ return Number(0);
20
+ case 'ping':
21
+ return Number(1);
22
+ default:
23
+ return Number(0);
24
+ }
25
+ };
26
+
27
+ const list = Array.from(
28
+ Array(dots),
29
+ () => new Animated.Value(animatedValues(animation))
30
+ );
31
+
32
+ const [visible, setVisible] = useState(false);
33
+
34
+ const run = (nodes: Animated.Value[]) => {
35
+ Animated.parallel(
36
+ nodes.map((node, index) =>
37
+ animationStyle(
38
+ animation,
39
+ node,
40
+ delay ? index * delay : index * 260,
41
+ size
42
+ )
43
+ )
44
+ ).start(() => {
45
+ setVisible(!visible);
46
+ });
47
+ };
48
+
49
+ run(list);
50
+
51
+ return (
52
+ <Animated.View
53
+ style={{
54
+ display: 'flex',
55
+ flexDirection: 'row',
56
+ justifyContent: 'center',
57
+ alignItems: 'center',
58
+ }}
59
+ >
60
+ {list.map((size, index) => (
61
+ <Dot key={index} dynamicSize={size} />
62
+ ))}
63
+ </Animated.View>
64
+ );
65
+ };
@@ -0,0 +1,6 @@
1
+ import { Animated } from 'react-native';
2
+ declare type DotProps = {
3
+ dynamicSize: Animated.Value;
4
+ };
5
+ export declare const Dot: ({ dynamicSize }: DotProps) => JSX.Element;
6
+ export {};
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import {Animated, View} from 'react-native';
3
+ import {useLoadingContext} from '../../../context/loading-dots.context';
4
+ import {styles} from './animation-style.animate';
5
+
6
+ type DotProps = {
7
+ dynamicSize: Animated.Value;
8
+ };
9
+
10
+ export const Dot = ({dynamicSize}: DotProps): JSX.Element => {
11
+ const {animation, color, size, spacing} = useLoadingContext();
12
+ return (
13
+ <View
14
+ style={{
15
+ display: 'flex',
16
+ flexDirection: 'row',
17
+ justifyContent: 'center',
18
+ alignItems: 'center',
19
+ height: size,
20
+ width: size,
21
+ margin: spacing,
22
+ }}
23
+ >
24
+ <Animated.View style={styles(animation, color, size, dynamicSize)} />
25
+ </View>
26
+ );
27
+ };
@@ -0,0 +1,2 @@
1
+ import { LoadingDotsProps } from '../../../types/loading-dots.type';
2
+ export declare const LoadingIndicator: ({ animation, dots, color, size, spacing, delay, }: LoadingDotsProps) => JSX.Element;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import {LoadingDotsProps} from '../../../types/loading-dots.type';
3
+ import {LoadingDotsContainer} from './container.component';
4
+ import {LoadingDotContextProvider} from '../../../context/loading-dots.context';
5
+
6
+ export const LoadingIndicator = ({
7
+ animation = 'pulse',
8
+ dots = 3,
9
+ color = 'black',
10
+ size = 10,
11
+ spacing = 2,
12
+ delay = 260,
13
+ }: LoadingDotsProps): JSX.Element => {
14
+ return (
15
+ <LoadingDotContextProvider
16
+ values={{animation, dots, color, size, spacing, delay}}
17
+ >
18
+ <LoadingDotsContainer />
19
+ </LoadingDotContextProvider>
20
+ );
21
+ };
@@ -0,0 +1 @@
1
+ export declare const LoadingIndicatorPreview: ({}: {}) => JSX.Element;
@@ -0,0 +1,100 @@
1
+ import React, {useContext} from 'react';
2
+ import {View, Text} from 'react-native';
3
+ import {LoadingIndicator} from './loading-indicator.component';
4
+ import {ThemeCtx} from '../../../context/theme.context';
5
+
6
+ export const LoadingIndicatorPreview = ({}: {}) => {
7
+ const context = useContext(ThemeCtx);
8
+ return (
9
+ <View
10
+ style={{
11
+ flex: 1,
12
+ justifyContent: 'space-around',
13
+ alignItems: 'center',
14
+ padding: 16,
15
+ backgroundColor: context.colors.ui.white,
16
+ }}
17
+ >
18
+ <View style={{flex: 1, justifyContent: 'space-around'}}>
19
+ <Text style={{fontWeight: 'bold', textAlign: 'center'}}>
20
+ Default/Pulse
21
+ </Text>
22
+ <LoadingIndicator color={context.colors.main['5']} dots={2} />
23
+ <LoadingIndicator color={context.colors.main['6']} dots={3} />
24
+ <LoadingIndicator color={context.colors.main['3']} dots={4} />
25
+ </View>
26
+ <View style={{flex: 1, justifyContent: 'space-around'}}>
27
+ <Text style={{fontWeight: 'bold', textAlign: 'center'}}>Elastic</Text>
28
+ <LoadingIndicator
29
+ animation={'elastic'}
30
+ color={context.colors.main['5']}
31
+ dots={2}
32
+ />
33
+ <LoadingIndicator
34
+ animation={'elastic'}
35
+ color={context.colors.main['6']}
36
+ dots={3}
37
+ />
38
+ <LoadingIndicator
39
+ animation={'elastic'}
40
+ color={context.colors.main['3']}
41
+ dots={4}
42
+ />
43
+ </View>
44
+ <View style={{flex: 1, justifyContent: 'space-around'}}>
45
+ <Text style={{fontWeight: 'bold', textAlign: 'center'}}>Flashing</Text>
46
+ <LoadingIndicator
47
+ animation={'flashing'}
48
+ color={context.colors.main['5']}
49
+ dots={2}
50
+ />
51
+ <LoadingIndicator
52
+ animation={'flashing'}
53
+ color={context.colors.main['6']}
54
+ dots={3}
55
+ />
56
+ <LoadingIndicator
57
+ animation={'flashing'}
58
+ color={context.colors.main['3']}
59
+ dots={4}
60
+ />
61
+ </View>
62
+ <View style={{flex: 1, justifyContent: 'space-around'}}>
63
+ <Text style={{fontWeight: 'bold', textAlign: 'center'}}>Typing</Text>
64
+ <LoadingIndicator
65
+ color={context.colors.main['5']}
66
+ animation={'typing'}
67
+ dots={2}
68
+ />
69
+ <LoadingIndicator
70
+ color={context.colors.main['6']}
71
+ animation={'typing'}
72
+ dots={3}
73
+ />
74
+ <LoadingIndicator
75
+ color={context.colors.main['3']}
76
+ animation={'typing'}
77
+ dots={4}
78
+ />
79
+ </View>
80
+ <View style={{flex: 1, justifyContent: 'space-around'}}>
81
+ <Text style={{fontWeight: 'bold', textAlign: 'center'}}>Ping</Text>
82
+ <LoadingIndicator
83
+ color={context.colors.main['5']}
84
+ animation={'ping'}
85
+ dots={2}
86
+ />
87
+ <LoadingIndicator
88
+ color={context.colors.main['6']}
89
+ animation={'ping'}
90
+ dots={3}
91
+ />
92
+ <LoadingIndicator
93
+ color={context.colors.main['3']}
94
+ animation={'ping'}
95
+ dots={4}
96
+ />
97
+ </View>
98
+ </View>
99
+ );
100
+ };
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import {LoadingIndicator} from './loading-indicator.component';
4
+
5
+ describe('loading indicator test', function () {
6
+ it('should render a default loading indicator', function () {
7
+ const tree = renderer.create(<LoadingIndicator />).toJSON();
8
+
9
+ expect(tree).toMatchSnapshot();
10
+ });
11
+ it('should render an elastic loading indicator with 2 dots', function () {
12
+ const tree = renderer
13
+ .create(<LoadingIndicator animation={'elastic'} dots={2} />)
14
+ .toJSON();
15
+ expect(tree).toMatchSnapshot();
16
+ });
17
+ it('should render a flashing loading indicator with a dot size of 12px', function () {
18
+ const tree = renderer
19
+ .create(<LoadingIndicator animation={'flashing'} size={12} />)
20
+ .toJSON();
21
+
22
+ expect(tree).toMatchSnapshot();
23
+ });
24
+ it('should render a typing loading indicator with a red color and a delay of 200', function () {
25
+ const tree = renderer
26
+ .create(
27
+ <LoadingIndicator animation={'typing'} color={'red'} delay={200} />
28
+ )
29
+ .toJSON();
30
+
31
+ expect(tree).toMatchSnapshot();
32
+ });
33
+ it('should render a ping loading indicator with a size of 14px and a spacing of 4px', function () {
34
+ const tree = renderer
35
+ .create(<LoadingIndicator animation={'ping'} size={14} spacing={4} />)
36
+ .toJSON();
37
+
38
+ expect(tree).toMatchSnapshot();
39
+ });
40
+ });
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { LoadingDotsProps } from '../types/loading-dots.type';
3
+ declare const useLoadingContext: () => LoadingDotsProps;
4
+ declare const LoadingDotContextProvider: ({ children, values, }: {
5
+ children: ReactNode;
6
+ values: LoadingDotsProps;
7
+ }) => JSX.Element;
8
+ export { LoadingDotContextProvider, useLoadingContext };
@@ -0,0 +1,33 @@
1
+ import React, {createContext, ReactNode, useContext, useState} from 'react';
2
+ import {LoadingDotsProps} from '../types/loading-dots.type';
3
+
4
+ const defaultState = {
5
+ animation: 'pulse',
6
+ dots: 3,
7
+ color: 'black',
8
+ size: 10,
9
+ spacing: 2,
10
+ };
11
+
12
+ const LoadingDotContext = createContext<LoadingDotsProps>(defaultState);
13
+
14
+ const useLoadingContext = () => {
15
+ const context = useContext(LoadingDotContext);
16
+ return context;
17
+ };
18
+
19
+ const LoadingDotContextProvider = ({
20
+ children,
21
+ values,
22
+ }: {
23
+ children: ReactNode;
24
+ values: LoadingDotsProps;
25
+ }) => {
26
+ return (
27
+ <LoadingDotContext.Provider value={{...values}}>
28
+ {children}
29
+ </LoadingDotContext.Provider>
30
+ );
31
+ };
32
+
33
+ export {LoadingDotContextProvider, useLoadingContext};
@@ -0,0 +1,8 @@
1
+ export declare type LoadingDotsProps = {
2
+ animation?: string;
3
+ dots?: number;
4
+ color?: string;
5
+ size?: number;
6
+ spacing?: number;
7
+ delay?: number;
8
+ };
@@ -0,0 +1,8 @@
1
+ export type LoadingDotsProps = {
2
+ animation?: string;
3
+ dots?: number;
4
+ color?: string;
5
+ size?: number;
6
+ spacing?: number;
7
+ delay?: number;
8
+ };