Skip to content

Commit

Permalink
Challenge and Code: Interactive Instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Oct 23, 2022
1 parent 48f66eb commit 70e05f1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions evens-or-odds/src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { startGame, cancelGame } from '../actions/settings';
import Instructions from './Instructions';

class App extends Component {
render() {
Expand All @@ -21,6 +22,8 @@ class App extends Component {
<h3>A new game awaits</h3>
<br />
<button onClick={this.props.startGame}>Start Game</button>
<hr />
<Instructions />
</div>
)
}
Expand Down
34 changes: 34 additions & 0 deletions evens-or-odds/src/components/Instructions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { connect } from 'react-redux';
import { expandInstructions, collapseInstructions } from '../actions/settings';

const Instructions = props => {
const { instructionsExpanded, expandInstructions, collapseInstructions } = props;

if (instructionsExpanded) {
return (
<div>
<h3>Instructions</h3>
<p>Welcome to evens or odds. The game goes like this</p>
<p>The deck is shuffled. Then choose. will the next card be even or odd?</p>
<p>Make a choive on every draw, and see how many you get right!</p>
<p>(Face cards don't count)</p>
<br />
<button onClick={collapseInstructions}>Show less</button>
</div>
)
}

return (
<div>
<h3>Instructions</h3>
<p>Welcome to evens or odds. The game goes like this...</p>
<button onClick={expandInstructions}>Read more</button>
</div>
)
}

export default connect(
state => ({ instructionsExpanded: state.instructionsExpanded }),
{ expandInstructions, collapseInstructions }
)(Instructions);

0 comments on commit 70e05f1

Please sign in to comment.