diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-17 19:08:58 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-17 19:08:58 +0900 |
| commit | 4615ca9b8b1989d315ae2322556697b97161b97b (patch) | |
| tree | 693170d89d6c6d56982dbacf4e88495297d20ce6 /frontend | |
| parent | 516e81953173ced9209ebea955b86da589e5f2f6 (diff) | |
| download | iosdc-japan-2025-albatross-4615ca9b8b1989d315ae2322556697b97161b97b.tar.gz iosdc-japan-2025-albatross-4615ca9b8b1989d315ae2322556697b97161b97b.tar.zst iosdc-japan-2025-albatross-4615ca9b8b1989d315ae2322556697b97161b97b.zip | |
feat(frontend): apply effect for high score
Diffstat (limited to 'frontend')
| -rw-r--r-- | frontend/app/components/Gaming/Score.tsx | 38 | ||||
| -rw-r--r-- | frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx | 9 |
2 files changed, 45 insertions, 2 deletions
diff --git a/frontend/app/components/Gaming/Score.tsx b/frontend/app/components/Gaming/Score.tsx new file mode 100644 index 0000000..9b6283f --- /dev/null +++ b/frontend/app/components/Gaming/Score.tsx @@ -0,0 +1,38 @@ +import { useEffect, useState } from "react"; + +type Props = { + status: string | null; + score: number | null; +}; + +export default function Score({ status, score }: Props) { + const [displayScore, setDisplayScore] = useState(score); + + useEffect(() => { + let intervalId = null; + + if (status === "running") { + intervalId = setInterval(() => { + const maxValue = Math.pow(10, String(score).length) - 1; + const minValue = Math.pow(10, String(score).length - 1); + const randomValue = + Math.floor(Math.random() * (maxValue - minValue + 1)) + minValue; + setDisplayScore(randomValue); + }, 50); + } else { + setDisplayScore(score); + } + + return () => { + if (intervalId) { + clearInterval(intervalId); + } + }; + }, [status, score]); + + return ( + <span className={status === "running" ? "animate-pulse" : ""}> + {displayScore} + </span> + ); +} diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx index f06728d..4a9cf92 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx @@ -13,6 +13,7 @@ import CodeBlock from "../Gaming/CodeBlock"; import LeftTime from "../Gaming/LeftTime"; import ProblemColumnContent from "../Gaming/ProblemColumnContent"; import RankingTable from "../Gaming/RankingTable"; +import Score from "../Gaming/Score"; import ScoreBar from "../Gaming/ScoreBar"; import SubmitStatusLabel from "../SubmitStatusLabel"; import ThreeColumnLayout from "../ThreeColumnLayout"; @@ -82,7 +83,9 @@ export default function GolfWatchAppGaming1v1({ {playerProfileA?.displayName} </div> </div> - <div className="text-2xl md:text-6xl">{scoreA}</div> + <div className="text-2xl md:text-6xl"> + <Score status={statusA} score={scoreA} /> + </div> </div> <div className="font-bold text-center"> <div className="text-gray-100">{gameDisplayName}</div> @@ -99,7 +102,9 @@ export default function GolfWatchAppGaming1v1({ )} </div> <div className="font-bold flex gap-4 justify-end md:justify-between items-center my-auto"> - <div className="text-2xl md:text-6xl">{scoreB}</div> + <div className="text-2xl md:text-6xl"> + <Score status={statusB} score={scoreB} /> + </div> <div className="flex gap-6 items-center text-end"> <div className="hidden md:block text-4xl"> {playerProfileB?.displayName} |
