-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathLoading.js
40 lines (34 loc) · 970 Bytes
/
Loading.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
import React from 'react';
import PropTypes from 'prop-types';
import css from './DotSpinner.css';
const Loading = ({ size = 'medium', useCurrentColor }) => {
const multiplyerMap = {
small: 0.5,
medium: 1,
large: 2,
xlarge: 3
};
const getStyle = () => {
if (size) {
const wAmount = multiplyerMap[size] * 30;
const hAmount = multiplyerMap[size] * 15;
return { width: `${wAmount}px`, height: `${hAmount}px` };
}
return null;
};
const dotStyle = {
backgroundColor: useCurrentColor ? 'currentColor' : null
};
return (
<div className={css.spinner} style={getStyle()}>
<div className={css.bounce1} style={dotStyle} />
<div className={css.bounce2} style={dotStyle} />
<div className={css.bounce3} style={dotStyle} />
</div>
);
};
Loading.propTypes = {
size: PropTypes.oneOf(['small', 'medium', 'large', 'xlarge']),
useCurrentColor: PropTypes.bool,
};
export default Loading;