{tutorialStages.map((stage, index) => (
-
+
+
+ {/* The status goes under the title rather than beside it, to leave the title room */}
-
- {texts.stageNumber(index + 1)}
-
-
+
{texts.stageTexts[stage.id].title}
+ {clearedStages.has(stage.id) && (
+ }
+ label={texts.cleared}
+ color={theme.colors.primary}
+ />
+ )}
+ {stage.id === nextStage && (
+ }
+ label={texts.upNext}
+ color={theme.colors.tutorial}
+ />
+ )}
- {clearedStages.has(stage.id) && (
-
-
- {texts.cleared}
-
- )}
diff --git a/src/pages/tutorial/stage.tsx b/src/pages/tutorial/stage.tsx
index 683f8d7..062ea4e 100644
--- a/src/pages/tutorial/stage.tsx
+++ b/src/pages/tutorial/stage.tsx
@@ -65,6 +65,7 @@ import CCComponentEditor from "../edit/Editor";
import { OutlinedNodeIdsContext } from "../edit/Editor/outlinedNodes";
import type { OffersComponent } from "../edit/placement";
import SidePanel from "../edit/SidePanel";
+import { StageNumber } from "./StageNumber";
import { StageText } from "./StageText";
function SectionHeading({ children }: { children: ReactNode }) {
@@ -236,18 +237,19 @@ function StageView({ stage }: { stage: TutorialStage }) {
{texts.stages}
-
-
- {texts.stageNumber(stageIndex + 1)}
-
-
- {stageTexts.title}
-
-
+
+
+ {stageTexts.title}
+
{texts.goalHeading}
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..ce50293 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,9 @@ export function forgetClearedStages(): void {
console.warn("Could not forget the tutorial progress", error);
}
}
+
+export function nextStageOf(
+ cleared: ReadonlySet,
+): TutorialStageId | undefined {
+ return tutorialStageIds.find((id) => !cleared.has(id));
+}
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([]);
+ });
+});