8000 Study: a "One paragraph at a time" switch on a stage, remembered in the browser · Issue #323 · alexbeeken/skrongle-mini · GitHub
[go: up one dir, main page]

Skip to content

Study: a "One paragraph at a time" switch on a stage, remembered in the browser #323

In review

Description

@alexbeeken

First of four small issues that add One paragraph at a time to Study: a concept step shows its first paragraph and each tap brings the next. This issue adds only the switch and remembers it. The switch changes nothing on the page yet; the next issue reads it.

Decided

  • Study stages only (/study/{slug}), not the lesson page under Lessons.
  • Off for everyone until they switch it on.
  • Remembered in the browser, like the audio switch (speech:audio in static/core.js). No database column, no server code.

What to build

  1. templates/stage.html: in <div class="stage-hud">, before <span class="hud-step">, add a button:
    • type="button", class="switch", role="switch", aria-checked="false", id="one-paragraph", data-testid="stage-one-paragraph".
    • Inside it: <span class="switch-knob" aria-hidden="true"></span> and the label {{ crate::t("guide.play.one_paragraph") }}.
    • Reuse the existing .switch / .switch-knob styles (static/style.css, near line 1403). Look at another .switch in templates/ and copy its markup shape so it looks the same. Add no new switch CSS unless the HUD row needs a wrap rule; .stage-hud must wrap at phone width (400px) without horizontal scroll.
  2. static/guide.js:
    • onePara() reads localStorage.getItem("study:one-paragraph") === "1" inside try/catch (private mode throws; then it is false).
    • On load, set the button's aria-checked and root.dataset.oneParagraph ("true" / "false") from it.
    • On click, flip it, write "1" or "0" (in try/catch), update both attributes, and dispatch new CustomEvent("oneparagraph") on root so the next issue can listen.
  3. i18n: add one_paragraph under guide.play (beside got_it) in all six files. cargo test fails if one file lacks the key.
    • en: "One paragraph at a time"
    • es: "Un párrafo a la vez"
    • de: "Ein Absatz nach dem anderen"
    • fr: "Un paragraphe à la fois"
    • pt: "Um parágrafo de cada vez"
    • zh: "一次一段"

Done when

  • A stage shows the switch beside the step counter, off.
  • Clicking it turns it on; reloading the page, or opening another stage, shows it still on.
  • #stage[data-one-paragraph] and the button's aria-checked always agree.
  • Nothing else on the stage changes.

Not in this issue

Hiding paragraphs, the animation, the e2e spec, docs and changelog (the three issues after this one). Don't run cargo fmt.

Checks

cargo build, then push and read gh pr checks. By eye: ./.dev-start --reset --seed --background, /dev/login, open a Study stage.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0