diff --git a/BoardSwitcher.js b/BoardSwitcher.js new file mode 100644 index 0000000..206d0fb --- /dev/null +++ b/BoardSwitcher.js @@ -0,0 +1,69 @@ +import React from 'react'; + +class Board extends React.Component { + render() { + let className = "board"; + if (this.props.selected) { + className += " selected"; + } + return ( +
+ {this.props.index + 1} +
+ ); + } +} + +class BoardSwitcher extends React.Component { + + constructor(props) { + super(props); // required so that props work + this.state = {clicks: 0,}; + } + + handleClick(event) { + this.setState({ + clicks: this.state.clicks + 1 + }); + if(this.state.clicks > 1){ + this.setState({ + clicks: 0 + }); + } + } + render() { + let boards = []; + for (let ii = 0; ii < this.props.numBoards; ii++) { + let isSelected = ii === this.state.clicks; + boards.push( + + ); + } + return ( +
+
{boards}
+ +
+ ); + } +} + +export default BoardSwitcher; + + + + + + + + + + + + + + + + + +