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

import { FerdiumStores } from '../../@types/stores.types';

interface IProps {
  className?: string;
  color?: string;
  loaded?: boolean;
  stores?: FerdiumStores;
}

// Can this file be merged into the './loader/index.tsx' file?
@inject('stores')
@observer
class LoaderComponent extends Component<PropsWithChildren<IProps>> {
  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 LoaderComponent;