-
Notifications
You must be signed in to change notification settings - Fork 275
/
Copy pathScaleLoader.tsx
57 lines (50 loc) · 1.38 KB
/
ScaleLoader.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
import * as React from "react";
import { cssValue } from "./helpers/unitConverter";
import { LoaderHeightWidthRadiusProps } from "./helpers/props";
import { createAnimation } from "./helpers/animation";
const scale = createAnimation(
"ScaleLoader",
"0% {transform: scaley(1.0)} 50% {transform: scaley(0.4)} 100% {transform: scaley(1.0)}",
"scale"
);
function ScaleLoader({
loading = true,
color = "#000000",
speedMultiplier = 1,
cssOverride = {},
height = 35,
width = 4,
radius = 2,
margin = 2,
...additionalprops
}: LoaderHeightWidthRadiusProps): JSX.Element | null {
const wrapper: React.CSSProperties = {
display: "inherit",
...cssOverride,
};
const style = (i: number): React.CSSProperties => {
return {
backgroundColor: color,
width: cssValue(width),
height: cssValue(height),
margin: cssValue(margin),
borderRadius: cssValue(radius),
display: "inline-block",
animation: `${scale} ${1 / speedMultiplier}s ${i * 0.1}s infinite cubic-bezier(0.2, 0.68, 0.18, 1.08)`,
animationFillMode: "both",
};
};
if (!loading) {
return null;
}
return (
<span style={wrapper} {...additionalprops}>
<span style={style(1)} />
<span style={style(2)} />
<span style={style(3)} />
<span style={style(4)} />
<span style={style(5)} />
</span>
);
}
export default ScaleLoader;