-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSemipolarSpinner.js
More file actions
116 lines (109 loc) · 3.32 KB
/
SemipolarSpinner.js
File metadata and controls
116 lines (109 loc) · 3.32 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
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
import { styled } from '@linaria/react';
import { addRefProps } from '../utils/index';
const Semipolar = styled.div`
height: ${(props) => props.size}px;
width: ${(props) => props.size}px;
position: relative;
* {
box-sizing: border-box;
}
.ring {
border-radius: 50%;
position: absolute;
border: calc(${(props) => props.size}px * 0.05) solid transparent;
border-top-color: ${(props) => props.color};
border-left-color: ${(props) => props.color};
animation: semipolar-spinner-animation
${(props) => props.animationDuration}ms infinite;
}
.ring:nth-child(1) {
height: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 0
);
width: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 0
);
top: calc(${(props) => props.size}px * 0.1 * 0);
left: calc(${(props) => props.size}px * 0.1 * 0);
animation-delay: calc(${(props) => props.animationDuration}ms * 0.1 * 4);
z-index: 5;
}
.ring:nth-child(2) {
height: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 1
);
width: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 1
);
top: calc(${(props) => props.size}px * 0.1 * 1);
left: calc(${(props) => props.size}px * 0.1 * 1);
animation-delay: calc(${(props) => props.animationDuration}ms * 0.1 * 3);
z-index: 4;
}
.ring:nth-child(3) {
height: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 2
);
width: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 2
);
top: calc(${(props) => props.size}px * 0.1 * 2);
left: calc(${(props) => props.size}px * 0.1 * 2);
animation-delay: calc(${(props) => props.animationDuration}ms * 0.1 * 2);
z-index: 3;
}
.ring:nth-child(4) {
height: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 3
);
width: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 3
);
top: calc(${(props) => props.size}px * 0.1 * 3);
left: calc(${(props) => props.size}px * 0.1 * 3);
animation-delay: calc(${(props) => props.animationDuration}ms * 0.1 * 1);
z-index: 2;
}
.ring:nth-child(5) {
height: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 4
);
width: calc(
${(props) => props.size}px - ${(props) => props.size}px * 0.2 * 4
);
top: calc(${(props) => props.size}px * 0.1 * 4);
left: calc(${(props) => props.size}px * 0.1 * 4);
animation-delay: calc(${(props) => props.animationDuration}ms * 0.1 * 0);
z-index: 1;
}
@keyframes semipolar-spinner-animation {
50% {
transform: rotate(360deg) scale(0.7);
}
}
`;
function generateSpinners(num) {
return Array.from({ length: num }).map((val, index) => (
<div key={index} className="ring" />
));
}
const SemipolarSpinnerBase = ({
size = 65,
color = '#fff',
animationDuration = 2000,
className = '',
innerRef,
...props
}) => (
<Semipolar
ref={innerRef}
size={size}
color={color}
animationDuration={animationDuration}
className={`semipolar-spinner${className ? ' ' + className : ''}`}
{...props}
>
{generateSpinners(5)}
</Semipolar>
);
export const SemipolarSpinner = addRefProps(SemipolarSpinnerBase);