Skip to content

Fix the quick-check quiz UI: contrast, semantics, and the answer leak - #19

Merged
samanyugoyal2010 merged 3 commits into
mainfrom
quiz-ui-fixes
Aug 7, 2026
Merged

Fix the quick-check quiz UI: contrast, semantics, and the answer leak#19
samanyugoyal2010 merged 3 commits into
mainfrom
quiz-ui-fixes

Conversation

@samanyugoyal2010

Copy link
Copy Markdown
Contributor

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

  • New lesson
  • Lesson fix or improvement
  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Breaking change

Checklist

  • npm run check passes (lint + typecheck + lesson validator + build)

If this touches /learn

  • A lesson proposal issue was opened and confirmed before writing
  • npm run learn:check passes
  • Every id in headings has a matching id="..." in the body component
  • Cover art added — not the silent fallback
  • Data is seeded at module scope; no Math.random(), Date.now(), or new Date()
  • No toLocaleString or Intl.NumberFormat
  • Composed from src/components/learn/primitives/, no hand-rolled styled blocks
  • No heading ids renamed on an existing lesson (they are permanent links)
  • Read back at 375px and with reduced motion
  • Original work, not paraphrased from another course, book, or blog

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>
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
new-cwp Ready Ready Preview Aug 7, 2026 9:16pm

samanyugoyal2010 and others added 2 commits August 7, 2026 13:27
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
@samanyugoyal2010
samanyugoyal2010 merged commit 7ae7780 into main Aug 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant