aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/Loader.tsx
blob: 171d0e290d3641cb51a8e7d296ae0a2680c57836 (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
import { Component, ReactChildren } from 'react';
import { observer, inject } from 'mobx-react';
import Loader from 'react-loader';

import { FerdiStores } from '../../stores.types';

type Props = {
  children: ReactChildren;
  loaded: boolean;
  className: string;
  color: string;
  stores: FerdiStores;
};

class LoaderComponent extends Component<Props> {
  static defaultProps = {
    loaded: false,
    color: 'ACCENT',
  };

  render() {
    const { children, loaded, className } = this.props;

    const color =
      this.props.color !== 'ACCENT'
        ? this.props.color
        : this.props.stores.settings.app.accentColor;

    return (
      <Loader
        loaded={loaded}
        width={4}
        scale={0.6}
        color={color}
        component="span"
        className={className}
      >
        {children}
      </Loader>
    );
  }
}

export default inject('stores')(observer(LoaderComponent));