aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/AppLoader/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ui/AppLoader/index.tsx')
-rw-r--r--src/components/ui/AppLoader/index.tsx80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/components/ui/AppLoader/index.tsx b/src/components/ui/AppLoader/index.tsx
new file mode 100644
index 000000000..c7c290a57
--- /dev/null
+++ b/src/components/ui/AppLoader/index.tsx
@@ -0,0 +1,80 @@
1import { Component } from 'react';
2import injectSheet, { withTheme } from 'react-jss';
3import classnames from 'classnames';
4
5import FullscreenLoader from '../FullscreenLoader';
6import { shuffleArray } from '../../../helpers/array-helpers';
7
8import styles from './styles';
9
10// TODO: Need to externalize for i18n
11const textList = shuffleArray([
12 'Adding free features',
13 'Making application usable',
14 'Removing unproductive paywalls',
15 'Creating custom server software',
16 'Increasing productivity',
17 'Listening to our userbase',
18 'Fixing bugs',
19]);
20
21type Props = {
22 classes: typeof styles;
23 theme: any;
24 texts: string[];
25};
26
27@injectSheet(styles)
28@withTheme
29class AppLoader extends Component<Props> {
30 static defaultProps = {
31 texts: textList,
32 };
33
34 state = {
35 step: 0,
36 };
37
38 interval: NodeJS.Timeout | null = null;
39
40 componentDidMount() {
41 this.interval = setInterval(() => {
42 this.setState((prevState: { step: number }) => ({
43 step: prevState.step === textList.length - 1 ? 0 : prevState.step + 1,
44 }));
45 }, 2500);
46 }
47
48 componentWillUnmount() {
49 if (this.interval) {
50 clearInterval(this.interval);
51 }
52 }
53
54 render() {
55 const { classes, theme, texts } = this.props;
56 const { step } = this.state;
57
58 return (
59 <FullscreenLoader
60 title="Ferdi"
61 className={classes.component}
62 spinnerColor={theme.colorAppLoaderSpinner}
63 >
64 {texts.map((text, i) => (
65 <span
66 key={text}
67 className={classnames({
68 [`${classes.slogan}`]: true,
69 [`${classes.visible}`]: step === i,
70 })}
71 >
72 {text}
73 </span>
74 ))}
75 </FullscreenLoader>
76 );
77 }
78}
79
80export default AppLoader;