forked from jossmac/react-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpinner.js
56 lines (50 loc) · 1.06 KB
/
Spinner.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
import PropTypes from 'prop-types';
import React from 'react';
import { css, StyleSheet } from 'aphrodite/no-important';
const Spinner = props => {
const classes = StyleSheet.create(styles(props));
return (
<div className={css(classes.spinner)}>
<div className={css(classes.ripple)} />
</div>
);
};
Spinner.propTypes = {
color: PropTypes.string,
size: PropTypes.number,
};
const rippleKeyframes = {
'0%': {
top: '50%',
left: '50%',
width: 0,
height: 0,
opacity: 1,
},
'100%': {
top: 0,
left: 0,
width: '100%',
height: '100%',
opacity: 0,
},
};
const styles = ({ color, size }) => ({
spinner: {
display: 'inline-block',
position: 'relative',
width: size,
height: size,
},
ripple: {
position: 'absolute',
border: `4px solid ${color}`,
opacity: 1,
borderRadius: '50%',
animationName: rippleKeyframes,
animationDuration: '1s',
animationTimingFunction: 'cubic-bezier(0, 0.2, 0.8, 1)',
animationIterationCount: 'infinite',
},
});
export default Spinner;