From 4d655fc497758ee219a8ff8103223812e73e8d37 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:03:33 +0900 Subject: [PATCH 01/17] feat(tutorial): lay out the stage list in a grid Each card held only a number and a title across the whole width. Three in a row on a wide window fit every stage in view. Co-Authored-By: Claude Opus 5.5 --- src/pages/tutorial/index.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 5f75562..23e9ec5 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -45,15 +45,29 @@ export default function TutorialPage() { {texts.lead} {tutorialStages.map((stage, index) => (
  • - + From 6390a9efdb3655b40554659c38507fc924019d9d Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:05:10 +0900 Subject: [PATCH 02/17] feat(tutorial): number the stage cards in large circles In a grid, the small "Stage N" did not tell whether to read across or down. The number is read out as "Stage N" from a hidden copy, whose style is now shared with the controls of stage texts. Co-Authored-By: Claude Opus 5.5 --- src/components/visuallyHidden.ts | 9 +++++++++ src/pages/tutorial/StageText.tsx | 10 +--------- src/pages/tutorial/index.tsx | 34 +++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 src/components/visuallyHidden.ts diff --git a/src/components/visuallyHidden.ts b/src/components/visuallyHidden.ts new file mode 100644 index 0000000..8c2cc67 --- /dev/null +++ b/src/components/visuallyHidden.ts @@ -0,0 +1,9 @@ +/** For text only screen readers read, such as the label of something drawn as an icon */ +export const visuallyHiddenSx = { + position: "absolute", + width: "1px", + height: "1px", + overflow: "hidden", + clip: "rect(0 0 0 0)", + whiteSpace: "nowrap", +} as const; diff --git a/src/pages/tutorial/StageText.tsx b/src/pages/tutorial/StageText.tsx index ae1cb4e..f935ceb 100644 --- a/src/pages/tutorial/StageText.tsx +++ b/src/pages/tutorial/StageText.tsx @@ -14,6 +14,7 @@ import { withLookSx, } from "../../components/controlLooks"; import { ValueView } from "../../components/ValueView"; +import { visuallyHiddenSx } from "../../components/visuallyHidden"; import { useMessages } from "../../i18n"; import { parseStageText, @@ -35,15 +36,6 @@ const inlineSx = { pointerEvents: "none", } as const; -const visuallyHiddenSx = { - position: "absolute", - width: "1px", - height: "1px", - overflow: "hidden", - clip: "rect(0 0 0 0)", - whiteSpace: "nowrap", -} as const; - const iconSx = { display: "inline-flex", verticalAlign: "-0.25em", diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 23e9ec5..566f09d 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -11,6 +11,7 @@ import { import { useState } from "react"; import { Link } from "react-router"; import { ConfirmDialog } from "../../components/ConfirmDialog"; +import { visuallyHiddenSx } from "../../components/visuallyHidden"; import { useMessages } from "../../i18n"; import { theme } from "../../style"; import { readClearedStages } from "../../tutorial/progress"; @@ -69,14 +70,33 @@ export default function TutorialPage() { gap: 2, }} > - - - {texts.stageNumber(index + 1)} - - - {texts.stageTexts[stage.id].title} - + {/* Large, as the grid alone does not tell the order */} + + {texts.stageNumber(index + 1)} + + {index + 1} + + + {texts.stageTexts[stage.id].title} + {clearedStages.has(stage.id) && ( Date: Sat, 21 Nov 2026 01:09:49 +0900 Subject: [PATCH 03/17] fix(tutorial): keep a stage title on one line when it is cleared The cleared mark beside the title left too little width, so a short title such as "Both switches" wrapped. It is now under the title, the number's circle is a little smaller, and a long Japanese title wraps between phrases. Co-Authored-By: Claude Opus 5.5 --- src/pages/tutorial/index.tsx | 48 +++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 566f09d..cf9aa37 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -67,7 +67,7 @@ export default function TutorialPage() { height: "100%", display: "flex", alignItems: "center", - gap: 2, + gap: 1.5, }} > {/* Large, as the grid alone does not tell the order */} @@ -82,35 +82,43 @@ export default function TutorialPage() { justifyContent: "center", alignItems: "center", flexShrink: 0, - width: 40, - height: 40, + width: 32, + height: 32, borderRadius: "50%", border: 2, borderColor: theme.colors.tutorial, color: theme.colors.tutorial, - fontSize: "1.25rem", + fontSize: "1.125rem", fontWeight: "bold", }} > {index + 1} - - {texts.stageTexts[stage.id].title} - - {clearedStages.has(stage.id) && ( - + - - {texts.cleared} - - )} + {texts.stageTexts[stage.id].title} + + {clearedStages.has(stage.id) && ( + + + {texts.cleared} + + )} +
  • From 44ebecfbe81f005acef174ee8f91616750bef3d3 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:12:46 +0900 Subject: [PATCH 04/17] fix(tutorial): centre the number in its circle The digits sat low in their line, so they looked below the middle of the circle. Their box is now trimmed to the digits. Co-Authored-By: Claude Opus 5.5 --- src/pages/tutorial/index.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index cf9aa37..680f839 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -92,7 +92,16 @@ export default function TutorialPage() { fontWeight: "bold", }} > - {index + 1} + {/* Trimmed to the digits, which otherwise sit low in their line */} + + {index + 1} +
    {/* Under the title, which then has the width of the card */} From 4f872725a5dffadff94b4a53ed6ece250263ea74 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:15:57 +0900 Subject: [PATCH 05/17] fix(tutorial): keep every stage card the same height A title on two lines made its row taller than the others. The list is a little wider, so that every title fits on one line in three columns, and every row is as tall as the tallest when a narrow window wraps one. Comments that only restated the code are dropped. Co-Authored-By: Claude Opus 5.5 --- src/components/visuallyHidden.ts | 1 - src/pages/tutorial/index.tsx | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/visuallyHidden.ts b/src/components/visuallyHidden.ts index 8c2cc67..e12afbf 100644 --- a/src/components/visuallyHidden.ts +++ b/src/components/visuallyHidden.ts @@ -1,4 +1,3 @@ -/** For text only screen readers read, such as the label of something drawn as an icon */ export const visuallyHiddenSx = { position: "absolute", width: "1px", diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 680f839..b4ec7b1 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -39,7 +39,8 @@ export default function TutorialPage() { return (
    - + {/* Wide enough for the longest title on one line in three columns */} + {messages.header.modes.tutorial} @@ -51,8 +52,8 @@ export default function TutorialPage() { p: 0, mt: 3, display: "grid", - // Three in a row on a wide window, fewer on a narrow one gridTemplateColumns: "repeat(auto-fill, minmax(240px, 1fr))", + gridAutoRows: "1fr", gap: 2, }} > @@ -108,7 +109,6 @@ export default function TutorialPage() { {texts.stageTexts[stage.id].title} From 2d32a9f613452c57bfc732ba386252f494289463 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:17:44 +0900 Subject: [PATCH 06/17] fix(tutorial): tell where the stages lead, and why any can come first The lead said to go from the top, which a grid no longer has, and did not say that the stages build up to a stopwatch. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 2 +- src/i18n/ja.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 1f61cc1..607e692 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -225,7 +225,7 @@ export const en = { timeStep: "Time step", }, tutorial: { - lead: "Going from the top is recommended, but you can start from any stage.", + lead: "Build circuit after circuit from stage 1, and finish a stopwatch in the last stage. Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", stageNumber: (number: number) => `Stage ${number}`, cleared: "Cleared", startOver: "Start over from the beginning", diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index f177ca7..8b09b66 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -106,7 +106,7 @@ export const ja: Messages = { timeStep: "ステップ", }, tutorial: { - lead: "上から順に進めるのがおすすめですが、どの課題からでも始められます。", + lead: "課題 1 から順に回路を組み立てていき、最後にストップウォッチを完成させます。前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", stageNumber: (number) => `課題 ${number}`, cleared: "クリア", startOver: "最初からやり直す", From 9084612f08e681fe6198dd752c7b02e676cb6d32 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:19:42 +0900 Subject: [PATCH 07/17] feat(tutorial): show a stage's number in the same circle on its own page The list showed a circled number and the stage page "Stage 7" in small grey text. Both now use one component, and the list's lead points at the number as it is shown. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 2 +- src/i18n/ja.ts | 2 +- src/pages/tutorial/StageNumber.tsx | 42 ++++++++++++++++++++++++++++++ src/pages/tutorial/index.tsx | 35 ++----------------------- src/pages/tutorial/stage.tsx | 9 +++---- 5 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 src/pages/tutorial/StageNumber.tsx diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 607e692..86a36e3 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -225,7 +225,7 @@ export const en = { timeStep: "Time step", }, tutorial: { - lead: "Build circuit after circuit from stage 1, and finish a stopwatch in the last stage. Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", + lead: "Starting at 1, build circuit after circuit, and finish a stopwatch in the last stage. Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", stageNumber: (number: number) => `Stage ${number}`, cleared: "Cleared", startOver: "Start over from the beginning", diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 8b09b66..7d9061a 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -106,7 +106,7 @@ export const ja: Messages = { timeStep: "ステップ", }, tutorial: { - lead: "課題 1 から順に回路を組み立てていき、最後にストップウォッチを完成させます。前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", + lead: "1 の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", stageNumber: (number) => `課題 ${number}`, cleared: "クリア", startOver: "最初からやり直す", diff --git a/src/pages/tutorial/StageNumber.tsx b/src/pages/tutorial/StageNumber.tsx new file mode 100644 index 0000000..1caf97a --- /dev/null +++ b/src/pages/tutorial/StageNumber.tsx @@ -0,0 +1,42 @@ +import { Box } from "@mui/material"; +import { visuallyHiddenSx } from "../../components/visuallyHidden"; +import { useMessages } from "../../i18n"; +import { theme } from "../../style"; + +/** The number of a stage in a circle, as the list and the stage itself show it */ +export function StageNumber({ number }: { number: number }) { + const messages = useMessages(); + return ( + <> + + {messages.tutorial.stageNumber(number)} + + + {/* Trimmed to the digits, which otherwise sit low in their line */} + + {number} + + + + ); +} diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index b4ec7b1..af1e1fc 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -11,12 +11,12 @@ import { import { useState } from "react"; import { Link } from "react-router"; import { ConfirmDialog } from "../../components/ConfirmDialog"; -import { visuallyHiddenSx } from "../../components/visuallyHidden"; import { useMessages } from "../../i18n"; import { theme } from "../../style"; import { readClearedStages } from "../../tutorial/progress"; import { resetTutorial } from "../../tutorial/stageStore"; import { tutorialStages } from "../../tutorial/stages"; +import { StageNumber } from "./StageNumber"; export default function TutorialPage() { const messages = useMessages(); @@ -72,38 +72,7 @@ export default function TutorialPage() { }} > {/* Large, as the grid alone does not tell the order */} - - {texts.stageNumber(index + 1)} - - - {/* Trimmed to the digits, which otherwise sit low in their line */} - - {index + 1} - - + {/* Under the title, which then has the width of the card */} {texts.stages} -
    - - {texts.stageNumber(stageIndex + 1)} - + + {stageTexts.title} -
    +
    {texts.goalHeading} From 59da5c9c2ccb0484fb57788a1224ee83a5291423 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:20:01 +0900 Subject: [PATCH 08/17] fix(tutorial): say the first stage rather than its number in the lead Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 2 +- src/i18n/ja.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 86a36e3..12566f4 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -225,7 +225,7 @@ export const en = { timeStep: "Time step", }, tutorial: { - lead: "Starting at 1, build circuit after circuit, and finish a stopwatch in the last stage. Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", + lead: "Starting at the first stage, build circuit after circuit, and finish a stopwatch in the last stage. Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", stageNumber: (number: number) => `Stage ${number}`, cleared: "Cleared", startOver: "Start over from the beginning", diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 7d9061a..6827bf9 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -106,7 +106,7 @@ export const ja: Messages = { timeStep: "ステップ", }, tutorial: { - lead: "1 の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", + lead: "最初の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", stageNumber: (number) => `課題 ${number}`, cleared: "クリア", startOver: "最初からやり直す", From 5be6b8566bb64c1a2c7f9087f40c46810e604e24 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:20:33 +0900 Subject: [PATCH 09/17] fix(tutorial): put each sentence of the list's lead on its own line Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 5 ++++- src/i18n/ja.ts | 5 ++++- src/pages/tutorial/index.tsx | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 12566f4..ff7045b 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -225,7 +225,10 @@ export const en = { timeStep: "Time step", }, tutorial: { - lead: "Starting at the first stage, build circuit after circuit, and finish a stopwatch in the last stage. Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", + lead: [ + "Starting at the first stage, build circuit after circuit, and finish a stopwatch in the last stage.", + "Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", + ], stageNumber: (number: number) => `Stage ${number}`, cleared: "Cleared", startOver: "Start over from the beginning", diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 6827bf9..ff250e7 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -106,7 +106,10 @@ export const ja: Messages = { timeStep: "ステップ", }, tutorial: { - lead: "最初の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", + lead: [ + "最初の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。", + "前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", + ], stageNumber: (number) => `課題 ${number}`, cleared: "クリア", startOver: "最初からやり直す", diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index af1e1fc..1c6c594 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -44,7 +44,11 @@ export default function TutorialPage() { {messages.header.modes.tutorial} - {texts.lead} + {texts.lead.map((sentence) => ( + + {sentence} + + ))} Date: Sat, 21 Nov 2026 01:22:37 +0900 Subject: [PATCH 10/17] feat(tutorial): mark the next stage in the list The first stage not cleared yet gets a border in the tutorial colour and "Next stage" under its title, so that a player coming back to the list sees where to go on. No stage is marked once all are cleared. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 1 + src/i18n/ja.ts | 1 + src/pages/tutorial/index.tsx | 63 ++++++++++++++++++++++++++--------- src/tutorial/progress.test.ts | 14 ++++++++ src/tutorial/progress.ts | 13 +++++++- 5 files changed, 75 insertions(+), 17 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index ff7045b..f54fe07 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -231,6 +231,7 @@ export const en = { ], stageNumber: (number: number) => `Stage ${number}`, cleared: "Cleared", + upNext: "Next stage", startOver: "Start over from the beginning", startOverDialog: { title: "Start the tutorial over?", diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index ff250e7..9796f19 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -112,6 +112,7 @@ export const ja: Messages = { ], stageNumber: (number) => `課題 ${number}`, cleared: "クリア", + upNext: "次の課題", startOver: "最初からやり直す", startOverDialog: { title: "チュートリアルを最初からやり直しますか?", diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 1c6c594..0768a37 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -1,4 +1,4 @@ -import { CheckCircle } from "@mui/icons-material"; +import { ArrowForward, CheckCircle } from "@mui/icons-material"; import { Alert, Box, @@ -8,20 +8,41 @@ import { Container, Typography, } from "@mui/material"; -import { useState } from "react"; +import { type ReactNode, useState } from "react"; import { Link } from "react-router"; import { ConfirmDialog } from "../../components/ConfirmDialog"; import { useMessages } from "../../i18n"; import { theme } from "../../style"; -import { readClearedStages } from "../../tutorial/progress"; +import { nextStageOf, readClearedStages } from "../../tutorial/progress"; import { resetTutorial } from "../../tutorial/stageStore"; import { tutorialStages } from "../../tutorial/stages"; import { StageNumber } from "./StageNumber"; +function StageStatus({ + icon, + label, + color, +}: { + icon: ReactNode; + label: string; + color: string; +}) { + return ( + + {icon} + {label} + + ); +} + export default function TutorialPage() { const messages = useMessages(); const texts = messages.tutorial; const [clearedStages, setClearedStages] = useState(readClearedStages); + const nextStage = nextStageOf(clearedStages); const [isConfirming, setIsConfirming] = useState(false); const [hasFailed, setHasFailed] = useState(false); @@ -63,7 +84,17 @@ export default function TutorialPage() { > {tutorialStages.map((stage, index) => (
  • - + {clearedStages.has(stage.id) && ( - - - {texts.cleared} - + } + label={texts.cleared} + color={theme.colors.primary} + /> + )} + {stage.id === nextStage && ( + } + label={texts.upNext} + color={theme.colors.tutorial} + /> )} diff --git a/src/tutorial/progress.test.ts b/src/tutorial/progress.test.ts index 9eb6352..70d067d 100644 --- a/src/tutorial/progress.test.ts +++ b/src/tutorial/progress.test.ts @@ -3,8 +3,10 @@ import { stubLocalStorage } from "../store/testUtils"; import { forgetClearedStages, markStageCleared, + nextStageOf, readClearedStages, } from "./progress"; +import { tutorialStageIds } from "./stages"; let saved: Map; beforeEach(() => { @@ -34,3 +36,15 @@ describe("tutorial progress", () => { expect(readClearedStages().size).toBe(0); }); }); + +describe("nextStageOf", () => { + it("is the first stage not cleared, even before one cleared out of order", () => { + expect(nextStageOf(new Set())).toBe("and"); + expect(nextStageOf(new Set(["and", "a-only"]))).toBe("xor"); + expect(nextStageOf(new Set(["and", "full-adder"]))).toBe("a-only"); + }); + + it("is none once every stage is cleared", () => { + expect(nextStageOf(new Set(tutorialStageIds))).toBeUndefined(); + }); +}); diff --git a/src/tutorial/progress.ts b/src/tutorial/progress.ts index ad0e2d5..8e8a71f 100644 --- a/src/tutorial/progress.ts +++ b/src/tutorial/progress.ts @@ -1,4 +1,8 @@ -import { isTutorialStageId, type TutorialStageId } from "./stages"; +import { + isTutorialStageId, + type TutorialStageId, + tutorialStageIds, +} from "./stages"; const progressStorageKey = "ccTutorialProgress"; @@ -37,3 +41,10 @@ export function forgetClearedStages(): void { console.warn("Could not forget the tutorial progress", error); } } + +/** The first stage not cleared yet, from which the tutorial goes on in order */ +export function nextStageOf( + cleared: ReadonlySet, +): TutorialStageId | undefined { + return tutorialStageIds.find((id) => !cleared.has(id)); +} From 1e9ca943bd9c42de91f20a379af770b7b7eddecd Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:22:48 +0900 Subject: [PATCH 11/17] chore(tutorial): drop comments that restate the code Co-Authored-By: Claude Opus 5.5 --- src/pages/tutorial/StageNumber.tsx | 1 - src/pages/tutorial/index.tsx | 1 - src/tutorial/progress.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/src/pages/tutorial/StageNumber.tsx b/src/pages/tutorial/StageNumber.tsx index 1caf97a..7f3e66f 100644 --- a/src/pages/tutorial/StageNumber.tsx +++ b/src/pages/tutorial/StageNumber.tsx @@ -3,7 +3,6 @@ import { visuallyHiddenSx } from "../../components/visuallyHidden"; import { useMessages } from "../../i18n"; import { theme } from "../../style"; -/** The number of a stage in a circle, as the list and the stage itself show it */ export function StageNumber({ number }: { number: number }) { const messages = useMessages(); return ( diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index 0768a37..b8ee745 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -106,7 +106,6 @@ export default function TutorialPage() { gap: 1.5, }} > - {/* Large, as the grid alone does not tell the order */} {/* Under the title, which then has the width of the card */} diff --git a/src/tutorial/progress.ts b/src/tutorial/progress.ts index 8e8a71f..ce50293 100644 --- a/src/tutorial/progress.ts +++ b/src/tutorial/progress.ts @@ -42,7 +42,6 @@ export function forgetClearedStages(): void { } } -/** The first stage not cleared yet, from which the tutorial goes on in order */ export function nextStageOf( cleared: ReadonlySet, ): TutorialStageId | undefined { From 04c9e52a0f626a3b865ee849df295182dc1d8033 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:26:07 +0900 Subject: [PATCH 12/17] feat: introduce the app on the start page, and tell who each mode is for The start page asked what to do without saying what the app is. It now opens with the app's name and the project's description, and the tutorial is marked for first-timers, with where it leads, and the free mode for those who know logic circuits. The page is narrower, as the cards hold short texts. The app name is one constant for the header and the page. Co-Authored-By: Claude Opus 5.5 --- src/common/appName.ts | 1 + src/components/GlobalHeader.tsx | 3 ++- src/i18n/en.ts | 6 +++++- src/i18n/ja.ts | 6 +++++- src/pages/start/index.tsx | 19 ++++++++++++++++--- 5 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 src/common/appName.ts diff --git a/src/common/appName.ts b/src/common/appName.ts new file mode 100644 index 0000000..403488f --- /dev/null +++ b/src/common/appName.ts @@ -0,0 +1 @@ +export const appName = "CreateCPU"; diff --git a/src/components/GlobalHeader.tsx b/src/components/GlobalHeader.tsx index 1f22926..d1dbd0e 100644 --- a/src/components/GlobalHeader.tsx +++ b/src/components/GlobalHeader.tsx @@ -8,6 +8,7 @@ import { } from "@mui/material"; import type { CSSProperties } from "react"; import { Link as RouterLink, useLocation } from "react-router"; +import { appName } from "../common/appName"; import { type Language, languages, @@ -55,7 +56,7 @@ export default function GlobalHeader({ style }: GlobalHeaderProps) { }} > - CreateCPU + {appName} {mode && ( - - + + + {appName} + + {messages.start.intro} + {messages.start.title}
    {choices.map((choice) => ( @@ -44,6 +51,12 @@ export default function StartPage() { to={choice.to} sx={{ p: 3, flexGrow: 1, alignSelf: "stretch" }} > + + {choice.audience} + {choice.title} From dc5941f601032088ea83ff3bf060ab72c776b01b Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:26:31 +0900 Subject: [PATCH 13/17] fix: widen the start page back, as it now holds a long description Co-Authored-By: Claude Opus 5.5 --- src/pages/start/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/start/index.tsx b/src/pages/start/index.tsx index c9321b4..dca4adf 100644 --- a/src/pages/start/index.tsx +++ b/src/pages/start/index.tsx @@ -24,7 +24,7 @@ export default function StartPage() { ]; return (
    - + {appName} From 05b6a1dc8808b6d7d24a1e5250f31e34f039e187 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:27:05 +0900 Subject: [PATCH 14/17] fix: put each sentence of the start page's description on its own line Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 7 +++++-- src/i18n/ja.ts | 7 +++++-- src/pages/start/index.tsx | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index f14eba9..0949751 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -165,8 +165,11 @@ export const en = { }, }, start: { - intro: - "The brain of a computer or a smartphone, the CPU, is built from combinations of simple logic elements. In CreateCPU, you place small circuits on the screen, connect them and run them to learn about logic circuits. Try things out like a puzzle, and take a look inside a computer.", + intro: [ + "The brain of a computer or a smartphone, the CPU, is built from combinations of simple logic elements.", + "In CreateCPU, you place small circuits on the screen, connect them and run them to learn about logic circuits.", + "Try things out like a puzzle, and take a look inside a computer.", + ], title: "What would you like to do?", tutorialAudience: "New here? Start here.", tutorial: diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index fabe1f9..8e52f4c 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -47,8 +47,11 @@ export const ja: Messages = { }, }, start: { - intro: - "パソコンやスマホの頭脳「CPU」は、単純な論理素子の組み合わせからできています。CreateCPU では、画面上で小さな回路を並べてつなぎ、動かしながら論理回路について学べます。パズル感覚で試行錯誤しながら、コンピュータの中身をのぞいてみませんか?", + intro: [ + "パソコンやスマホの頭脳「CPU」は、単純な論理素子の組み合わせからできています。", + "CreateCPU では、画面上で小さな回路を並べてつなぎ、動かしながら論理回路について学べます。", + "パズル感覚で試行錯誤しながら、コンピュータの中身をのぞいてみませんか?", + ], title: "何をしますか?", tutorialAudience: "はじめての方はこちら", tutorial: "2つのスイッチから始めて、最後にストップウォッチを作ります。", diff --git a/src/pages/start/index.tsx b/src/pages/start/index.tsx index dca4adf..53117ad 100644 --- a/src/pages/start/index.tsx +++ b/src/pages/start/index.tsx @@ -28,7 +28,11 @@ export default function StartPage() { {appName} - {messages.start.intro} + {messages.start.intro.map((sentence) => ( + + {sentence} + + ))} {messages.start.title} From 480d2838eda03bc2e9cb8f829184a9794284077b Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:28:13 +0900 Subject: [PATCH 15/17] fix: say what the tutorial is made of on the start page "Starting from a pair of switches" meant nothing before the first stage. The card now tells the number of stages, counted from the stages, and that they end in a stopwatch. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 4 ++-- src/i18n/ja.ts | 3 ++- src/pages/start/index.tsx | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 0949751..ac64ff7 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -172,8 +172,8 @@ export const en = { ], title: "What would you like to do?", tutorialAudience: "New here? Start here.", - tutorial: - "Start from a pair of switches, and build a stopwatch at the end.", + tutorial: (stageCount: number) => + `Solve ${stageCount} stages in turn, building circuits as you go, and finish a stopwatch at the end.`, freeAudience: "For those who know logic circuits", free: "Build any circuit you like.", }, diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 8e52f4c..fe350e4 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -54,7 +54,8 @@ export const ja: Messages = { ], title: "何をしますか?", tutorialAudience: "はじめての方はこちら", - tutorial: "2つのスイッチから始めて、最後にストップウォッチを作ります。", + tutorial: (stageCount) => + `${stageCount}つの課題を順に解きながら回路を作り、最後にストップウォッチを完成させます。`, freeAudience: "論理回路を知っている方向け", free: "好きな回路を自由に作ります。", }, diff --git a/src/pages/start/index.tsx b/src/pages/start/index.tsx index 53117ad..9ff820f 100644 --- a/src/pages/start/index.tsx +++ b/src/pages/start/index.tsx @@ -3,6 +3,7 @@ import { Link } from "react-router"; import { appName } from "../../common/appName"; import { useMessages } from "../../i18n"; import { theme } from "../../style"; +import { tutorialStages } from "../../tutorial/stages"; export default function StartPage() { const messages = useMessages(); @@ -11,7 +12,7 @@ export default function StartPage() { to: "/tutorial", audience: messages.start.tutorialAudience, title: messages.header.modes.tutorial, - body: messages.start.tutorial, + body: messages.start.tutorial(tutorialStages.length), color: theme.colors.tutorial, }, { From 6a1b2f19ee6c273b6baffaec417c111fe77fb973 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:33:39 +0900 Subject: [PATCH 16/17] fix(tutorial): name stages by what their circuits do MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Both switches" and the like named the inputs rather than what the circuit does, which also read oddly as the name of a part handed over. They are now "ON when both are ON" and so on. "One decimal digit" and "One base-6 digit", whose terms are taught only inside the stages, are now "0–9 counter" and "0–5 counter", after the counter stage before them. The texts that name these parts follow. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 16 ++++++++-------- src/i18n/ja.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index ac64ff7..90a4264 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -20,7 +20,7 @@ type StageTexts = { const stageTexts: Record = { and: { - title: "Both switches", + title: "ON when both are ON", goal: [ "Make the lamp {Out} turn [ON] only when both switches {A} and {B} are [ON]. The stage is cleared when the circuit works as in the table below.", ], @@ -33,16 +33,16 @@ const stageTexts: Record = { ], }, "a-only": { - title: "Only switch A", + title: "ON when only A is ON", goal: [ "Make the lamp {Out} turn [ON] only when switch {A} is [ON] and {B} is [OFF]. This time, one part alone is not enough.", ], steps: [], }, xor: { - title: "Only one switch", + title: "ON when just one is ON", goal: [ - 'Make the lamp {Out} turn [ON] when exactly one of the switches {A} and {B} is [ON]. It stays [OFF] when both are [ON]. "{Only switch A}" is ready to use as a part.', + 'Make the lamp {Out} turn [ON] when exactly one of the switches {A} and {B} is [ON]. It stays [OFF] when both are [ON]. "{ON when only A is ON}" is ready to use as a part.', ], steps: [], }, @@ -87,7 +87,7 @@ const stageTexts: Record = { ], }, "decimal-digit": { - title: "One decimal digit", + title: "0–9 counter", goal: [ "Writing numbers with 0 to 9, carrying over after 9 as everyday numbers do, is called decimal.", "Make {Count} go up by 1 only at the time steps when {Up} is [ON], and go back to [0000] after [1001]. [1001] is 9, 8 plus 1. At a time step when {Count} is [1001] and {Up} is [ON], make {Carry} turn [ON]: it tells the digit above to go up.", @@ -109,8 +109,8 @@ const stageTexts: Record = { " keeps {Start} [ON] until 59:59 has gone back to 00:00, then turns it [OFF] for two time steps to see that the stopwatch stops, and [ON] again to see that it goes on.", ], steps: [ - 'Place two "{One base-6 digit}" and two "{One decimal digit}". "{One base-6 digit}" is built like "{One decimal digit}", but counts 0 to 5 and carries over after 5, as decimal does after 9.', - 'Give each of the four parts one of {M10}, {M1}, {S10} and {S1}: "{One base-6 digit}" for {M10} and {S10}, and "{One decimal digit}" for {M1} and {S1}. Connect the {Count} of each to the output on the right named after its digit, and to the {7seg} of that digit. The {7seg}s are, from the top, for {M10}, {M1}, {S10} and {S1}.', + 'Place two "{0–5 counter}" and two "{0–9 counter}". "{0–5 counter}" is built like "{0–9 counter}", but goes back to 0 and carries over after 5 instead of 9.', + 'Give each of the four parts one of {M10}, {M1}, {S10} and {S1}: "{0–5 counter}" for {M10} and {S10}, and "{0–9 counter}" for {M1} and {S1}. Connect the {Count} of each to the output on the right named after its digit, and to the {7seg} of that digit. The {7seg}s are, from the top, for {M10}, {M1}, {S10} and {S1}.', "Connect {Start} to {Up} of the part connected to {S1}. Then connect {Carry} of the part for {S1} to {Up} of the part for {S10}, {Carry} for {S10} to {Up} for {M1}, and {Carry} for {M1} to {Up} for {M10}. A digit then goes on only when the digit one lower goes back to 0.", "Press the play button . If {Start} is [OFF] at the first time step, click it to turn it [ON]. Press , and the {Display} goes on like a clock, one time step a second. To see what comes after 59:59, stop , click the number at the bottom, enter 3600 and press the key. It goes to that time step at once and shows 59:59, and the right arrow shows 00:00.", ], @@ -288,7 +288,7 @@ export const en = { }, resetStageFailed: "Could not reset the stage.", stageTexts, - partTitles: { "senary-digit": "One base-6 digit" } satisfies Record< + partTitles: { "senary-digit": "0–5 counter" } satisfies Record< TutorialPartId, string >, diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index fe350e4..17a6f64 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -158,10 +158,10 @@ export const ja: Messages = { confirm: "やり直す", }, resetStageFailed: "課題をやり直せませんでした。", - partTitles: { "senary-digit": "6進の1桁" }, + partTitles: { "senary-digit": "0〜5 のカウンタ" }, stageTexts: { and: { - title: "両方のスイッチ", + title: "両方 ON で ON", goal: [ "スイッチ {A} と {B} が両方 [ON] のときだけ、ランプ {Out} が [ON] になるようにしましょう。下の表のとおりに動けばクリアです。", ], @@ -174,16 +174,16 @@ export const ja: Messages = { ], }, "a-only": { - title: "A だけのスイッチ", + title: "A だけ ON で ON", goal: [ "スイッチ {A} が [ON] で、{B} が [OFF] のときだけ、ランプ {Out} が [ON] になるようにしましょう。今度は、部品を1つ置くだけではできません。", ], steps: [], }, xor: { - title: "片方だけのスイッチ", + title: "片方だけ ON で ON", goal: [ - "スイッチ {A} と {B} のどちらか片方だけが [ON] のときに、ランプ {Out} が [ON] になるようにしましょう。両方 [ON] のときは [OFF] です。「{A だけのスイッチ}」を部品として使えます。", + "スイッチ {A} と {B} のどちらか片方だけが [ON] のときに、ランプ {Out} が [ON] になるようにしましょう。両方 [ON] のときは [OFF] です。「{A だけ ON で ON}」を部品として使えます。", ], steps: [], }, @@ -228,7 +228,7 @@ export const ja: Messages = { ], }, "decimal-digit": { - title: "10進の1桁", + title: "0〜9 のカウンタ", goal: [ "ふだんの数のように、0 から 9 までを使い、9 の次で桁が上がる書き方を10進数といいます。", "{Up} が [ON] のステップだけ {Count} が 1 増え、[1001] の次は [0000] に戻るようにしましょう。[1001] は、8 と 1 を足した 9 です。{Count} が [1001] で {Up} が [ON] のステップでは、{Carry} が [ON] になるようにします。{Carry} は、上の桁に桁上がりを知らせる合図です。", @@ -250,8 +250,8 @@ export const ja: Messages = { "は、{Start} を [ON] にしたまま、59:59 の次に 00:00 に戻るまで進めます。そのあと2ステップだけ {Start} を [OFF] にして止まるかを、また [ON] にしてまた進むかを調べます。", ], steps: [ - "「{6進の1桁}」を2つと、「{10進の1桁}」を2つ置きます。「{6進の1桁}」は「{10進の1桁}」と同じつくりで、0 から 5 を数え、5 の次で 0 に戻って上の桁が上がります。10進数が 9 の次で桁が上がるのと同じです。", - "置いた4つの部品を、{M10}・{M1}・{S10}・{S1} に1つずつ割り当てます。{M10} と {S10} には「{6進の1桁}」を、{M1} と {S1} には「{10進の1桁}」を使います。それぞれの {Count} を、割り当てた桁と同じ名前の右の出力と、その桁の {7seg} につなぎます。{7seg} は、上から {M10}・{M1}・{S10}・{S1} 用です。", + "「{0〜5 のカウンタ}」を2つと、「{0〜9 のカウンタ}」を2つ置きます。「{0〜5 のカウンタ}」は「{0〜9 のカウンタ}」と同じつくりで、9 の次ではなく 5 の次で 0 に戻り、上の桁に桁上がりを知らせます。", + "置いた4つの部品を、{M10}・{M1}・{S10}・{S1} に1つずつ割り当てます。{M10} と {S10} には「{0〜5 のカウンタ}」を、{M1} と {S1} には「{0〜9 のカウンタ}」を使います。それぞれの {Count} を、割り当てた桁と同じ名前の右の出力と、その桁の {7seg} につなぎます。{7seg} は、上から {M10}・{M1}・{S10}・{S1} 用です。", "{S1} につないだ部品の {Up} に {Start} をつなぎます。次に、{S1} の部品の {Carry} を {S10} の部品の {Up} に、{S10} の {Carry} を {M1} の {Up} に、{M1} の {Carry} を {M10} の {Up} につなぎます。こうすると、1つ下の桁が 0 に戻るときだけ、その上の桁が進みます。", "再生ボタンを押します。最初のステップで {Start} が [OFF] なら、クリックして [ON] にします。を押すと、1秒に1ステップずつ、{Display} が時計のように進みます。59:59 の次を見るには、を止めて下の数字をクリックし、3600 と入れてキーを押します。そのステップまで一度に進んで 59:59 になり、右の矢印を押すと 00:00 に戻ります。", ], From 2c8c0022ddf9536ae01453a35615bec8a0bebe68 Mon Sep 17 00:00:00 2001 From: Rn86222 Date: Sat, 21 Nov 2026 01:44:12 +0900 Subject: [PATCH 17/17] fix(tutorial): address the review of the list and start pages - The list's mark for the first stage not cleared reads "Continue here", as "Next stage" is the stage page's button to the following stage. - The lead says that only a stage needing an earlier circuit hands it over. - The start page's description takes the app name from its constant. - The free mode's audience label uses the darker green, which small text needs on white. - The stage page's heading holds the hidden "Stage N", so that moving by headings reads the number too. - A test checks that every name a stage text marks is a pin, a part or a title, so that renaming a title cannot leave a text naming the old part. Co-Authored-By: Claude Opus 5.5 --- src/i18n/en.ts | 8 +++---- src/i18n/ja.ts | 8 +++---- src/pages/start/index.tsx | 7 ++++-- src/pages/tutorial/index.tsx | 2 +- src/pages/tutorial/stage.tsx | 21 ++++++++++------- src/tutorial/stageText.test.ts | 43 ++++++++++++++++++++++++++++++++-- 6 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 90a4264..9be7f8e 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -165,9 +165,9 @@ export const en = { }, }, start: { - intro: [ + intro: (appName: string) => [ "The brain of a computer or a smartphone, the CPU, is built from combinations of simple logic elements.", - "In CreateCPU, you place small circuits on the screen, connect them and run them to learn about logic circuits.", + `In ${appName}, you place small circuits on the screen, connect them and run them to learn about logic circuits.`, "Try things out like a puzzle, and take a look inside a computer.", ], title: "What would you like to do?", @@ -234,11 +234,11 @@ export const en = { tutorial: { lead: [ "Starting at the first stage, build circuit after circuit, and finish a stopwatch in the last stage.", - "Each stage hands you the circuits of the earlier stages as finished parts, so you can start from any stage.", + "When a stage needs a circuit from an earlier one, it hands it to you as a finished part, so you can start from any stage.", ], stageNumber: (number: number) => `Stage ${number}`, cleared: "Cleared", - upNext: "Next stage", + upNext: "Continue here", startOver: "Start over from the beginning", startOverDialog: { title: "Start the tutorial over?", diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts index 17a6f64..9fe1461 100644 --- a/src/i18n/ja.ts +++ b/src/i18n/ja.ts @@ -47,9 +47,9 @@ export const ja: Messages = { }, }, start: { - intro: [ + intro: (appName) => [ "パソコンやスマホの頭脳「CPU」は、単純な論理素子の組み合わせからできています。", - "CreateCPU では、画面上で小さな回路を並べてつなぎ、動かしながら論理回路について学べます。", + `${appName} では、画面上で小さな回路を並べてつなぎ、動かしながら論理回路について学べます。`, "パズル感覚で試行錯誤しながら、コンピュータの中身をのぞいてみませんか?", ], title: "何をしますか?", @@ -116,11 +116,11 @@ export const ja: Messages = { tutorial: { lead: [ "最初の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。", - "前の課題の回路は完成した部品として渡されるので、どの課題からでも始められます。", + "前の課題で作った回路が必要な課題では、その回路が完成した部品として渡されるので、どの課題からでも始められます。", ], stageNumber: (number) => `課題 ${number}`, cleared: "クリア", - upNext: "次の課題", + upNext: "続きはここから", startOver: "最初からやり直す", startOverDialog: { title: "チュートリアルを最初からやり直しますか?", diff --git a/src/pages/start/index.tsx b/src/pages/start/index.tsx index 9ff820f..f97885d 100644 --- a/src/pages/start/index.tsx +++ b/src/pages/start/index.tsx @@ -14,6 +14,7 @@ export default function StartPage() { title: messages.header.modes.tutorial, body: messages.start.tutorial(tutorialStages.length), color: theme.colors.tutorial, + textColor: theme.colors.tutorial, }, { to: "/free", @@ -21,6 +22,8 @@ export default function StartPage() { title: messages.header.modes.free, body: messages.start.free, color: theme.colors.primary, + // The primary colour is too light for small text on white + textColor: "primary.dark", }, ]; return ( @@ -29,7 +32,7 @@ export default function StartPage() { {appName} - {messages.start.intro.map((sentence) => ( + {messages.start.intro(appName).map((sentence) => ( {sentence} @@ -58,7 +61,7 @@ export default function StartPage() { > {choice.audience} diff --git a/src/pages/tutorial/index.tsx b/src/pages/tutorial/index.tsx index b8ee745..ede4126 100644 --- a/src/pages/tutorial/index.tsx +++ b/src/pages/tutorial/index.tsx @@ -107,7 +107,7 @@ export default function TutorialPage() { }} > - {/* Under the title, which then has the width of the card */} + {/* The status goes under the title rather than beside it, to leave the title room */} {texts.stages} - + - - {stageTexts.title} - - + {stageTexts.title} +
    {texts.goalHeading} diff --git a/src/tutorial/stageText.test.ts b/src/tutorial/stageText.test.ts index 36e445b..4c8fda6 100644 --- a/src/tutorial/stageText.test.ts +++ b/src/tutorial/stageText.test.ts @@ -1,6 +1,13 @@ import { describe, expect, it } from "vitest"; -import { messagesByLanguage } from "../i18n/messages"; -import { tutorialStageIds } from "./stages"; +import { languages, messagesByLanguage } from "../i18n/messages"; +import { definitions } from "../store/intrinsics/definitions"; +import { + isTutorialStageId, + tutorialPartIds, + tutorialParts, + tutorialStageIds, + tutorialStages, +} from "./stages"; import { parseStageText, type StageTextSegment } from "./stageText"; describe("parseStageText", () => { @@ -68,3 +75,35 @@ describe("the stage texts", () => { }, ); }); + +describe("the names in stage texts", () => { + // A part handed over is named by its title, so a renamed title must be renamed in the + // texts too + it.each(languages)("are pins, parts or titles in %s", (language) => { + const texts = messagesByLanguage[language].tutorial; + const known = new Set([ + ...Object.values(definitions).flatMap((definition) => [ + definition.name, + ...definition.allPins.map((pin) => pin.name), + ]), + ...[...tutorialStages, ...tutorialParts].flatMap(({ check }) => [ + ...check.inputs.map(({ name }) => name), + ...check.outputs, + ]), + ...[...tutorialStageIds, ...tutorialPartIds].map((id) => + isTutorialStageId(id) + ? texts.stageTexts[id].title + : texts.partTitles[id], + ), + ]); + const names = tutorialStageIds.flatMap((id) => + [...texts.stageTexts[id].goal, ...texts.stageTexts[id].steps].flatMap( + (text) => + parseStageText(text).flatMap((segment) => + segment.type === "name" ? [segment.name] : [], + ), + ), + ); + expect(names.filter((name) => !known.has(name))).toEqual([]); + }); +});