-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathHalfCircleSpinner.js
74 lines (67 loc) · 1.64 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
65
66
67
68
69
70
71
72
73
74
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
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 propTypes = {
size: PropTypes.number,
animationDuration: PropTypes.number,
color: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
};
const HalfCircleSpinner = ({
size = 60,
color = '#fff',
animationDuration = 1000,
className = '',
style,
...props
}) => (
<HalfSpinner
size={size}
color={color}
animationDuration={animationDuration}
className={`half-circle-spinner${className ? ' ' + className : ''}`}
style={style}
{...props}
>
<div className="circle circle-1" />
<div className="circle circle-2" />
</HalfSpinner>
);
HalfCircleSpinner.propTypes = propTypes;
export default HalfCircleSpinner;