Skip to content

Components

Two kinds of component:

  • Astro components render to HTML at build time and ship no JavaScript.
  • Effect UI components (effect/ui) are interactive. Their logic is Effect code: a pure update, Commands for side effects, Queries for data, Layers for services. Each one is mounted into the page by src/ui/mount.ts.

Callouts, steps, tabs and code blocks come from Starlight and are themed, not rebuilt.

Pure update, no side effects. Each exercise is one component in src/ui/exercises/, registered in src/ui/mount.ts.

<Exercise name="exhaustive-switch" />

Monaco in an Effect UI mount (AttachEditor). Live errors and hover types come from TypeScript itself, running in Monaco’s worker. Run (or ⌘ ↵) compiles with the Compiler service and executes in the Sandbox service: a throwaway Web Worker with a 5 second limit. With tests, a hidden tests.ts is type-checked against your code and its bun:test tests run against it. The .js and .d.ts tabs show TypeScript’s own emit.

import starter from "../exercises/m2-exhaustive/main.starter.ts?raw"
import tests from "../exercises/m2-exhaustive/main.test.ts?raw"
<Playground id="m2-exhaustive" title="Exercise" file="relay/events.ts" code={starter} tests={tests} />

Reads progress through a Query (GetProgress) and writes it with a Command (ToggleLesson), both backed by a ProgressStore service over KeyValueStore (localStorage in the browser, memory in tests). The toggle invalidates the query, so the list refreshes itself.

<ModuleProgress module="m2" title="M2 · Modeling the domain" current="m2/discriminated-unions" />
  1. Write the failing test.
  2. Make it pass.
  3. Run tsc --noEmit.
Terminal window
bun test

Keys use the native element: ⌘ K opens search.