@@ -2,8 +2,9 @@ import React, { Fragment } from 'react';
22import PropTypes from 'prop-types' ;
33import styled from 'styled-components' ;
44import { connect } from 'react-redux' ;
5+ import { start } from '../actions/start' ;
56import { restart } from '../actions/restart' ;
6- import { getCurrent , getAnswers } from '../selectors' ;
7+ import { getIntro , getCurrent , getAnswers } from '../selectors' ;
78import ButtonContainer from '../components/ButtonContainer' ;
89import ProgressBar from '../components/ProgressBar' ;
910import Code from '../components/Code' ;
@@ -35,7 +36,7 @@ const ShareContainer = styled.p`
3536 text-align: center;
3637` ;
3738
38- const Game = ( { current, answers, style, onRestart } ) => {
39+ const Game = ( { intro , current, answers, style, onStart , onRestart } ) => {
3940 let correct ;
4041
4142 if ( ! current ) {
@@ -44,13 +45,17 @@ const Game = ({ current, answers, style, onRestart }) => {
4445
4546 return (
4647 < Fragment >
47- { current ? (
48+ { intro && < Button label = "Start" id = "start" onClick = { onStart } /> }
49+
50+ { ! intro && current && (
4851 < Fragment >
4952 < ProgressBar />
5053 < Code style = { style } />
5154 < ButtonContainer />
5255 </ Fragment >
53- ) : (
56+ ) }
57+
58+ { ! intro && ! current && (
5459 < Fragment >
5560 < Result />
5661 < Percentage />
@@ -82,17 +87,21 @@ const Game = ({ current, answers, style, onRestart }) => {
8287
8388Game . propTypes = {
8489 style : PropTypes . object . isRequired ,
90+ onStart : PropTypes . func . isRequired ,
8591 onRestart : PropTypes . func . isRequired ,
8692 answers : PropTypes . array . isRequired ,
93+ intro : PropTypes . bool . isRequired ,
8794 current : PropTypes . object
8895} ;
8996
9097export default connect (
9198 state => ( {
99+ intro : getIntro ( state ) ,
92100 current : getCurrent ( state ) ,
93101 answers : getAnswers ( state )
94102 } ) ,
95103 {
104+ onStart : ( ) => start ( ) ,
96105 onRestart : ( ) => restart ( )
97106 }
98107) ( Game ) ;
0 commit comments