diff --git a/learn/src/components/AlphabetTableDialog.tsx b/learn/src/components/AlphabetTableDialog.tsx index d930705c..c45ef5ec 100644 --- a/learn/src/components/AlphabetTableDialog.tsx +++ b/learn/src/components/AlphabetTableDialog.tsx @@ -2,13 +2,13 @@ import { useState } from "react"; import { Typography, Box, - Button, Table, TableRow, TableCell, Paper, } from "@mui/material"; import { alphabetTable } from "@/utils/translateBraille"; +import CommonButton from "./CommonButton"; export default function AlphabetTableDialog(): JSX.Element { const [isAlphabetTableOpen, setIsAlphabetTableOpen] = @@ -17,15 +17,14 @@ export default function AlphabetTableDialog(): JSX.Element { {isAlphabetTableOpen ? ( <> - + @@ -97,15 +96,14 @@ export default function AlphabetTableDialog(): JSX.Element { ) : ( - + )} ); diff --git a/learn/src/components/BottomStepper.tsx b/learn/src/components/BottomStepper.tsx index c60a38a2..88d50817 100644 --- a/learn/src/components/BottomStepper.tsx +++ b/learn/src/components/BottomStepper.tsx @@ -1,6 +1,7 @@ import { type Dispatch, type SetStateAction } from "react"; import { useRouter } from "next/router"; -import { BottomNavigation, Button, MobileStepper } from "@mui/material"; +import { BottomNavigation, MobileStepper } from "@mui/material"; +import CommonButton from "./CommonButton"; export default function BottomStepper({ selectedStep, @@ -20,8 +21,7 @@ export default function BottomStepper({ position="bottom" activeStep={selectedStep} backButton={ - + } nextButton={ selectedStep !== length - 1 ? ( - + ) : ( - + ) } /> diff --git a/learn/src/components/CommonButton.tsx b/learn/src/components/CommonButton.tsx new file mode 100644 index 00000000..939e8ba2 --- /dev/null +++ b/learn/src/components/CommonButton.tsx @@ -0,0 +1,44 @@ +import { MouseEventHandler } from "react"; + +type CommonButtonProps = { + disabled?: boolean | undefined; + onClick?: MouseEventHandler | undefined; + variant?: "outlined" | "contained"; + children: React.ReactNode; +}; + +function CommonButton(props: CommonButtonProps) { + const { disabled, onClick, variant, children } = props; + const baseClassName = + "mb-1 rounded border px-4 py-2 text-center font-medium "; + let className = baseClassName; + + if (disabled) { + if (variant === "contained") { + className += "text-white bg-blue-300 dark:bg-white dark:text-blue-300"; + } else { + className += + "border-blue-300 text-blue-300 dark:border-blue-300 dark:text-blue-300"; + } + } else if (!disabled) { + if (variant === "contained") { + className += "text-white bg-blue-500 hover:text-blue-500 hover:bg-white"; + } else { + className += + "border-blue-500 text-blue-500 hover:bg-blue-500 hover:text-white focus:outline-none focus:ring-4 focus:ring-blue-300"; + } + } + + return ( + + ); +} + +export default CommonButton; diff --git a/learn/src/components/HiraganaTableDialog.tsx b/learn/src/components/HiraganaTableDialog.tsx index db938cc5..4250a4cc 100644 --- a/learn/src/components/HiraganaTableDialog.tsx +++ b/learn/src/components/HiraganaTableDialog.tsx @@ -2,7 +2,6 @@ import { useState } from "react"; import { Typography, Box, - Button, Table, TableHead, TableRow, @@ -10,6 +9,7 @@ import { Paper, } from "@mui/material"; import { hiraganaTable } from "@/utils/translateBraille"; +import CommonButton from "./CommonButton"; export default function HiraganaTableDialog(): JSX.Element { const [isHiraganaTableOpen, setIsHiraganaTableOpen] = @@ -18,15 +18,14 @@ export default function HiraganaTableDialog(): JSX.Element { {isHiraganaTableOpen ? ( <> - + @@ -208,15 +207,14 @@ export default function HiraganaTableDialog(): JSX.Element { ) : ( - + )} ); diff --git a/learn/src/components/PracticeField.tsx b/learn/src/components/PracticeField.tsx index f233f9f1..addf2988 100644 --- a/learn/src/components/PracticeField.tsx +++ b/learn/src/components/PracticeField.tsx @@ -1,8 +1,9 @@ import React, { useState, useEffect } from "react"; import useTypedBrailleString from "@/hooks/useTypedBrailleString"; import translateBraille from "@/utils/translateBraille"; -import { TextField, Typography, Box, Button } from "@mui/material"; +import { TextField, Typography, Box } from "@mui/material"; import { BrailleArray } from "@dot-tutor/braille"; +import CommonButton from "./CommonButton"; export default function PracticeField({ question, @@ -42,7 +43,7 @@ export default function PracticeField({ - + {answered diff --git a/learn/src/components/TenjiInput.tsx b/learn/src/components/TenjiInput.tsx index 81259cb5..2dd218fa 100644 --- a/learn/src/components/TenjiInput.tsx +++ b/learn/src/components/TenjiInput.tsx @@ -18,6 +18,7 @@ export default function TenjiInput(props: { const oncePressedKeysRef = useRef(new Set()); return ( setValue((e.target.value.match(/[⠀-⣿]/g) ?? [""]).join("")) diff --git a/learn/src/components/TopBar.tsx b/learn/src/components/TopBar.tsx index f674e19f..795cd091 100644 --- a/learn/src/components/TopBar.tsx +++ b/learn/src/components/TopBar.tsx @@ -8,12 +8,12 @@ import { Toolbar, Stack, Typography, - Button, Link, IconButton, } from "@mui/material"; import GitHubIcon from "@mui/icons-material/GitHub"; import { type TutorialDialogSteps } from "../types/Tutorial"; +import CommonButton from "./CommonButton"; export default function TopBar({ tutorialDialogSteps, @@ -58,15 +58,14 @@ export default function TopBar({ {tutorialDialogSteps !== undefined && ( <> - + - - + {selectedStep === tutorialDialogSteps.length - 1 && ( - + )} diff --git a/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx b/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx index 2691c92e..c14ff575 100644 --- a/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx +++ b/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx @@ -1,21 +1,12 @@ import React, { useState, useEffect, useRef } from "react"; -import { - Paper, - Divider, - Box, - Typography, - Button, - Stack, - Accordion, - AccordionSummary, - AccordionDetails, -} from "@mui/material"; +import { Accordion, AccordionSummary, AccordionDetails } from "@mui/material"; import translateBraille from "@/utils/translateBraille"; import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline"; import RefreshIcon from "@mui/icons-material/Refresh"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import TenjiInput from "@/components/TenjiInput"; import { BrailleArray } from "@dot-tutor/braille"; +import CommonButton from "@/components/CommonButton"; interface Question { question: string; @@ -86,74 +77,67 @@ export default function Tutorial1({ setQuestionIndex(0); }, [questionList]); + const sectionClass = "mb-8 rounded pt-3 shadow"; + const sectionTitleClass = "mb-3 ml-3 text-xl font-bold"; + const sectionTextClass = "min-h-24 p-3"; + return ( <> - - - 問題 - - - +
+

問題

+
+

{questionList !== undefined && (questionIndex >= questionList.length ? "すべての問題を解きました!" : `「${questionList[questionIndex].question}」を入力してください。`)} - - +

+
- - - - 点字を入力 - - - - - + + +
+
- - +
+ - - - 翻訳 - - - +
+

翻訳

+
+
{translatedBrailleString} {goNextQuestion && } - - +
+
{questionList !== undefined && questionList[questionIndex] !== undefined && questionList[questionIndex].hint !== undefined && ( - +
}> - - ヒント - - +

ヒント

+
- {questionList[questionIndex].hint} +

{questionList[questionIndex].hint}

- +
)} - + ); }