-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathFulfillingSquareSpinner.js
94 lines (85 loc) · 1.87 KB
/
FulfillingSquareSpinner.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
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const SquareSpinner = styled.div`
height: ${(props) => props.size}px;
width: ${(props) => props.size}px;
position: relative;
border: 4px solid ${(props) => props.color};
animation: fulfilling-square-spinner-animation
${(props) => props.animationDuration}ms infinite ease;
* {
box-sizing: border-box;
}
.spinner-inner {
vertical-align: top;
display: inline-block;
background-color: ${(props) => props.color};
width: 100%;
opacity: 1;
animation: fulfilling-square-spinner-inner-animation
${(props) => props.animationDuration}ms infinite ease-in;
}
@keyframes fulfilling-square-spinner-animation {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(180deg);
}
50% {
transform: rotate(180deg);
}
75% {
transform: rotate(360deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes fulfilling-square-spinner-inner-animation {
0% {
height: 0%;
}
25% {
height: 0%;
}
50% {
height: 100%;
}
75% {
height: 100%;
}
100% {
height: 0%;
}
}
`;
const propTypes = {
size: PropTypes.number,
animationDuration: PropTypes.number,
color: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
};
const FulfillingSquareSpinner = ({
size = 50,
color = '#fff',
animationDuration = 4000,
className = '',
style,
...props
}) => (
<SquareSpinner
size={size}
color={color}
animationDuration={animationDuration}
className={`fulfilling-square-spinner${className ? ' ' + className : ''}`}
style={style}
{...props}
>
<div className="spinner-inner" />
</SquareSpinner>
);
FulfillingSquareSpinner.propTypes = propTypes;
export default FulfillingSquareSpinner;