From e1b9a557b2fbd57896dbb7c4f424376677157cf4 Mon Sep 17 00:00:00 2001 From: ShaniyaS13 <57805735+ShaniyaS13@users.noreply.github.com> Date: Wed, 29 Sep 2021 00:10:51 -0400 Subject: [PATCH] Add files via upload --- BoardSwitcher.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 BoardSwitcher.js 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; + + + + + + + + + + + + + + + + + +