summaryrefslogtreecommitdiffstats
path: root/src/components/ui/WebviewLoader/index.tsx
blob: 53e10d3b9ce44c8e860bfb1312b729b923f19569 (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
import { observer } from 'mobx-react';
import { Component, type ReactElement } from 'react';
import {
  type WrappedComponentProps,
  defineMessages,
  injectIntl,
} from 'react-intl';
import injectSheet, { type WithStylesProps } from 'react-jss';
import FullscreenLoader from '../FullscreenLoader';

const messages = defineMessages({
  loading: {
    id: 'service.webviewLoader.loading',
    defaultMessage: 'Loading {service}',
  },
});

const styles = theme => ({
  component: {
    background: theme.colorWebviewLoaderBackground,
    padding: 20,
    width: 'auto',
    margin: [0, 'auto'],
    borderRadius: 6,
  },
});

interface IProps extends WithStylesProps<typeof styles>, WrappedComponentProps {
  name: string;
  loaded?: boolean;
}

class WebviewLoader extends Component<IProps> {
  render(): ReactElement {
    const { classes, name, loaded = false, intl } = this.props;
    return (
      <FullscreenLoader
        className={classes.component}
        title={intl.formatMessage(messages.loading, { service: name })}
        loaded={loaded}
      />
    );
  }
}

export default injectIntl(
  injectSheet(styles, { injectTheme: true })(observer(WebviewLoader)),
);