From 22551bc0ce5bf8f8767cfff86155c8c8c92ac362 Mon Sep 17 00:00:00 2001 From: "Wenjian(Michael) Shi" <61084115+Micsushi@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:46:38 -0600 Subject: [PATCH] simple main page changes --- components/BananaMath/MonkeyMath.tsx | 23 ++++++++++++++++++----- components/Footer.tsx | 16 ++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/components/BananaMath/MonkeyMath.tsx b/components/BananaMath/MonkeyMath.tsx index b0e041d..74daae3 100644 --- a/components/BananaMath/MonkeyMath.tsx +++ b/components/BananaMath/MonkeyMath.tsx @@ -14,6 +14,7 @@ function getRandomNumber(min: number, max: number): number { } const TEXT_CLASS = "text-zinc-400 hover:text-zinc-200"; +const COUNT_DOWN_TIME = 30; export default function MonkeyMath() { // State variables @@ -23,7 +24,7 @@ export default function MonkeyMath() { const [result, setResult] = useState(null); const [isCorrect, setIsCorrect] = useState(null); const [timerEnded, setTimerEnded] = useState(false); - const [timeLeft, setTimeLeft] = useState(10); // Start the timer at 10 seconds + const [timeLeft, setTimeLeft] = useState(COUNT_DOWN_TIME); const [timerStarted, setTimerStarted] = useState(false); const [correctCount, setCorrectCount] = useState(0); const [totalCount, setTotalCount] = useState(0); @@ -93,7 +94,7 @@ export default function MonkeyMath() { // Update the timer every second once it has started useEffect(() => { // Focus the input field when the component mounts - if (inputRef.current) { + if (inputRef.current && timeLeft > 0) { (inputRef.current as unknown as HTMLInputElement).focus(); } @@ -121,7 +122,7 @@ export default function MonkeyMath() {
{/*

{problem}

*/}

{timeLeft} @@ -134,7 +135,19 @@ export default function MonkeyMath() { {problem}

+ +