2020-01-09 10:06:38 +01:00
|
|
|
import React, {useContext} from "react"
|
2020-01-22 07:58:35 +01:00
|
|
|
import {GameModeContext} from "../contexts/gameModeContext"
|
|
|
|
|
import { MorseBufferContext } from "../contexts/morseBufferContext"
|
2019-12-27 09:41:53 +01:00
|
|
|
|
|
|
|
|
function ModePicker() {
|
2020-01-09 10:06:38 +01:00
|
|
|
|
2020-01-19 04:35:11 +01:00
|
|
|
const {setGameMode} = useContext(GameModeContext)
|
2020-01-22 07:58:35 +01:00
|
|
|
const {setMorseCharBuffer} = useContext(MorseBufferContext)
|
2020-01-09 10:06:38 +01:00
|
|
|
|
|
|
|
|
function handleClick(e) {
|
2020-01-22 07:58:35 +01:00
|
|
|
setMorseCharBuffer('')
|
2020-01-19 04:35:11 +01:00
|
|
|
setGameMode(e.target.id)
|
2020-01-09 10:06:38 +01:00
|
|
|
console.log("Switched to " + e.target.id + " mode.");
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-27 09:41:53 +01:00
|
|
|
return (
|
2020-01-17 21:23:17 +01:00
|
|
|
<div id="gameMode" className="mode-picker">
|
2020-01-28 10:13:32 +01:00
|
|
|
<button id="practice" class="selected" onClick={handleClick}>
|
2020-01-09 10:06:38 +01:00
|
|
|
Practice
|
|
|
|
|
</button>
|
2020-01-25 08:32:08 +01:00
|
|
|
<button id="training" onClick={handleClick}>
|
|
|
|
|
Training Mode
|
2020-01-09 10:06:38 +01:00
|
|
|
</button>
|
|
|
|
|
<button id="challenge" onClick={handleClick}>
|
|
|
|
|
Challenge Mode
|
|
|
|
|
</button>
|
2020-01-03 08:53:56 +01:00
|
|
|
</div>
|
2019-12-27 09:41:53 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-14 11:37:04 +01:00
|
|
|
export default React.memo(ModePicker)
|