diff --git a/src/BoardSwitcher.js b/src/BoardSwitcher.js index 61ad96f..73d959f 100644 --- a/src/BoardSwitcher.js +++ b/src/BoardSwitcher.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; class Board extends React.Component { render() { @@ -6,28 +6,43 @@ class Board extends React.Component { if (this.props.selected) { className += " selected"; } - return ( -
- {this.props.index + 1} -
- ); + return
{this.props.index + 1}
; } } class BoardSwitcher extends React.Component { + constructor(props) { + super(props); + this.state = { + clicks: 0, + }; + } + + handleClick(event) { + this.setState({ + clicks: this.state.clicks + 1, + }); + } + render() { let boards = []; for (let ii = 0; ii < this.props.numBoards; ii++) { - let isSelected = ii === 0; - boards.push( - - ); + //check if the index matches the clicks number then state its true and display the border around the clicked BoardSwitcher + let isSelected = ii === this.state.clicks; + boards.push(); + //once the clicks go past numofBoards reset to default start + if (this.state.clicks === this.props.numBoards) { + this.setState({ + clicks: 0, + }); + } } return (
{boards}
- + {/*on click return */} +
); }