-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
TrinityRingsSpinner.js
113 lines (105 loc) · 2.78 KB
/
TrinityRingsSpinner.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
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const Trinity = styled.div`
height: ${(props) => props.size}px;
width: ${(props) => props.size}px;
padding: 3px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
overflow: hidden;
box-sizing: border-box;
* {
box-sizing: border-box;
}
.circle {
position: absolute;
display: block;
border-radius: 50%;
border: 3px solid ${(props) => props.color};
opacity: 1;
}
.circle:nth-child(1) {
height: ${(props) => props.outerWidth}px;
width: ${(props) => props.outerWidth}px;
animation: trinity-rings-spinner-circle1-animation
${(props) => props.animationDuration}ms infinite linear;
border-width: 3px;
}
.circle:nth-child(2) {
height: calc(${(props) => props.outerWidth}px * 0.65);
width: calc(${(props) => props.outerWidth}px * 0.65);
animation: trinity-rings-spinner-circle2-animation
${(props) => props.animationDuration}ms infinite linear;
border-width: 2px;
}
.circle:nth-child(3) {
height: calc(${(props) => props.outerWidth}px * 0.1);
width: calc(${(props) => props.outerWidth}px * 0.1);
animation: trinity-rings-spinner-circle3-animation
${(props) => props.animationDuration}ms infinite linear;
border-width: 1px;
}
@keyframes trinity-rings-spinner-circle1-animation {
0% {
transform: rotateZ(20deg) rotateY(0deg);
}
100% {
transform: rotateZ(100deg) rotateY(360deg);
}
}
@keyframes trinity-rings-spinner-circle2-animation {
0% {
transform: rotateZ(100deg) rotateX(0deg);
}
100% {
transform: rotateZ(0deg) rotateX(360deg);
}
}
@keyframes trinity-rings-spinner-circle3-animation {
0% {
transform: rotateZ(100deg) rotateX(-360deg);
}
100% {
transform: rotateZ(-360deg) rotateX(360deg);
}
}
`;
const propTypes = {
size: PropTypes.number,
animationDuration: PropTypes.number,
color: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
};
const TrinityRingsSpinner = ({
size = 66,
color = '#fff',
animationDuration = 1500,
className = '',
style,
...props
}) => {
const containerPadding = 3;
const outerWidth = size - containerPadding * 2;
return (
<Trinity
size={size}
color={color}
animationDuration={animationDuration}
className={`trinity-rings-spinner${className ? ' ' + className : ''}`}
style={style}
outerWidth={outerWidth}
{...props}
>
<div className="circle circle1" />
<div className="circle circle2" />
<div className="circle circle3" />
</Trinity>
);
};
TrinityRingsSpinner.propTypes = propTypes;
export default TrinityRingsSpinner;