From df34337b4ac5f7291fe329ea78b31a1d3055bf8c Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Mon, 12 Oct 2026 21:15:56 +0000 Subject: [PATCH] Accessibility pass, report control for homework exercises, clearer rail actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - axe is clean across every screen in both themes, phone and desktop. Fixed: the hidden file inputs (aria-hidden + tabIndex -1 — they are opened by labelled buttons, so they should not be in the accessibility tree), the heading order (deck/homework/smart-review cards are h2 under the page h1; LearningSection takes a level so it stays h2 on the library and h3 inside the settings dialog) and landmarks around the study and review feeds. - tests/contrast.mjs (new diagnostic): samples rendered pixels, because axe cannot judge text on blurred glass — it reports those nodes as incomplete. It skips disabled controls (1.4.3 exempts them) and content behind an open sheet. Result: no below-minimum text on any scanned screen. - The report control exists in the homework guide too: under each "Try it yourself" exercise, labelled "Report exercise", without a skip (there is no queue to skip). lib/question-reports now takes deckId/deckTitle directly. - The rail's two creation actions are buttons now (.nav-action) rather than quiet nav rows — once the library is full they were the only way to start something on desktop and read as just more navigation. "Make my homework" is "New homework" wherever it is an action (rail, empty state, share chooser, manifest shortcut); the page title and mode switch keep their wording. Version 0.1.6 (three task bumps), SW -> freezmo-v52. --- app/deck/[id]/page.tsx | 5 +- app/globals.css | 22 ++++ app/manifest.ts | 2 +- components/DataSection.tsx | 2 + components/DeckCard.tsx | 4 +- components/HomeworkCard.tsx | 4 +- components/LearningSection.tsx | 13 +- components/LibraryScreen.tsx | 2 + components/ReportQuestionButton.tsx | 31 +++-- components/ReviewClient.tsx | 63 +++++----- components/SessionFeed.tsx | 3 +- components/SettingsDialog.tsx | 4 +- components/Sidebar.tsx | 13 +- components/StudyFeed.tsx | 3 +- components/UploadScreen.tsx | 8 ++ components/chat/Composer.tsx | 2 + components/homework/HomeworkGuide.tsx | 13 +- components/homework/HomeworkInput.tsx | 12 ++ lib/i18n-dict.ts | 10 +- lib/question-reports.ts | 11 +- package.json | 2 +- public/sw.js | 2 +- tests/contrast.mjs | 169 ++++++++++++++++++++++++++ tests/mobile-test.mjs | 4 +- tests/native-test.mjs | 2 +- tests/regression.mjs | 4 +- tests/wizard-test.mjs | 2 +- 27 files changed, 337 insertions(+), 75 deletions(-) create mode 100644 tests/contrast.mjs diff --git a/app/deck/[id]/page.tsx b/app/deck/[id]/page.tsx index bb6eac8..5927fad 100644 --- a/app/deck/[id]/page.tsx +++ b/app/deck/[id]/page.tsx @@ -72,7 +72,10 @@ export default function DeckPage() { return ( - + {/* The feed is a fixed overlay, but its content still needs a landmark. */} +
+ +
); } diff --git a/app/globals.css b/app/globals.css index 4357eb8..c5d4249 100644 --- a/app/globals.css +++ b/app/globals.css @@ -647,6 +647,28 @@ body:has(.overlay-open) :is(.app-header, .segmented, .tabbar) { background: var(--hover); color: var(--text); } + +/* The rail's two creation actions ("New deck", "New homework") are buttons, + not nav rows: once the library is full the empty-state CTAs are long gone, + and on desktop the rail is the only place left to start something. */ +.nav-action { + display: flex; + align-items: center; + gap: 0.625rem; + width: 100%; + border-radius: 0.75rem; + padding: 0.5rem 0.625rem; + font-size: 13.5px; + font-weight: 600; + color: var(--text); + background: var(--surface-strong); + border: 1px solid var(--glass-border); + transition: background-color 160ms ease, border-color 160ms ease; +} +.nav-action:hover { + background: var(--hover); + border-color: var(--nav-active-border); +} .nav-row[aria-current="page"], .nav-row[aria-pressed="true"] { background: var(--nav-active-bg); diff --git a/app/manifest.ts b/app/manifest.ts index 205c105..26d61e4 100644 --- a/app/manifest.ts +++ b/app/manifest.ts @@ -55,7 +55,7 @@ export default function manifest(): MetadataRoute.Manifest { ], shortcuts: [ { name: "New deck", short_name: "New", url: "/create" }, - { name: "Make my homework", short_name: "Homework", url: "/homework" }, + { name: "New homework", short_name: "Homework", url: "/homework" }, { name: "Library", short_name: "Library", url: "/" }, ], /* Share text and links from other apps (GET). Files are POSTed to the diff --git a/components/DataSection.tsx b/components/DataSection.tsx index bc33178..1bf771d 100644 --- a/components/DataSection.tsx +++ b/components/DataSection.tsx @@ -78,6 +78,8 @@ export function DataSection() { void pick(event.target.files?.[0])} diff --git a/components/DeckCard.tsx b/components/DeckCard.tsx index e42fce4..3a8621a 100644 --- a/components/DeckCard.tsx +++ b/components/DeckCard.tsx @@ -182,12 +182,12 @@ export function DeckCard({ ) : ( -

{truncate(deck.title, 90)} -

+ )} {/* Phones: one compact meta line. */}

