-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathOrbitSpinner.js
101 lines (94 loc) · 2.35 KB
/
OrbitSpinner.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
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
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const Orbit = styled.div`
height: ${(props) => props.size}px;
width: ${(props) => props.size}px;
border-radius: 50%;
perspective: 800px;
* {
box-sizing: border-box;
}
.orbit {
position: absolute;
box-sizing: border-box;
width: 100%;
height: 100%;
border-radius: 50%;
}
.orbit:nth-child(1) {
left: 0%;
top: 0%;
animation: orbit-spinner-orbit-one-animation
${(props) => props.animationDuration}ms linear infinite;
border-bottom: 3px solid ${(props) => props.color};
}
.orbit:nth-child(2) {
right: 0%;
top: 0%;
animation: orbit-spinner-orbit-two-animation
${(props) => props.animationDuration}ms linear infinite;
border-right: 3px solid ${(props) => props.color};
}
.orbit:nth-child(3) {
right: 0%;
bottom: 0%;
animation: orbit-spinner-orbit-three-animation
${(props) => props.animationDuration}ms linear infinite;
border-top: 3px solid ${(props) => props.color};
}
@keyframes orbit-spinner-orbit-one-animation {
0% {
transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg);
}
100% {
transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg);
}
}
@keyframes orbit-spinner-orbit-two-animation {
0% {
transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg);
}
100% {
transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg);
}
}
@keyframes orbit-spinner-orbit-three-animation {
0% {
transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg);
}
100% {
transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg);
}
}
`;
const propTypes = {
size: PropTypes.number,
animationDuration: PropTypes.number,
color: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
};
const OrbitSpinner = ({
size = 50,
color = '#fff',
animationDuration = 1000,
className = '',
style,
...props
}) => (
<Orbit
size={size}
color={color}
animationDuration={animationDuration}
className={`orbit-spinner${className ? ' ' + className : ''}`}
style={style}
{...props}
>
<div className="orbit one" />
<div className="orbit two" />
<div className="orbit three" />
</Orbit>
);
OrbitSpinner.propTypes = propTypes;
export default OrbitSpinner;