From 011899dd95f1d089d799171cf9c33150f019fb14 Mon Sep 17 00:00:00 2001 From: brdgb Date: Sat, 2 Mar 2024 12:25:44 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=A7=E9=83=A8=E5=88=86=E3=82=92tailwin?= =?UTF-8?q?d=20css=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- learn/src/components/TenjiInput.tsx | 1 + .../keyboard/tutorial/tutorial1/index.tsx | 89 ++++++++----------- 2 files changed, 37 insertions(+), 53 deletions(-) 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/pages/keyboard/tutorial/tutorial1/index.tsx b/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx index 2691c92e..157355b1 100644 --- a/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx +++ b/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx @@ -1,15 +1,5 @@ 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"; @@ -86,74 +76,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}

- +
)} - + ); } From 69167abfa3b6b7d4e574eccc655a526f0c776b2c Mon Sep 17 00:00:00 2001 From: brdgb Date: Mon, 8 Apr 2024 22:02:50 +0900 Subject: [PATCH 2/3] =?UTF-8?q?common=20button=20=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- learn/src/components/BottomStepper.tsx | 15 +++---- learn/src/components/CommonButton.tsx | 45 +++++++++++++++++++ .../keyboard/tutorial/tutorial1/index.tsx | 10 ++--- 3 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 learn/src/components/CommonButton.tsx diff --git a/learn/src/components/BottomStepper.tsx b/learn/src/components/BottomStepper.tsx index c60a38a2..28d36a98 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 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..caae623e --- /dev/null +++ b/learn/src/components/CommonButton.tsx @@ -0,0 +1,45 @@ +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-800 hover:text-blue-700 hover:bg-white dark:bg-white dark:text-blue-700"; + } else { + className += + "border-blue-700 text-blue-700 hover:bg-blue-800 hover:text-white focus:outline-none focus:ring-4 focus:ring-blue-300 dark:border-blue-500 dark:text-blue-500 dark:hover:bg-blue-500 dark:hover:text-white dark:focus:ring-blue-800"; + } + } + + return ( + + ); +} + +export default CommonButton; diff --git a/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx b/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx index 157355b1..c14ff575 100644 --- a/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx +++ b/learn/src/pages/keyboard/tutorial/tutorial1/index.tsx @@ -6,6 +6,7 @@ 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; @@ -96,10 +97,10 @@ export default function Tutorial1({

点字を入力

- +

@@ -136,7 +137,7 @@ export default function Tutorial1({
)} - + ); } From 086a5a3e20d6be5081ef23041802e2afecfb7806 Mon Sep 17 00:00:00 2001 From: brdgb Date: Mon, 15 Apr 2024 22:07:23 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Common=20button=E3=82=92=E9=81=A9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- learn/src/components/AlphabetTableDialog.tsx | 12 +++++------- learn/src/components/BottomStepper.tsx | 2 +- learn/src/components/CommonButton.tsx | 5 ++--- learn/src/components/HiraganaTableDialog.tsx | 12 +++++------- learn/src/components/PracticeField.tsx | 7 ++++--- learn/src/components/TopBar.tsx | 9 ++++----- learn/src/components/TutorialDialog.tsx | 14 +++++++------- 7 files changed, 28 insertions(+), 33 deletions(-) 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 28d36a98..88d50817 100644 --- a/learn/src/components/BottomStepper.tsx +++ b/learn/src/components/BottomStepper.tsx @@ -1,6 +1,6 @@ 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({ diff --git a/learn/src/components/CommonButton.tsx b/learn/src/components/CommonButton.tsx index caae623e..939e8ba2 100644 --- a/learn/src/components/CommonButton.tsx +++ b/learn/src/components/CommonButton.tsx @@ -22,11 +22,10 @@ function CommonButton(props: CommonButtonProps) { } } else if (!disabled) { if (variant === "contained") { - className += - "text-white bg-blue-800 hover:text-blue-700 hover:bg-white dark:bg-white dark:text-blue-700"; + className += "text-white bg-blue-500 hover:text-blue-500 hover:bg-white"; } else { className += - "border-blue-700 text-blue-700 hover:bg-blue-800 hover:text-white focus:outline-none focus:ring-4 focus:ring-blue-300 dark:border-blue-500 dark:text-blue-500 dark:hover:bg-blue-500 dark:hover:text-white dark:focus:ring-blue-800"; + "border-blue-500 text-blue-500 hover:bg-blue-500 hover:text-white focus:outline-none focus:ring-4 focus:ring-blue-300"; } } 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/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 && ( - + )}