aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/FullscreenLoader/index.js
blob: ab5e2f3655b00f03fcf3952f06aac9ddf884dfd6 (plain) (blame)
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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import injectSheet, { withTheme } from 'react-jss';
import classnames from 'classnames';

import Loader from '../Loader';

import styles from './styles';

@withTheme
@injectSheet(styles)
@observer
class FullscreenLoader extends Component {
  static propTypes = {
    className: PropTypes.string,
    title: PropTypes.string.isRequired,
    classes: PropTypes.object.isRequired,
    theme: PropTypes.object.isRequired,
    spinnerColor: PropTypes.string,
    children: PropTypes.node,
  };

  static defaultProps = {
    className: null,
    spinnerColor: null,
    children: null,
  };

  render() {
    const { classes, title, children, spinnerColor, className, theme } =
      this.props;

    return (
      <div className={classes.wrapper}>
        <div
          className={classnames({
            [`${classes.component}`]: true,
            [`${className}`]: className,
          })}
        >
          <h1 className={classes.title}>{title}</h1>
          <Loader color={spinnerColor || theme.colorFullscreenLoaderSpinner} />
          {children && <div className={classes.content}>{children}</div>}
        </div>
      </div>
    );
  }
}

export default FullscreenLoader;