aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/Loader.tsx
blob: ebb437d9d20e8ff658cc92d80329de28448b79be (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
import { Component, ReactElement, ReactNode } 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;
  children?: ReactNode;
}

// Can this file be merged into the './loader/index.tsx' file?
@inject('stores')
@observer
class LoaderComponent extends Component<IProps> {
  render(): ReactElement {
    const {
      loaded = false,
      color = 'ACCENT',
      className,
      children,
    } = this.props;

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

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

export default LoaderComponent;