Repository navigation
In review
Description
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-kindisconcept, 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.
- Load the stylesheet:
templates/stage.htmldoes not loadguide.cssyet. Add a{% block head %}with the same<link>linetemplates/guide.htmlhas. Put new CSS instatic/guide.css, notstyle.css. - When a step is shown (
show(i)inguide.js) and it reveals:- Add class
waitingto every block but the first. CSS:.step .prose > .waiting { visibility: hidden; }. Usevisibility, nothiddenordisplay: none: the card keeps its full height so the button does not move. - Set on the step
data-blocks="<count>"anddata-shown="1". - Change the step's
[data-continue]button text tot('guide.js.show_next'). Keep its original text to put back later.
- Add class
- Revealing: while
data-shown<data-blocks, a click on[data-continue]removeswaitingfrom the next block and adds one todata-shown, and does not callcomplete(). When the last block shows, put the button's original text back; its next click callscomplete(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 aninput,textareaorselect. → never completes a step; only the button does. - While a step still has waiting blocks, give it class
revealingand style.step.revealing { cursor: pointer; }.
- The same reveal happens on a click anywhere on the step, unless the click was on a
- 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'stextContent. (.sr-onlyexists instyle.css.) - The switch, mid-step: listen for the
oneparagraphevent on#stage(from Study: a "One paragraph at a time" switch on a stage, remembered in the browser #323).- Turned off: remove
waitingfrom every block of the step on screen, removerevealing, put the button text back. - Turned on: nothing changes on the step on screen. It applies from the next step shown.
- Turned off: remove
- i18n: add
show_nextunderguide.js(besidenext) 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-continueonce 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.
Metadata
Metadata
Assignees
Labels
No labels
Activity