Skip to content

Commit

Permalink
simple main page changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Micsushi committed Jul 16, 2024
1 parent afdde14 commit 22551bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
23 changes: 18 additions & 5 deletions components/BananaMath/MonkeyMath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +24,7 @@ export default function MonkeyMath() {
const [result, setResult] = useState<number | null>(null);
const [isCorrect, setIsCorrect] = useState<boolean | null>(null);
const [timerEnded, setTimerEnded] = useState<boolean>(false);
const [timeLeft, setTimeLeft] = useState<number>(10); // Start the timer at 10 seconds
const [timeLeft, setTimeLeft] = useState<number>(COUNT_DOWN_TIME);
const [timerStarted, setTimerStarted] = useState<boolean>(false);
const [correctCount, setCorrectCount] = useState<number>(0);
const [totalCount, setTotalCount] = useState<number>(0);
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -121,7 +122,7 @@ export default function MonkeyMath() {
<div className="mb-6 text-center">
{/* <p className="mb-5 text-2xl">{problem}</p> */}
<p
className="text-xl text-gray-700"
className="text-x1 white"
style={{ visibility: timerStarted ? "visible" : "hidden" }}
>
{timeLeft}
Expand All @@ -134,7 +135,19 @@ export default function MonkeyMath() {
{problem}
</p>
<p
className="text-center text-2xl text-gray-700"
className="text-center text-2xl white"
hidden={!timerEnded}
>
Correct answers: {correctCount}
</p>
<p
className="text-center text-2xl white"
hidden={!timerEnded}
>
Incorrect answers: {totalCount - correctCount}
</p>
<p
className="text-center text-2xl white"
hidden={!timerEnded}
>
{totalCount > 0
Expand Down Expand Up @@ -164,7 +177,7 @@ export default function MonkeyMath() {
onClick={() => {
promptMathProblem();
setTimerStarted(false);
setTimeLeft(10); // Reset the timer to 10 seconds
setTimeLeft(COUNT_DOWN_TIME);
setTimerEnded(false);
setCorrectCount(0);
setTotalCount(0);
Expand Down
16 changes: 12 additions & 4 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import React from 'react';
const Footer = () => (
<footer className="mt-8 flex w-full items-center justify-between text-sm text-zinc-400">
<div className="flex space-x-2">
<button>Contact</button>
<button>Support</button>
<button>GitHub</button>
<button>Twitter</button>
<a href="https://mail.google.com/" target="_blank">
<button>Contact</button>
</a>
<a href="https://mail.google.com/" target="_blank">
<button>Support</button>
</a>
<a href="https://github.com/Gym-Bros-Programs/banana-math" target="_blank">
<button>GitHub</button>
</a>
<a href="https://x.com/?lang=en" target="_blank">
<button>Twitter</button>
</a>
</div>
<div>
<span>v0.0.1</span>
Expand Down

0 comments on commit 22551bc

Please sign in to comment.