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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
import { Component } from 'react';
import classnames from 'classnames';
import injectStyle from 'react-jss';
import FullscreenLoader from '../FullscreenLoader';
import { shuffleArray } from '../../../helpers/array-helpers';
import styles from './styles';
// TODO: Need to externalize for i18n
const textList = shuffleArray([
'Adding free features',
'Making application usable',
'Removing unproductive paywalls',
'Creating custom server software',
'Increasing productivity',
'Listening to our userbase',
'Fixing bugs',
]);
type Props = {
classes: typeof styles;
theme: any;
texts: string[];
};
class AppLoader extends Component<Props> {
static defaultProps = {
texts: textList,
};
state = {
step: 0,
};
interval: NodeJS.Timeout | null = null;
componentDidMount() {
this.interval = setInterval(() => {
this.setState((prevState: { step: number }) => ({
step: prevState.step === textList.length - 1 ? 0 : prevState.step + 1,
}));
}, 2500);
}
componentWillUnmount() {
if (this.interval) {
clearInterval(this.interval);
}
}
render() {
const { classes, theme, texts } = this.props;
const { step } = this.state;
return (
<FullscreenLoader
title="Ferdi"
className={classes.component}
spinnerColor={theme.colorAppLoaderSpinner}
>
{texts.map((text, i) => (
<span
key={text}
className={classnames({
[`${classes.slogan}`]: true,
[`${classes.visible}`]: step === i,
})}
>
{text}
</span>
))}
</FullscreenLoader>
);
}
}
export default injectStyle(styles, { injectTheme: true })(AppLoader);
|