Commit 0337167c authored by Alexander Kotov's avatar Alexander Kotov

add undo redu buttons

parent 12df4a1d
......@@ -6,4 +6,8 @@
.Toolbar>span {
padding: 0 2rem;
}
.Toolbar button {
margin-right: 10px;
}
\ No newline at end of file
import React from 'react'
import { connect } from 'react-redux'
import { ActionCreators } from 'redux-undo';
import { startNewGame } from '../../actions/gameActions';
import './Toolbar.css'
......@@ -11,14 +12,22 @@ const Toolbar = (props) => {
<span>
Moves: {props.moveCount}
</span>
<button disabled={!props.past} onClick={props.undo}>undo</button>
<button disabled={!props.future} onClick={props.redo}>redo</button>
</div>
)
}
const mapStateToProps = (state) => {
return {
moveCount: state.game.present.moves
moveCount: state.game.present.moves,
past: state.game.past.length,
future: state.game.future.length
}
}
export default connect( mapStateToProps, { startNewGame })(Toolbar)
export default connect( mapStateToProps, {
startNewGame,
undo: ActionCreators.undo,
redo: ActionCreators.redo
})(Toolbar)
......@@ -20,3 +20,8 @@ button:hover {
background-color: #0069d9;
border-color: #0062cc;
}
button:disabled {
background-color: lightgrey;
border-color: darkgray;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment