diff options
Diffstat (limited to 'src/components/ui/AppLoader')
-rw-r--r-- | src/components/ui/AppLoader/index.js | 69 | ||||
-rw-r--r-- | src/components/ui/AppLoader/styles.js | 16 |
2 files changed, 85 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 | |||
diff --git a/src/components/ui/AppLoader/styles.js b/src/components/ui/AppLoader/styles.js new file mode 100644 index 000000000..755a56b40 --- /dev/null +++ b/src/components/ui/AppLoader/styles.js | |||
@@ -0,0 +1,16 @@ | |||
1 | export default { | ||
2 | component: { | ||
3 | color: '#FFF', | ||
4 | }, | ||
5 | slogan: { | ||
6 | display: 'block', | ||
7 | opacity: 0, | ||
8 | transition: 'opacity 1s ease', | ||
9 | position: 'absolute', | ||
10 | textAlign: 'center', | ||
11 | width: '100%', | ||
12 | }, | ||
13 | visible: { | ||
14 | opacity: 1, | ||
15 | }, | ||
16 | }; | ||