From db23d03e134bad839b23c0518acf937b66834780 Mon Sep 17 00:00:00 2001 From: Sandu Victor Date: Wed, 12 Feb 2020 22:30:27 +0200 Subject: [PATCH] feat: Added a restart button. --- .../src/components/typingBox/typingBox.tsx | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/web/src/components/typingBox/typingBox.tsx b/packages/web/src/components/typingBox/typingBox.tsx index 562016b..0919b7f 100644 --- a/packages/web/src/components/typingBox/typingBox.tsx +++ b/packages/web/src/components/typingBox/typingBox.tsx @@ -192,6 +192,7 @@ export const Box = () => { const [time, setTime] = useState(60) const [cpm, setCpm] = useState(0) const [wpm, setWpm] = useState(0) + // const [showButton, setButton] = useState("none") if (time === 0) { setCpmWpm(cpm, wpm) @@ -210,6 +211,16 @@ export const Box = () => { ) ] } + const resetEverything = () => { + string = "" /// I hate mutating stuff + increment = 0 + color = "green" + stringFullyBackspaced = false + charTyped = 0 + correctedCharTyped = 0 + CPM = 0 + WPM = 0 + } useEffect(() => { setTimeout( @@ -221,6 +232,7 @@ export const Box = () => { ) setTimeout(() => setCpm(calculateCpmWpm()[0]), 1000) setTimeout(() => setWpm(calculateCpmWpm()[1]), 1000) + // setButton(time === 0 ? "inline-block" : "inline-block") }) return ( @@ -242,6 +254,26 @@ export const Box = () => { {" "} {"WPM:"} {wpm} +
+ +
{text}