-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HalfCircleSpinner.js
64 lines (58 loc) · 1.46 KB
/
HalfCircleSpinner.js
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
import { styled } from '@linaria/react';
import { addRefProps } from '../utils/index';
const HalfSpinner = styled.div`
width: ${(props) => props.size}px;
height: ${(props) => props.size}px;
border-radius: 100%;
position: relative;
* {
box-sizing: border-box;
}
.circle {
content: '';
position: absolute;
width: 100%;
height: 100%;
border-radius: 100%;
border: calc(${(props) => props.size}px / 10) solid transparent;
}
.circle.circle-1 {
border-top-color: ${(props) => props.color};
animation: half-circle-spinner-animation
${(props) => props.animationDuration}ms infinite;
}
.circle.circle-2 {
border-bottom-color: ${(props) => props.color};
animation: half-circle-spinner-animation
${(props) => props.animationDuration}ms infinite alternate;
}
@keyframes half-circle-spinner-animation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
`;
const HalfCircleSpinnerBase = ({
size = 60,
color = '#fff',
animationDuration = 1000,
className = '',
innerRef,
...props
}) => (
<HalfSpinner
ref={innerRef}
size={size}
color={color}
animationDuration={animationDuration}
className={`half-circle-spinner${className ? ' ' + className : ''}`}
{...props}
>
<div className="circle circle-1" />
<div className="circle circle-2" />
</HalfSpinner>
);
export const HalfCircleSpinner = addRefProps(HalfCircleSpinnerBase);