Files
CatoandClaude 0a57ad24a8 feat(practice): the start card comes first, a chosen tile is an outline, and the button honours your situations (#349)
The practice page opens with one card: what kind of sitting, and the button
that starts it. Everything that tailors or explains follows.

A chosen tile or chip is no longer a solid black slab. One `choice` utility
draws every selection the same way: light at rest; a dark outline, a faint
tint and a check mark in the corner when chosen. The start button is the
only filled block on the screen. Used by the practice chooser, the
situations form, the session settings, the theme and language settings, the
vocabulary filters and the sector chips.

The start button used to practise everything whatever the learner had
chosen below it. Choosing a situation now takes effect as it is tapped, the
button starts from the chosen situations (`startScope`, with a test), and
one line under it says which it is: your situations, or everything.


Claude-Session: https://claude.ai/code/session_019MDtmvb6xi489TfZMg7n9T

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-25 12:10:30 +01:00

26 lines
1.1 KiB
TypeScript

import { focusScope, type Focus } from "./focus.ts";
import type { Flow } from "./mode.ts";
import type { Scope } from "./scope.ts";
/**
* What the start button on `/practice` starts, and why.
*
* - `url` the page was opened on one thing (a topic, a scene, some words):
* that is the sitting, and the page already names it.
* - `focus` nothing was asked for and the learner has chosen their
* situations: practice draws from those.
* - `all` nothing was asked for and nothing chosen: everything.
*
* A TEST IS NEVER NARROWED HERE. Whether a scope can be tested at all is
* decided on the server from its pool (`testable`); narrowing it in the
* browser could hand the learner a test of three questions, or of none.
*/
export type Start = { scope: Scope; from: "url" | "focus" | "all" };
export function startScope(scope: Scope, flow: Flow, focus: Focus | null): Start {
if (scope.kind !== "all") return { scope, from: "url" };
if (flow === "test") return { scope, from: "all" };
const own = focusScope(focus);
return own.kind === "all" ? { scope, from: "all" } : { scope: own, from: "focus" };
}