Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4d655fc
feat(tutorial): lay out the stage list in a grid
Rn86222 Nov 20, 2026
6390a9e
feat(tutorial): number the stage cards in large circles
Rn86222 Nov 20, 2026
d3544f5
fix(tutorial): keep a stage title on one line when it is cleared
Rn86222 Nov 20, 2026
44ebecf
fix(tutorial): centre the number in its circle
Rn86222 Nov 20, 2026
4f87272
fix(tutorial): keep every stage card the same height
Rn86222 Nov 20, 2026
2d32a9f
fix(tutorial): tell where the stages lead, and why any can come first
Rn86222 Nov 20, 2026
9084612
feat(tutorial): show a stage's number in the same circle on its own page
Rn86222 Nov 20, 2026
59da5c9
fix(tutorial): say the first stage rather than its number in the lead
Rn86222 Nov 20, 2026
5be6b85
fix(tutorial): put each sentence of the list's lead on its own line
Rn86222 Nov 20, 2026
02e8c7d
feat(tutorial): mark the next stage in the list
Rn86222 Nov 20, 2026
1e9ca94
chore(tutorial): drop comments that restate the code
Rn86222 Nov 20, 2026
04c9e52
feat: introduce the app on the start page, and tell who each mode is for
Rn86222 Nov 20, 2026
dc5941f
fix: widen the start page back, as it now holds a long description
Rn86222 Nov 20, 2026
05b6a1d
fix: put each sentence of the start page's description on its own line
Rn86222 Nov 20, 2026
480d283
fix: say what the tutorial is made of on the start page
Rn86222 Nov 20, 2026
6a1b2f1
fix(tutorial): name stages by what their circuits do
Rn86222 Nov 20, 2026
2c8c002
fix(tutorial): address the review of the list and start pages
Rn86222 Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/appName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const appName = "CreateCPU";
3 changes: 2 additions & 1 deletion src/components/GlobalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -55,7 +56,7 @@ export default function GlobalHeader({ style }: GlobalHeaderProps) {
}}
>
<Link component={RouterLink} to="/" color="inherit" underline="hover">
CreateCPU
{appName}
</Link>
{mode && (
<Chip
Expand Down
8 changes: 8 additions & 0 deletions src/components/visuallyHidden.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const visuallyHiddenSx = {
position: "absolute",
width: "1px",
height: "1px",
overflow: "hidden",
clip: "rect(0 0 0 0)",
whiteSpace: "nowrap",
} as const;
33 changes: 22 additions & 11 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type StageTexts = {

const stageTexts: Record<TutorialStageId, StageTexts> = {
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.",
],
Expand All @@ -33,16 +33,16 @@ const stageTexts: Record<TutorialStageId, StageTexts> = {
],
},
"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: [],
},
Expand Down Expand Up @@ -87,7 +87,7 @@ const stageTexts: Record<TutorialStageId, StageTexts> = {
],
},
"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.",
Expand All @@ -109,8 +109,8 @@ const stageTexts: Record<TutorialStageId, StageTexts> = {
"<check> 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 <play>. If {Start} is [OFF] at the first time step, click it to turn it [ON]. Press <auto>, and the {Display} goes on like a clock, one time step a second. To see what comes after 59:59, stop <auto>, click the number at the bottom, enter 3600 and press the <enter> key. It goes to that time step at once and shows 59:59, and the right arrow <nextStep> shows 00:00.",
],
Expand Down Expand Up @@ -165,9 +165,16 @@ export const en = {
},
},
start: {
intro: (appName: string) => [
"The brain of a computer or a smartphone, the CPU, is built from combinations of simple logic elements.",
`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?",
tutorial:
"Build logic circuits step by step, starting from a pair of switches.",
tutorialAudience: "New here? Start here.",
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.",
},
home: {
Expand Down Expand Up @@ -225,9 +232,13 @@ export const en = {
timeStep: "Time step",
},
tutorial: {
lead: "Going from the top is recommended, but you can start from any stage.",
lead: [
"Starting at the first stage, build circuit after circuit, and finish a stopwatch in the last 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: "Continue here",
startOver: "Start over from the beginning",
startOverDialog: {
title: "Start the tutorial over?",
Expand Down Expand Up @@ -277,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
>,
Expand Down
32 changes: 22 additions & 10 deletions src/i18n/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ export const ja: Messages = {
},
},
start: {
intro: (appName) => [
"パソコンやスマホの頭脳「CPU」は、単純な論理素子の組み合わせからできています。",
`${appName} では、画面上で小さな回路を並べてつなぎ、動かしながら論理回路について学べます。`,
"パズル感覚で試行錯誤しながら、コンピュータの中身をのぞいてみませんか?",
],
title: "何をしますか?",
tutorial: "2つのスイッチから始めて、課題に沿って論理回路を組み立てます。",
tutorialAudience: "はじめての方はこちら",
tutorial: (stageCount) =>
`${stageCount}つの課題を順に解きながら回路を作り、最後にストップウォッチを完成させます。`,
freeAudience: "論理回路を知っている方向け",
free: "好きな回路を自由に作ります。",
},
home: {
Expand Down Expand Up @@ -106,9 +114,13 @@ export const ja: Messages = {
timeStep: "ステップ",
},
tutorial: {
lead: "上から順に進めるのがおすすめですが、どの課題からでも始められます。",
lead: [
"最初の課題から順に回路を組み立てていき、最後にストップウォッチを完成させます。",
"前の課題で作った回路が必要な課題では、その回路が完成した部品として渡されるので、どの課題からでも始められます。",
],
stageNumber: (number) => `課題 ${number}`,
cleared: "クリア",
upNext: "続きはここから",
startOver: "最初からやり直す",
startOverDialog: {
title: "チュートリアルを最初からやり直しますか?",
Expand Down Expand Up @@ -146,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] になるようにしましょう。下の表のとおりに動けばクリアです。",
],
Expand All @@ -162,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: [],
},
Expand Down Expand Up @@ -216,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} は、上の桁に桁上がりを知らせる合図です。",
Expand All @@ -238,8 +250,8 @@ export const ja: Messages = {
"<check>は、{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 に戻るときだけ、その上の桁が進みます。",
"再生ボタン<play>を押します。最初のステップで {Start} が [OFF] なら、クリックして [ON] にします。<auto>を押すと、1秒に1ステップずつ、{Display} が時計のように進みます。59:59 の次を見るには、<auto>を止めて下の数字をクリックし、3600 と入れて<enter>キーを押します。そのステップまで一度に進んで 59:59 になり、右の矢印<nextStep>を押すと 00:00 に戻ります。",
],
Expand Down
27 changes: 24 additions & 3 deletions src/pages/start/index.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
import { Card, CardActionArea, Container, Typography } from "@mui/material";
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();
const choices = [
{
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,
textColor: theme.colors.tutorial,
},
{
to: "/free",
audience: messages.start.freeAudience,
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 (
<div style={{ overflowY: "auto" }}>
<Container sx={{ px: 2, py: 6 }} maxWidth="md">
<Typography variant="h2" typography="h4" gutterBottom>
<Typography variant="h1" typography="h4" gutterBottom>
{appName}
</Typography>
{messages.start.intro(appName).map((sentence) => (
<Typography key={sentence} color="textSecondary">
{sentence}
</Typography>
))}
<Typography variant="h2" typography="h6" sx={{ mt: 4 }}>
{messages.start.title}
</Typography>
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(250px, 1fr))",
gap: "16px",
marginTop: "24px",
marginTop: "8px",
}}
>
{choices.map((choice) => (
Expand All @@ -44,6 +59,12 @@ export default function StartPage() {
to={choice.to}
sx={{ p: 3, flexGrow: 1, alignSelf: "stretch" }}
>
<Typography
variant="body2"
sx={{ color: choice.textColor, fontWeight: "bold" }}
>
{choice.audience}
</Typography>
<Typography variant="h3" typography="h5" gutterBottom>
{choice.title}
</Typography>
Expand Down
41 changes: 41 additions & 0 deletions src/pages/tutorial/StageNumber.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Box } from "@mui/material";
import { visuallyHiddenSx } from "../../components/visuallyHidden";
import { useMessages } from "../../i18n";
import { theme } from "../../style";

export function StageNumber({ number }: { number: number }) {
const messages = useMessages();
return (
<>
<Box component="span" sx={visuallyHiddenSx}>
{messages.tutorial.stageNumber(number)}
</Box>
<Box
component="span"
aria-hidden
sx={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexShrink: 0,
width: 32,
height: 32,
borderRadius: "50%",
border: 2,
borderColor: theme.colors.tutorial,
color: theme.colors.tutorial,
fontSize: "1.125rem",
fontWeight: "bold",
}}
>
{/* Trimmed to the digits, which otherwise sit low in their line */}
<Box
component="span"
sx={{ display: "block", textBox: "trim-both cap alphabetic" }}
>
{number}
</Box>
</Box>
</>
);
}
10 changes: 1 addition & 9 deletions src/pages/tutorial/StageText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down
Loading
Loading