8000 Study: with the switch on, a concept step shows one block per tap · Issue #324 · alexbeeken/skrongle-mini · GitHub
[go: up one dir, main page]

Skip to content

Study: with the switch on, a concept step shows one block per tap #324

In review

Description

@alexbeeken

Second of four. Depends on #323 (the switch). With the switch on, a Study concept step shows one block of text at a time.

Words

  • A block is a direct child element of the step's .prose (a paragraph, a list, a table, a quote). One block is revealed per tap, whatever it is.
  • A step reveals when the switch is on, its data-kind is concept, and it has two or more blocks. Every other step behaves as it does today.

What to build

All of it is in static/guide.js, static/guide.css and two i18n keys. No server code. No change to /api/guide/step.

  1. Load the stylesheet: templates/stage.html does not load guide.css yet. Add a {% block head %} with the same <link> line templates/guide.html has. Put new CSS in static/guide.css, not style.css.
  2. When a step is shown (show(i) in guide.js) and it reveals:
    • Add class waiting to every block but the first. CSS: .step .prose > .waiting { visibility: hidden; }. Use visibility, not hidden or display: none: the card keeps its full height so the button does not move.
    • Set on the step data-blocks="<count>" and data-shown="1".
    • Change the step's [data-continue] button text to t('guide.js.show_next'). Keep its original text to put back later.
  3. Revealing: while data-shown < data-blocks, a click on [data-continue] removes waiting from the next block and adds one to data-shown, and does not call complete(). When the last block shows, put the button's original text back; its next click calls complete(i, false) as today.
    • The same reveal happens on a click anywhere on the step, unless the click was on a button, a, .say, or the learner has selected text (String(window.getSelection()) is not empty).
    • The same reveal happens on the → key (ArrowRight), unless focus is in an input, textarea or select. → never completes a step; only the button does.
    • While a step still has waiting blocks, give it class revealing and style .step.revealing { cursor: pointer; }.
  4. Screen readers: add to each concept step, from the script, one <p class="sr-only" aria-live="polite">. On each reveal set its text to the revealed block's textContent. (.sr-only exists in style.css.)
  5. The switch, mid-step: listen for the oneparagraph event on #stage (from Study: a "One paragraph at a time" switch on a stage, remembered in the browser #323).
    • Turned off: remove waiting from every block of the step on screen, remove revealing, put the button text back.
    • Turned on: nothing changes on the step on screen. It applies from the next step shown.
  6. i18n: add show_next under guide.js (beside next) in all six files:
    • en: "Show next" · es: "Mostrar siguiente" · de: "Nächsten zeigen" · fr: "Afficher la suite" · pt: "Mostrar o seguinte" · zh: "显示下一段"

Done when

  • Switch off: every stage plays exactly as before (the existing specs click stage-continue once per concept step and must still pass).
  • Switch on, concept step with 3 blocks: one block visible, button says Show next. Two taps later all three show and the button says Got it. Got it opens the next step.
  • Switch on, a concept step with one block, a tip, a terms step or a question: unchanged.
  • Turning the switch off mid-step shows the rest at once.
  • The button stays at the same place on the page while blocks appear.

Not in this issue

Any animation (next issue), a counter, a Show all link, dimming read paragraphs, the lesson page under Lessons, the e2e spec and docs (last issue). Don't run cargo fmt.

Checks

cargo build, push, gh pr checks. By eye on the dev server: the seeded Spanish course's Ser vs estar stage (/study/ser-vs-estar), or any stage whose concept step has several paragraphs.

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