-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathAtomSpinner.js
116 lines (103 loc) · 2.79 KB
/
AtomSpinner.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const Atom = styled.div`
height: ${(props) => props.size}px;
width: ${(props) => props.size}px;
overflow: hidden;
* {
box-sizing: border-box;
}
.spinner-inner {
position: relative;
display: block;
height: 100%;
width: 100%;
}
.spinner-circle {
display: block;
position: absolute;
color: ${(props) => props.color};
font-size: calc(${(props) => props.size}px * 0.24);
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.spinner-line {
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
animation-duration: ${(props) => props.animationDuration}ms;
border-left-width: calc(${(props) => props.size}px / 25);
border-top-width: calc(${(props) => props.size}px / 25);
border-left-color: ${(props) => props.color};
border-left-style: solid;
border-top-style: solid;
border-top-color: transparent;
}
.spinner-line:nth-child(1) {
animation: atom-spinner-animation-1 ${(props) => props.animationDuration}ms
linear infinite;
transform: rotateZ(120deg) rotateX(66deg) rotateZ(0deg);
}
.spinner-line:nth-child(2) {
animation: atom-spinner-animation-2 ${(props) => props.animationDuration}ms
linear infinite;
transform: rotateZ(240deg) rotateX(66deg) rotateZ(0deg);
}
.spinner-line:nth-child(3) {
animation: atom-spinner-animation-3 ${(props) => props.animationDuration}ms
linear infinite;
transform: rotateZ(360deg) rotateX(66deg) rotateZ(0deg);
}
@keyframes atom-spinner-animation-1 {
100% {
transform: rotateZ(120deg) rotateX(66deg) rotateZ(360deg);
}
}
@keyframes atom-spinner-animation-2 {
100% {
transform: rotateZ(240deg) rotateX(66deg) rotateZ(360deg);
}
}
@keyframes atom-spinner-animation-3 {
100% {
transform: rotateZ(360deg) rotateX(66deg) rotateZ(360deg);
}
}
`;
const propTypes = {
size: PropTypes.number,
animationDuration: PropTypes.number,
color: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
};
export const AtomSpinner = ({
size = 60,
animationDuration = 1000,
color = '#fff',
className = '',
style,
...props
}) => (
<Atom
size={size}
color={color}
animationDuration={animationDuration}
className={`atom-spinner${className ? ' ' + className : ''}`}
style={style}
{...props}
>
<div className="spinner-inner">
<div className="spinner-line" />
<div className="spinner-line" />
<div className="spinner-line" />
{/* Chrome renders little circles malformed */}
<div className="spinner-circle">●</div>
</div>
</Atom>
);
AtomSpinner.propTypes = propTypes;
export default AtomSpinner;