diff --git a/src/components/BoardSwitcher.jsx b/src/components/BoardSwitcher.jsx index e99793a..4eee84b 100644 --- a/src/components/BoardSwitcher.jsx +++ b/src/components/BoardSwitcher.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; function Board(props) { let className = "board"; @@ -6,20 +6,32 @@ function Board(props) { className += " selected"; } - return
{props.index + 1}
; + return
{props.index + 1}
; } function BoardSwitcher(props) { + + const [selectedBoardIndex, setSelectedBoardIndex] = useState(0); + const handleClick = (event) => { + if(selectedBoardIndex === props.numBoards - 1){ + setSelectedBoardIndex(0); + } + else { + setSelectedBoardIndex(selectedBoardIndex + 1); + } + +} + let boards = []; - for (let ii = 0; ii < props.numBoards; ii++) { - let isSelected = ii === 0; - boards.push(); + for (let boardIndex = 0; boardIndex < props.numBoards; boardIndex++) { + let isSelected = boardIndex === selectedBoardIndex; + boards.push(); } return (
{boards}
- +
); } diff --git a/src/main.jsx b/src/main.jsx index 782f402..316ad56 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -6,6 +6,6 @@ import "./index.css"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( - + );