aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/FullscreenLoader/index.js
blob: f8c6b92ee6fc0b43b3292b8547c1389b79cb2fb6 (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
52
import { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import injectStyle from 'react-jss';
import classnames from 'classnames';

import Loader from '../Loader';

import styles from './styles';
import { H1 } from '../headline';

class FullscreenLoader extends Component {
  static propTypes = {
    className: PropTypes.string,
    title: PropTypes.string,
    classes: PropTypes.object.isRequired,
    theme: PropTypes.object.isRequired,
    spinnerColor: PropTypes.string,
    children: PropTypes.node,
  };

  static defaultProps = {
    className: null,
    spinnerColor: null,
    children: null,
    title: 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 injectStyle(styles, { injectTheme: true })(
  observer(FullscreenLoader),
);