Fix the quick-check quiz UI: contrast, semantics, and the answer leak - #19
Merged
Conversation
One component, so this lands on all 144 chapters across the six tracks. The worst of it was contrast. The line telling you that you failed used text-learn-code-err (#ff9b9b), a token designed for the near-black code surface, rendered on cream — roughly 1.8:1, well under AA, and the least readable text on the page at the moment it mattered most. The wrong-answer option used the same token as a border on an almost identically pale danger background. Both now use the light-surface danger tokens that exist for this. Correct and wrong were also signalled by colour alone, which the rest of this codebase is careful about — two-class charts vary mark shape as well as hue. Every option that means something now carries an icon and the words "Correct" or "Not this one". The options were bare buttons: no group, no aria-checked, no name. A screen reader announced four unrelated buttons with no indication that they were a choice or which one was picked. They are now real radios in a fieldset with a legend, which also buys arrow-key navigation for free. Checking answers changed the score, the colours and the pass state with nothing announced at all; the results now sit in an aria-live region. And a behavioural one worth calling out. On a failed attempt the quiz highlighted the correct answer for every question, then offered "Try again" — so the first wrong attempt handed over the entire answer key and the gate could not be failed twice. A failure now marks only the options the learner actually chose and says nothing about the rest. Retry also stops wiping correct answers, so fixing one question no longer means re-answering four. Emoji removed from the quiz and gate per the house rule in AGENTS.md: the padlocks and the koala are inline SVG or plain text now. The pager locks were also reading as "lock emoji Locked" to a screen reader. Koda's emoji elsewhere on the marketing pages are deliberate branding and are left alone. npm run check passes. The prerendered HTML for a chapter shows 4 fieldsets, 16 radios, and the live region, with no emoji. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Two separate causes, both firing on every single click. The flash. The <img> is keyed on the pose index, which is deliberate — a keyed remount is what replays the koala-pop animation. But it means each tap mounts a brand-new element with no bitmap attached, and decoding="async" is explicit permission to paint that empty element before the image arrives. koala-pop starts at opacity 0, so the two together gave a blank frame every time. All eight poses are now decoded once on mount, and this element decodes sync, so the remount paints with content in the same frame. The resize. The eight poses have eight different intrinsic ratios (440 to 560 wide against 560 tall, plus koala-sleep which is landscape), and the image was height:auto inside a width-only button — so the box changed height on every pose change, under the cursor, mid-animation. The button now has a fixed aspect-ratio and the image is object-fit:contain anchored to the bottom, so Koda's feet stay on one line and only the picture changes. min-height:0 on the button is not decoration. It is a flex item in a column, so its default min-height:auto let it grow to the image's natural height and overrode the aspect-ratio for exactly the poses more portrait than 500/560 — measured in the browser at 139px for koala-read and 147px for koala-tree against a 129px baseline. With it pinned, all eight poses now measure 115.2x129.0. Verified in a real browser: all eight poses fetched before the first tap, box identical across every pose, and the two extreme poses (koala-tree portrait, koala-sleep landscape) render undistorted and uncropped. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Stop Koda flickering and resizing on every tap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One component, so this lands on all 144 chapters across the six tracks.
The worst of it was contrast. The line telling you that you failed used text-learn-code-err (#ff9b9b), a token designed for the near-black code surface, rendered on cream — roughly 1.8:1, well under AA, and the least readable text on the page at the moment it mattered most. The wrong-answer option used the same token as a border on an almost identically pale danger background. Both now use the light-surface danger tokens that exist for this.
Correct and wrong were also signalled by colour alone, which the rest of this codebase is careful about — two-class charts vary mark shape as well as hue. Every option that means something now carries an icon and the words "Correct" or "Not this one".
The options were bare buttons: no group, no aria-checked, no name. A screen reader announced four unrelated buttons with no indication that they were a choice or which one was picked. They are now real radios in a fieldset with a legend, which also buys arrow-key navigation for free. Checking answers changed the score, the colours and the pass state with nothing announced at all; the results now sit in an aria-live region.
And a behavioural one worth calling out. On a failed attempt the quiz highlighted the correct answer for every question, then offered "Try again" — so the first wrong attempt handed over the entire answer key and the gate could not be failed twice. A failure now marks only the options the learner actually chose and says nothing about the rest. Retry also stops wiping correct answers, so fixing one question no longer means re-answering four.
Emoji removed from the quiz and gate per the house rule in AGENTS.md: the padlocks and the koala are inline SVG or plain text now. The pager locks were also reading as "lock emoji Locked" to a screen reader.
Koda's emoji elsewhere on the marketing pages are deliberate branding and are left alone.
npm run check passes. The prerendered HTML for a chapter shows 4 fieldsets, 16 radios, and the live region, with no emoji.
Summary
Related Issue
Type of Change
Checklist
npm run checkpasses (lint + typecheck + lesson validator + build)If this touches
/learnnpm run learn:checkpassesheadingshas a matchingid="..."in the body componentMath.random(),Date.now(), ornew Date()toLocaleStringorIntl.NumberFormatsrc/components/learn/primitives/, no hand-rolled styled blocks