diff --git a/components/HomeworkCard.tsx b/components/HomeworkCard.tsx index 43019e7..c085181 100644 --- a/components/HomeworkCard.tsx +++ b/components/HomeworkCard.tsx @@ -62,12 +62,12 @@ export function HomeworkCard({

-

{truncate(record.title, 90)} -

+

{record.mode === "make" ? : } diff --git a/components/LearningSection.tsx b/components/LearningSection.tsx index ebe20ef..0043eaf 100644 --- a/components/LearningSection.tsx +++ b/components/LearningSection.tsx @@ -25,7 +25,12 @@ function urlBase64ToUint8Array(base64: string): Uint8Array { * the server has VAPID keys configured. Without them the reminder block is * hidden completely, exactly as if the feature did not exist. */ -export function LearningSection() { +/** + * `level` keeps the heading order right in both places it is used: h2 on the + * library page (under its h1) and h3 inside the settings dialog (under its h2 + * title). + */ +export function LearningSection({ level = 2 }: { level?: 2 | 3 } = {}) { const { t } = useI18n(); const dailyGoal = useSyncExternalStore( settingsStore.subscribe, @@ -154,7 +159,11 @@ export function LearningSection() { return (

-

{t("settings.learning")}

+ {level === 3 ? ( +

{t("settings.learning")}

+ ) : ( +

{t("settings.learning")}

+ )}

{t("settings.dailyGoal")}

diff --git a/components/LibraryScreen.tsx b/components/LibraryScreen.tsx index ac7cc77..4e1bba6 100644 --- a/components/LibraryScreen.tsx +++ b/components/LibraryScreen.tsx @@ -220,6 +220,8 @@ export function LibraryScreen({ initialTab = "decks" }: { initialTab?: "decks" | { diff --git a/components/ReportQuestionButton.tsx b/components/ReportQuestionButton.tsx index b26686a..a2cef9c 100644 --- a/components/ReportQuestionButton.tsx +++ b/components/ReportQuestionButton.tsx @@ -3,22 +3,31 @@ import { haptic } from "@/lib/haptics"; import { useI18n } from "@/lib/i18n"; import { reportQuestion, unreportQuestion } from "@/lib/question-reports"; -import type { Activity, Deck } from "@/lib/schemas"; +import type { Activity } from "@/lib/schemas"; import { showToast } from "@/lib/toast"; /** * The red "!" report control that sits under the card (bottom-right of the - * exercise): records the question, sends the operator a copy and skips past - * it. Undo lives in the toast. 44px, because it is a thumb target. + * exercise): records the question, sends the operator a copy and — in the + * study feeds — skips past it. Undo lives in the toast. 44px, because it is a + * thumb target. + * + * `deckId` is a deck id in the feeds and the homework record's id for a + * homework exercise; `onSkip` is omitted where there is no queue to skip. */ export function ReportQuestionButton({ - deck, + deckId, + deckTitle, activity, onSkip, + labelKey = "feed.report", }: { - deck: Deck; + deckId: string; + deckTitle?: string; activity: Activity; - onSkip: () => void; + onSkip?: () => void; + /** i18n key for the accessible name ("Report question" / "Report exercise"). */ + labelKey?: string; }) { const { t } = useI18n(); @@ -27,16 +36,16 @@ export function ReportQuestionButton({ type="button" onClick={() => { haptic("tap"); - reportQuestion({ deck, activity }); + reportQuestion({ deckId, deckTitle, activity }); showToast({ message: t("feed.reported"), actionLabel: t("toast.undo"), - onAction: () => unreportQuestion(deck.id, activity.id), + onAction: () => unreportQuestion(deckId, activity.id), }); - onSkip(); + onSkip?.(); }} - aria-label={t("feed.report")} - title={t("feed.report")} + aria-label={t(labelKey)} + title={t(labelKey)} className="grid size-11 shrink-0 place-items-center rounded-xl border-2 border-rose-400/80 text-base font-black leading-none text-rose-600 transition hover:bg-rose-50 dark:border-rose-400/50 dark:text-rose-300 dark:hover:bg-rose-400/10" > ! diff --git a/components/ReviewClient.tsx b/components/ReviewClient.tsx index aabd2e6..dfb4598 100644 --- a/components/ReviewClient.tsx +++ b/components/ReviewClient.tsx @@ -81,36 +81,39 @@ export function ReviewClient({ mistakes, deckId }: { mistakes: boolean; deckId?: const sessionItems: SessionItem[] = session.map(({ deck, activity }) => ({ deck, activity })); return ( - router.push("/")} - onAnswered={(item, correct) => { - haptic(correct ? "success" : "error"); - recordAnswer({ - deckId: item.deck.id, - deckTitle: item.deck.title, - activityId: item.activity.id, - type: item.activity.type, - topic: item.activity.topic, - correct, - }); - }} - renderResults={({ correct, total, score }) => ( -
-

{title}

-

{score}%

-

- {t("results.gotOf", { correct, total, retry: "" })} -

-
- + // The feed is a fixed overlay, but its content still needs a landmark. +
+ router.push("/")} + onAnswered={(item, correct) => { + haptic(correct ? "success" : "error"); + recordAnswer({ + deckId: item.deck.id, + deckTitle: item.deck.title, + activityId: item.activity.id, + type: item.activity.type, + topic: item.activity.topic, + correct, + }); + }} + renderResults={({ correct, total, score }) => ( +
+

{title}

+

{score}%

+

+ {t("results.gotOf", { correct, total, retry: "" })} +

+
+ +
-
- )} - /> + )} + /> + ); } diff --git a/components/SessionFeed.tsx b/components/SessionFeed.tsx index 78b5cf8..40dc1f5 100644 --- a/components/SessionFeed.tsx +++ b/components/SessionFeed.tsx @@ -221,7 +221,8 @@ export function SessionFeed({
{ setSkipped((current) => [...current, item.activity.id]); diff --git a/components/SettingsDialog.tsx b/components/SettingsDialog.tsx index 3096328..8db0245 100644 --- a/components/SettingsDialog.tsx +++ b/components/SettingsDialog.tsx @@ -407,7 +407,7 @@ export function SettingsDialog({
{/* ------------------------------------------- data & sync */} - + @@ -746,7 +746,7 @@ export function SettingsDialog({ {/* ------------------------------------------- data & sync */} - + diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 0950082..bba0f29 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -137,23 +137,24 @@ function NavContent({ collapsed = false }: { collapsed?: boolean }) { {!collapsed ? {t("sidebar.collapse")} : null} - {/* new deck: a quiet row, not a competing primary button ---------- */} + {/* new deck: a button, not a nav row — it stays visible when the + library is already full (see .nav-action in globals.css) --------- */} - + {!collapsed ? {t("common.newDeck")} : null} - {/* make my homework: same quiet row --------------------------------- */} + {/* new homework: the same button ------------------------------------ */} - + {!collapsed ? {t("homework.nav")} : null} diff --git a/components/StudyFeed.tsx b/components/StudyFeed.tsx index b86aa45..b9d8a6d 100644 --- a/components/StudyFeed.tsx +++ b/components/StudyFeed.tsx @@ -332,7 +332,8 @@ export function StudyFeed({ deck }: { deck: Deck }) {
{ setSkipped((current) => [...current, activity.id]); diff --git a/components/UploadScreen.tsx b/components/UploadScreen.tsx index 4558cae..7dca7bb 100644 --- a/components/UploadScreen.tsx +++ b/components/UploadScreen.tsx @@ -650,6 +650,8 @@ export function UploadScreen() { { diff --git a/components/homework/HomeworkGuide.tsx b/components/homework/HomeworkGuide.tsx index a7af976..0ad75ef 100644 --- a/components/homework/HomeworkGuide.tsx +++ b/components/homework/HomeworkGuide.tsx @@ -6,6 +6,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { ActivityRenderer } from "@/components/activities"; import { PromptCard, QuestionText } from "@/components/activities/shared"; import { AiDisclaimer } from "@/components/AiDisclaimer"; +import { ReportQuestionButton } from "@/components/ReportQuestionButton"; import { XIcon } from "@/components/icons"; import { Button, ProgressBar } from "@/components/ui"; import { AskButton } from "@/components/chat/AskButton"; @@ -246,7 +247,7 @@ export function HomeworkGuide({ {/* checkpoint or a plain next button */} {step.checkpoint ? ( -
+

{t("homework.guide.tryIt")}

@@ -263,6 +264,16 @@ export function HomeworkGuide({ }} onNext={() => goTo(stepIndex + 1)} /> + {/* Same report control as the study feeds, under the + exercise (the homework record is the "deck" here). */} +
+ +
) : (