@@ -2,8 +2,9 @@ import React, { Fragment } from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
import styled from 'styled-components' ;
4
4
import { connect } from 'react-redux' ;
5
+ import { start } from '../actions/start' ;
5
6
import { restart } from '../actions/restart' ;
6
- import { getCurrent , getAnswers } from '../selectors' ;
7
+ import { getIntro , getCurrent , getAnswers } from '../selectors' ;
7
8
import ButtonContainer from '../components/ButtonContainer' ;
8
9
import ProgressBar from '../components/ProgressBar' ;
9
10
import Code from '../components/Code' ;
@@ -35,7 +36,7 @@ const ShareContainer = styled.p`
35
36
text-align: center;
36
37
` ;
37
38
38
- const Game = ( { current, answers, style, onRestart } ) => {
39
+ const Game = ( { intro , current, answers, style, onStart , onRestart } ) => {
39
40
let correct ;
40
41
41
42
if ( ! current ) {
@@ -44,13 +45,17 @@ const Game = ({ current, answers, style, onRestart }) => {
44
45
45
46
return (
46
47
< Fragment >
47
- { current ? (
48
+ { intro && < Button label = "Start" id = "start" onClick = { onStart } /> }
49
+
50
+ { ! intro && current && (
48
51
< Fragment >
49
52
< ProgressBar />
50
53
< Code style = { style } />
51
54
< ButtonContainer />
52
55
</ Fragment >
53
- ) : (
56
+ ) }
57
+
58
+ { ! intro && ! current && (
54
59
< Fragment >
55
60
< Result />
56
61
< Percentage />
@@ -82,17 +87,21 @@ const Game = ({ current, answers, style, onRestart }) => {
82
87
83
88
Game . propTypes = {
84
89
style : PropTypes . object . isRequired ,
90
+ onStart : PropTypes . func . isRequired ,
85
91
onRestart : PropTypes . func . isRequired ,
86
92
answers : PropTypes . array . isRequired ,
93
+ intro : PropTypes . bool . isRequired ,
87
94
current : PropTypes . object
88
95
} ;
89
96
90
97
export default connect (
91
98
state => ( {
99
+ intro : getIntro ( state ) ,
92
100
current : getCurrent ( state ) ,
93
101
answers : getAnswers ( state )
94
102
} ) ,
95
103
{
104
+ onStart : ( ) => start ( ) ,
96
105
onRestart : ( ) => restart ( )
97
106
}
98
107
) ( Game ) ;
0 commit comments