diff options
author | 2018-12-08 17:09:12 +0100 | |
---|---|---|
committer | 2018-12-08 17:09:12 +0100 | |
commit | 7ab7605c220c665607844784ffbf21a030888f8e (patch) | |
tree | 5285647db76b4cc16444d2fb81b7fb0585367416 /src/components/ui/AppLoader/index.js | |
parent | feat(Service): Add error screen for services that failed to load (diff) | |
download | ferdium-app-7ab7605c220c665607844784ffbf21a030888f8e.tar.gz ferdium-app-7ab7605c220c665607844784ffbf21a030888f8e.tar.zst ferdium-app-7ab7605c220c665607844784ffbf21a030888f8e.zip |
Revamp app loaders
Diffstat (limited to 'src/components/ui/AppLoader/index.js')
-rw-r--r-- | src/components/ui/AppLoader/index.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/components/ui/AppLoader/index.js b/src/components/ui/AppLoader/index.js new file mode 100644 index 000000000..61f97d4f9 --- /dev/null +++ b/src/components/ui/AppLoader/index.js | |||
@@ -0,0 +1,69 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import injectSheet from 'react-jss'; | ||
4 | import classnames from 'classnames'; | ||
5 | |||
6 | import FullscreenLoader from '../FullscreenLoader'; | ||
7 | import { shuffleArray } from '../../../helpers/array-helpers'; | ||
8 | |||
9 | import styles from './styles'; | ||
10 | |||
11 | const textList = shuffleArray([ | ||
12 | 'Looking for Sisi', | ||
13 | 'Contacting the herald', | ||
14 | 'Saddling the unicorn', | ||
15 | 'Learning the Waltz', | ||
16 | 'Visiting Horst & Grete', | ||
17 | 'Twisting my moustache', | ||
18 | 'Playing the trumpet', | ||
19 | 'Traveling through space & time', | ||
20 | ]); | ||
21 | |||
22 | export default @injectSheet(styles) class AppLoader extends Component { | ||
23 | static propTypes = { | ||
24 | classes: PropTypes.object.isRequired, | ||
25 | } | ||
26 | |||
27 | state = { | ||
28 | step: 0, | ||
29 | } | ||
30 | |||
31 | componentDidMount() { | ||
32 | this.interval = setInterval(() => { | ||
33 | this.setState({ | ||
34 | step: this.state.step === textList.length - 1 ? 0 : this.state.step + 1, | ||
35 | }); | ||
36 | }, 2500); | ||
37 | } | ||
38 | |||
39 | componentWillUnmount() { | ||
40 | clearInterval(this.interval); | ||
41 | } | ||
42 | |||
43 | interval = null; | ||
44 | |||
45 | render() { | ||
46 | const { classes } = this.props; | ||
47 | const { step } = this.state; | ||
48 | |||
49 | return ( | ||
50 | <FullscreenLoader | ||
51 | title="Franz" | ||
52 | className={classes.component} | ||
53 | > | ||
54 | {textList.map((text, i) => ( | ||
55 | <span | ||
56 | key={i} | ||
57 | className={classnames({ | ||
58 | [`${classes.slogan}`]: true, | ||
59 | [`${classes.visible}`]: step === i, | ||
60 | })} | ||
61 | > | ||
62 | {text} | ||
63 | </span> | ||
64 | ))} | ||
65 | </FullscreenLoader> | ||
66 | ); | ||
67 | } | ||
68 | } | ||
69 | |||