From fbe3a7eeae9d2b2c972ab6d2c30eb7aee41b0ecf Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 12 Aug 2024 06:39:36 +0900 Subject: feat(frontend): improve watch page styling --- frontend/app/components/GolfWatchApp.client.tsx | 4 +- .../GolfWatchApps/GolfWatchAppGaming.tsx | 182 +++++++++++++-------- frontend/app/components/SubmitStatusLabel.tsx | 2 +- 3 files changed, 117 insertions(+), 71 deletions(-) (limited to 'frontend') diff --git a/frontend/app/components/GolfWatchApp.client.tsx b/frontend/app/components/GolfWatchApp.client.tsx index b2f3b69..15b78dc 100644 --- a/frontend/app/components/GolfWatchApp.client.tsx +++ b/frontend/app/components/GolfWatchApp.client.tsx @@ -246,11 +246,13 @@ export default function GolfWatchApp({ } else if (gameState === "gaming") { return ( ); } else if (gameState === "finished") { diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx index f9647b3..c4c3a53 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx @@ -1,21 +1,26 @@ +import { faArrowDown } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { PlayerInfo } from "../../models/PlayerInfo"; +import BorderedContainer from "../BorderedContainer"; import ExecStatusIndicatorIcon from "../ExecStatusIndicatorIcon"; import SubmitStatusLabel from "../SubmitStatusLabel"; type Props = { + gameDisplayName: string; gameDurationSeconds: number; leftTimeSeconds: number; playerInfoA: PlayerInfo; playerInfoB: PlayerInfo; - problem: string; + problemTitle: string; + problemDescription: string; }; export default function GolfWatchAppGaming({ + gameDisplayName, gameDurationSeconds, leftTimeSeconds, playerInfoA, playerInfoB, - problem, }: Props) { const leftTime = (() => { const k = gameDurationSeconds + leftTimeSeconds; @@ -25,96 +30,135 @@ export default function GolfWatchAppGaming({ })(); const scoreRatio = (() => { - const scoreA = playerInfoA.score ?? 0; - const scoreB = playerInfoB.score ?? 0; - const totalScore = scoreA + scoreB; - return totalScore === 0 ? 50 : (scoreB / totalScore) * 100; + const scoreA = playerInfoA.score; + const scoreB = playerInfoB.score; + if (scoreA === null && scoreB === null) { + return 50; + } else if (scoreA === null) { + return 0; + } else if (scoreB === null) { + return 100; + } else { + return (scoreB / (scoreA + scoreB)) * 100; + } })(); return ( -
-
-
- {playerInfoA.displayName} -
-
{leftTime}
-
- {playerInfoB.displayName} -
-
-
-
- {playerInfoA.score} +
+
+
+
+
Player 1
+
{playerInfoA.displayName}
+
+
{playerInfoA.score}
-
-
+
+
{gameDisplayName}
+
{leftTime}
-
- {playerInfoB.score} +
+
{playerInfoB.score}
+
+
Player 2
+
{playerInfoB.displayName}
+
-
-
-
+			
+
+
+
+
+
 						{playerInfoA.code}
 					
-
-
- +
+
+
+ +
-
-
    - {playerInfoA.submitResult?.execResults.map((result) => ( -
  1. -
    +
      + {playerInfoA.submitResult.execResults.map((r, idx) => ( +
    • +
      +
      + +
      + {idx !== playerInfoA.submitResult.execResults.length - 1 && (
      - {" "} - {result.label} +
      + )} +
      +
      + +
      {r.label}
      - {result.stdout} - {result.stderr} + + {r.stdout} + {r.stderr} +
      -
      -
    • - ))} -
-
-
-
-
-						{playerInfoB.code}
-					
+ +
+ + ))} +
-
-
- +
+
+
+ +
-
-
    - {playerInfoB.submitResult?.execResults.map((result, idx) => ( -
  1. -
    +
      + {playerInfoB.submitResult.execResults.map((r, idx) => ( +
    • +
      +
      + +
      + {idx !== playerInfoB.submitResult.execResults.length - 1 && (
      - {" "} - {result.label} +
      + )} +
      +
      + +
      {r.label}
      - {result.stdout} - {result.stderr} + + {r.stdout} + {r.stderr} +
      -
      -
    • - ))} -
-
+ +
+ + ))} + +
+
+
+						{playerInfoB.code}
+					
-
{problem}
); } diff --git a/frontend/app/components/SubmitStatusLabel.tsx b/frontend/app/components/SubmitStatusLabel.tsx index e0ecc27..0e13c1e 100644 --- a/frontend/app/components/SubmitStatusLabel.tsx +++ b/frontend/app/components/SubmitStatusLabel.tsx @@ -7,7 +7,7 @@ type Props = { export default function SubmitStatusLabel({ status }: Props) { switch (status) { case "waiting_submission": - return null; + return "提出待ち"; case "running": return "実行中..."; case "success": -- cgit v1.2.3-70-g09d2