-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathLoadingIndicator.tsx
More file actions
80 lines (75 loc) · 1.73 KB
/
Copy pathLoadingIndicator.tsx
File metadata and controls
80 lines (75 loc) · 1.73 KB
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
import * as React from "react";
import { View, StyleProp, ViewStyle } from "react-native";
import { withTheme } from "@draftbit/theme";
import type { ReadTheme } from "@draftbit/theme";
import {
Bounce,
Chase,
Circle,
CircleFade,
Flow,
Fold,
Grid,
Plane,
Pulse,
Swing,
Wander,
Wave,
} from "react-native-animated-spinkit";
export enum LoadingIndicatorType {
plane = "plane",
chase = "chase",
bounce = "bounce",
wave = "wave",
pulse = "pulse",
flow = "flow",
swing = "swing",
circle = "circle",
circleFade = "circleFade",
grid = "grid",
fold = "fold",
wander = "wander",
}
type Props = {
style?: StyleProp<ViewStyle>;
className?: string;
color?: string;
theme: ReadTheme;
type?: LoadingIndicatorType;
size?: number;
};
const SPINNER_COMPONENTS = {
[LoadingIndicatorType.plane]: Plane,
[LoadingIndicatorType.chase]: Chase,
[LoadingIndicatorType.bounce]: Bounce,
[LoadingIndicatorType.wave]: Wave,
[LoadingIndicatorType.pulse]: Pulse,
[LoadingIndicatorType.flow]: Flow,
[LoadingIndicatorType.swing]: Swing,
[LoadingIndicatorType.circle]: Circle,
[LoadingIndicatorType.circleFade]: CircleFade,
[LoadingIndicatorType.grid]: Grid,
[LoadingIndicatorType.fold]: Fold,
[LoadingIndicatorType.wander]: Wander,
};
const LoadingIndicator: React.FC<React.PropsWithChildren<Props>> = ({
theme,
color = theme.colors.branding.primary,
type = LoadingIndicatorType.plane,
size,
style,
className,
...rest
}) => {
const SpinnerComponent = SPINNER_COMPONENTS[type];
return (
<View
style={style}
// @ts-ignore
className={className}
>
<SpinnerComponent size={size} color={color} {...rest} />
</View>
);
};
export default withTheme(LoadingIndicator);