aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/FullscreenLoader/index.tsx
blob: 40b04abe82dba574c8002a6e885378ee757f743f (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 classnames from 'classnames';
import { observer } from 'mobx-react';
import { Component, type ReactElement, type ReactNode } from 'react';
import withStyles, { type WithStylesProps } from 'react-jss';
import type { Theme } from '../../../themes';
import { H1 } from '../headline';
import Loader from '../loader/index';
import styles from './styles';

interface IProps extends WithStylesProps<typeof styles> {
  className?: string;
  title?: string;
  theme?: Theme;
  spinnerColor?: string;
  loaded?: boolean;
  children?: ReactNode;
}

@observer
class FullscreenLoader extends Component<IProps> {
  render(): ReactElement {
    const {
      classes,
      theme,
      className = '',
      spinnerColor = '',
      children = null,
      title = '',
      loaded = false,
    } = 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}
            loaded={loaded}
          />
          {children && <div className={classes.content}>{children}</div>}
        </div>
      </div>
    );
  }
}

export default withStyles(styles, { injectTheme: true })(FullscreenLoader);