diff --git a/src/components/PartDescription.tsx b/src/components/PartDescription.tsx
index 3f3e2c4..900c883 100644
--- a/src/components/PartDescription.tsx
+++ b/src/components/PartDescription.tsx
@@ -1,10 +1,9 @@
import { Box, Typography } from "@mui/material";
-import { bitLabel } from "../common/bitLabel";
import { type Messages, useMessages } from "../i18n";
import type { CCComponent } from "../store/component";
import { definitionByComponentId } from "../store/intrinsics/definitions";
import { truthTableOf } from "../store/intrinsics/truthTable";
-import { theme } from "../style";
+import { TruthTableView } from "./TruthTableView";
type Summaries = Messages["parts"]["summaries"];
@@ -23,68 +22,20 @@ export function PartDescription({ component }: { component: CCComponent }) {
const summary = partSummary(messages, component);
const definition = definitionByComponentId.get(component.id);
const table = definition && truthTableOf(definition);
- const columns = table
- ? [
- ...table.inputs.map((name) => ({ key: `in-${name}`, name })),
- ...table.outputs.map((name) => ({ key: `out-${name}`, name })),
- ]
- : [];
- const cellSx = (column: number) =>
- ({
- px: 1,
- py: 0.25,
- textAlign: "center",
- ...(table &&
- table.inputs.length > 0 &&
- column === table.inputs.length && {
- borderLeft: 1,
- borderColor: "divider",
- }),
- }) as const;
return (
- {component.name}
+
+ {component.name}
+
{summary && {summary}}
{table && (
-
-
-
- {columns.map(({ key, name }, i) => (
-
- {name}
-
- ))}
-
-
-
- {table.rows.map((row) => (
-
- {[...row.inputs, ...row.outputs].map((value, i) => (
-
- {bitLabel(value)}
-
- ))}
-
- ))}
-
+
+
)}
diff --git a/src/components/TruthTableView.tsx b/src/components/TruthTableView.tsx
new file mode 100644
index 0000000..0cf74a8
--- /dev/null
+++ b/src/components/TruthTableView.tsx
@@ -0,0 +1,64 @@
+import { Box } from "@mui/material";
+import { bitLabel } from "../common/bitLabel";
+import type { TruthTable } from "../store/intrinsics/truthTable";
+import { theme } from "../style";
+
+export function TruthTableView({ table }: { table: TruthTable }) {
+ const columns = [
+ ...table.inputs.map((name) => ({ key: `in-${name}`, name })),
+ ...table.outputs.map((name) => ({ key: `out-${name}`, name })),
+ ];
+ const cellSx = (column: number) =>
+ ({
+ px: 1,
+ py: 0.25,
+ textAlign: "center",
+ ...(table.inputs.length > 0 &&
+ column === table.inputs.length && {
+ borderLeft: 1,
+ borderColor: "divider",
+ }),
+ }) as const;
+
+ return (
+
+
+
+ {columns.map(({ key, name }, i) => (
+
+ {name}
+
+ ))}
+
+
+
+ {table.rows.map((row) => (
+
+ {[...row.inputs, ...row.outputs].map((value, i) => (
+
+ {bitLabel(value)}
+
+ ))}
+
+ ))}
+
+
+ );
+}
diff --git a/src/i18n/en.ts b/src/i18n/en.ts
index badfef4..726a0ef 100644
--- a/src/i18n/en.ts
+++ b/src/i18n/en.ts
@@ -27,7 +27,7 @@ export const en = {
FALSE: "Always OFF",
},
about: (name: string) => `About ${name}`,
- ofStage: "Parts you can use in this stage",
+ ofStage: "Available parts",
},
header: {
language: "Language",
@@ -106,6 +106,7 @@ export const en = {
startOverFailed: "Could not start the tutorial over.",
stages: "Stages",
parts: "Parts",
+ goalHeading: "Goal",
check: "Check",
passed: "Cleared! The circuit works for every combination of the inputs.",
next: "Next stage",
diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts
index 2cdf418..aac3d55 100644
--- a/src/i18n/ja.ts
+++ b/src/i18n/ja.ts
@@ -23,7 +23,7 @@ export const ja: Messages = {
FALSE: "いつも OFF",
},
about: (name) => `${name} について`,
- ofStage: "この課題で使える部品",
+ ofStage: "使える部品",
},
header: {
language: "言語",
@@ -101,6 +101,7 @@ export const ja: Messages = {
startOverFailed: "チュートリアルをやり直せませんでした。",
stages: "課題の一覧",
parts: "部品",
+ goalHeading: "目標",
check: "確かめる",
passed: "クリア!どの入力の組み合わせでも正しく動きます。",
next: "次の課題へ",
diff --git a/src/pages/tutorial/stage.tsx b/src/pages/tutorial/stage.tsx
index 25cb779..26a0103 100644
--- a/src/pages/tutorial/stage.tsx
+++ b/src/pages/tutorial/stage.tsx
@@ -9,7 +9,7 @@ import {
Typography,
} from "@mui/material";
import nullthrows from "nullthrows";
-import { useEffect, useState } from "react";
+import { type ReactNode, useEffect, useState } from "react";
import {
Navigate,
Link as RouterLink,
@@ -19,13 +19,18 @@ import {
import { valueLabel } from "../../common/bitLabel";
import { ConfirmDialog } from "../../components/ConfirmDialog";
import { PartDescription } from "../../components/PartDescription";
+import { TruthTableView } from "../../components/TruthTableView";
import { type Messages, useMessages } from "../../i18n";
import type CCStore from "../../store";
import { definitionByComponentId } from "../../store/intrinsics/definitions";
import { SimulationNodeError } from "../../store/netlist";
import { StoreScope } from "../../store/react";
import { theme } from "../../style";
-import { type CheckResult, checkCombinational } from "../../tutorial/check";
+import {
+ type CheckResult,
+ checkCombinational,
+ truthTableOfCheck,
+} from "../../tutorial/check";
import { markStageCleared } from "../../tutorial/progress";
import {
getTutorialStageStore,
@@ -72,6 +77,19 @@ function describeFailure(
}
}
+function SectionHeading({ children }: { children: ReactNode }) {
+ return (
+
+ {children}
+
+ );
+}
+
function StageView({ stage }: { stage: TutorialStage }) {
const messages = useMessages();
const texts = messages.tutorial;
@@ -79,6 +97,7 @@ function StageView({ stage }: { stage: TutorialStage }) {
const stageIndex = tutorialStages.indexOf(stage);
const nextStage = tutorialStages[stageIndex + 1];
const componentName = texts.stageTexts[stage.id].title;
+ const goalTable = truthTableOfCheck(stage.check);
const [store, setStore] = useState(() =>
getTutorialStageStore(stage, componentName),
@@ -150,11 +169,19 @@ function StageView({ stage }: { stage: TutorialStage }) {
{texts.stageNumber(stageIndex + 1)}
-
+
{texts.stageTexts[stage.id].title}
- {texts.stageTexts[stage.id].goal}
+
+ {texts.goalHeading}
+ {texts.stageTexts[stage.id].goal}
+ {goalTable && (
+
+
+
+ )}
+