Skip to content

Commit 99bf10e

Browse files
Merge pull request #80 from su-its/feat/game-screen/result-screen-button
feat: リザルト画面で「ゲームを終了する」ボタンの追加
2 parents 80adaf1 + eece7ae commit 99bf10e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

typing-app/src/components/templates/GameResult.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ import { ResultScore } from "@/types/RegisterScore";
22
import { Button, Grid, GridItem, Text } from "@chakra-ui/react";
33
import React from "react";
44
import styles from "./GameResult.module.css";
5+
import { useRouter } from "next/navigation";
56

67
interface GameResultProps {
78
nextPage: () => void;
89
resultScore: ResultScore;
910
}
1011

1112
const GameResult: React.FC<GameResultProps> = ({ nextPage, resultScore }) => {
13+
const router = useRouter();
14+
15+
const pushToRoot = () => {
16+
router.push("/");
17+
};
18+
1219
return (
1320
<div className={styles.box}>
1421
<Grid h="100%" w="100%" templateRows="repeat(10, 1fr)" templateColumns="repeat(10, 1fr)" gap={6} bg="white">
@@ -86,9 +93,14 @@ const GameResult: React.FC<GameResultProps> = ({ nextPage, resultScore }) => {
8693
{resultScore.accuracy.toFixed(1)}%
8794
</Text>
8895
</GridItem>
89-
<GridItem colSpan={4} rowSpan={2} colStart={4} rowStart={9} className={styles.centerText}>
90-
<Button onClick={nextPage} colorScheme="blue" size="lg" w="100%" h="90%">
91-
次へ
96+
<GridItem colSpan={4} rowSpan={2} colStart={2} rowStart={9} className={styles.centerText}>
97+
<Button onClick={pushToRoot} colorScheme="red" size="lg" w="80%" h="90%">
98+
ゲームを終了する
99+
</Button>
100+
</GridItem>
101+
<GridItem colSpan={4} rowSpan={2} colStart={6} rowStart={9} className={styles.centerText}>
102+
<Button onClick={nextPage} colorScheme="blue" size="lg" w="80%" h="90%">
103+
もう一度プレイする
92104
</Button>
93105
</GridItem>
94106
</Grid>

0 commit comments

Comments
 (0)