-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathSpinner.js
More file actions
63 lines (54 loc) · 1.39 KB
/
Spinner.js
File metadata and controls
63 lines (54 loc) · 1.39 KB
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
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { registerStyle } from './util';
export default class Spinner extends React.Component {
constructor() {
super();
registerStyle('spinner-overlay', [
[
'body .slds .slds-spinner_container',
'{ z-index: 9002 }',
],
]);
}
renderSpinner(props) {
const { className, size, type, ...pprops } = props;
const spinnerClassNames = classnames(className,
'slds-spinner',
`slds-spinner--${size}`,
type ? `slds-spinner--${type}` : null
);
return (
<div
className={ spinnerClassNames }
aria-hidden='false'
role='alert'
{ ...pprops }
>
<div className='slds-spinner__dot-a' />
<div className='slds-spinner__dot-b' />
</div>
);
}
render() {
const { container, ...props } = this.props;
return container ? (
<div className='slds-spinner_container'>
{this.renderSpinner(props)}
</div>
) : this.renderSpinner(props);
}
}
const SPINNER_SIZES = ['small', 'medium', 'large'];
const SPINNER_TYPES = ['brand', 'inverse'];
Spinner.propTypes = {
container: PropTypes.bool,
className: PropTypes.string,
type: PropTypes.oneOf(SPINNER_TYPES),
size: PropTypes.oneOf(SPINNER_SIZES),
};
Spinner.defaultProps = {
container: true,
size: 'small',
};