Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/form-labels-and-motion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@reelsaw/server": patch
---

Accessibility: the sign-in, reset-password and must-change-password fields are labelled for screen readers and their errors are announced; the new-project upload box is reachable with Tab; the marketing site's looping demo clips and self-advancing feature tabs have a pause button.
69 changes: 69 additions & 0 deletions apps/server/test/ui-a11y-guards.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Accessibility fixes the browser ratchet (apps/web/e2e/a11y.spec.ts) does not reach: it runs signed in, on the main
* screens, against a running stack. Read as source, like the other web checks here.
* - Sign-in, reset and must-change-password: each field's label names its input (htmlFor/id), and errors are
* announced (role="alert", or a live region).
* - New project: the file input is visually hidden, not display:none, so the keyboard reaches it.
* - Marketing site: every looping demo clip and the self-advancing tabs obey a pause button (WCAG 2.2.2), not only
* prefers-reduced-motion.
*/
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

const root = path.join(import.meta.dirname, "..", "..", "..");
const read = (p: string) => fs.readFileSync(path.join(root, p), "utf8");

/** each <label className="label" …> with the first <input that follows it */
function labelledFields(src: string): Array<{ label: string; input: string }> {
const out: Array<{ label: string; input: string }> = [];
for (const m of src.matchAll(/<label className="label"[^>]*>/g)) {
const rest = src.slice(m.index);
const input = /<input\b[^>]*?(\/>|>)/s.exec(rest);
assert.ok(input, `no input after ${m[0]}`);
out.push({ label: m[0], input: input[0] });
}
return out;
}

describe("auth forms", () => {
for (const page of ["Login", "ResetPassword", "MustChangePassword"]) {
it(`${page}: every label names its input`, () => {
const fields = labelledFields(read(`apps/web/src/pages/${page}.tsx`));
assert.ok(fields.length >= 2);
for (const { label, input } of fields) {
const id = /htmlFor="([^"]+)"/.exec(label)?.[1];
assert.ok(id, `label without htmlFor: ${label}`);
assert.match(input, new RegExp(`\\bid="${id}"`), `input for ${id}`);
}
});
}
it("errors are announced", () => {
assert.match(read("apps/web/src/pages/Login.tsx"), /role=\{error \? "alert" : "status"\}/);
assert.match(read("apps/web/src/pages/MustChangePassword.tsx"), /role=\{save\.error \? "alert" : "status"\}/);
assert.match(read("apps/web/src/pages/ResetPassword.tsx"), /aria-live=\{tone === "err" \? "assertive" : "polite"\}/);
});
});

describe("new project upload", () => {
it("the file input is reachable by keyboard and its box shows focus", () => {
const src = read("apps/web/src/pages/NewProject.tsx");
const input = /<input[^>]*type="file"[^>]*>/.exec(src)?.[0];
assert.ok(input);
assert.doesNotMatch(input, /className="hidden"/);
assert.match(input, /className="sr-only"/);
assert.match(src, /focus-within:outline-acc/);
});
});

describe("marketing site motion", () => {
it("reduced motion includes the visitor's pause, and every moving section offers the pause button", () => {
const loop = read("website/components/loop-video.tsx");
assert.match(loop, /return reduced \|\| paused;/);
assert.match(loop, /const live = play && visible && !reduced;/);
for (const c of ["hero-reel", "clip-strip", "feature-tabs"]) assert.match(read(`website/components/${c}.tsx`), /<MotionToggle\b/, c);
// the tabs' auto-advance stops on the same flag
assert.match(read("website/components/feature-tabs.tsx"), /if \(touched \|\| reduced \|\| !visible\) return;/);
});
});
25 changes: 19 additions & 6 deletions apps/web/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,34 @@ export function LoginPage({ signup = false }: { signup?: boolean }) {
<AuthCardHeader title={expiredLink ? t`This link expired` : mode === "login" ? t`Sign in` : t`Create account`} />
{mode === "signup" && (
<div>
<label className="label">
<label className="label" htmlFor="login-name">
<Trans>Name</Trans>
</label>
<input className="input" name="name" autoComplete="name" value={name} onChange={(e) => setName(e.target.value)} />
<input id="login-name" className="input" name="name" autoComplete="name" value={name} onChange={(e) => setName(e.target.value)} />
</div>
)}
<div>
<label className="label">
<label className="label" htmlFor="login-email">
<Trans>Email</Trans>
</label>
<input className="input" name="email" type="email" autoComplete="email" required value={email} onChange={(e) => setEmail(e.target.value)} />
<input
id="login-email"
className="input"
name="email"
type="email"
autoComplete="email"
required
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
{!expiredLink && (
<div>
<label className="label">
<label className="label" htmlFor="login-password">
<Trans>Password</Trans>
</label>
<input
id="login-password"
key={mode}
className="input"
name="password"
Expand Down Expand Up @@ -268,7 +278,10 @@ export function LoginPage({ signup = false }: { signup?: boolean }) {
)}
{!expiredLink && captcha && <Captcha key={captchaAttempt} provider={captcha.provider} siteKey={captcha.siteKey} onToken={onToken} />}
{(error || notice) && (
<p className={`rounded-[10px] px-3 py-2 text-sm leading-relaxed text-ink ${error ? "bg-err-soft" : "bg-warn-soft"}`}>
<p
role={error ? "alert" : "status"}
className={`rounded-[10px] px-3 py-2 text-sm leading-relaxed text-ink ${error ? "bg-err-soft" : "bg-warn-soft"}`}
>
{error ?? accountNotice(notice)}
</p>
)}
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/pages/MustChangePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export function MustChangePasswordPage() {
<p className="text-sm leading-relaxed text-ink2">{accountNotice(MUST_CHANGE_PASSWORD_COPY)}</p>
<p className="min-h-5 text-xs text-ink3">{me.data ? t`Signed in as ${me.data.email}` : ""}</p>
<div>
<label className="label">
<label className="label" htmlFor="change-password-new">
<Trans>New password</Trans>
</label>
<input
id="change-password-new"
className="input"
name="password"
type="password"
Expand All @@ -65,10 +66,11 @@ export function MustChangePasswordPage() {
/>
</div>
<div>
<label className="label">
<label className="label" htmlFor="change-password-confirm">
<Trans>Confirm</Trans>
</label>
<input
id="change-password-confirm"
className="input"
name="confirm-password"
type="password"
Expand All @@ -81,7 +83,7 @@ export function MustChangePasswordPage() {
/>
</div>
{(save.error || mismatch || tooShort) && (
<p className="rounded-[10px] bg-err-soft px-3 py-2 text-sm leading-relaxed text-ink">
<p role={save.error ? "alert" : "status"} className="rounded-[10px] bg-err-soft px-3 py-2 text-sm leading-relaxed text-ink">
{save.error?.message ?? (tooShort ? t`Use at least 8 characters.` : t`The two passwords do not match.`)}
</p>
)}
Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/pages/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,14 @@ export function NewProjectPage() {
const f = [...e.dataTransfer.files].find(isVideo);
if (f) setFile(f);
}}
className="flex cursor-pointer flex-col items-center gap-1 rounded-[12px] border-2 border-dashed border-line2 px-4 py-6 text-center text-sm text-ink2 hover:border-acc"
className="flex cursor-pointer flex-col items-center gap-1 rounded-[12px] border-2 border-dashed border-line2 px-4 py-6 text-center text-sm text-ink2 hover:border-acc focus-within:border-acc focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-acc"
>
<span className="font-semibold text-ink">{file ? file.name : t`Choose or drop a video file`}</span>
<span className="text-xs text-ink3">
{file ? `${formatNumber(Math.round(file.size / 1e6))} MB` : t`MP4, MOV, MKV or WebM · up to ${maxUploadText} MB`}
</span>
<input className="hidden" type="file" accept="video/*,.mkv,.mov,.mp4,.webm" onChange={(e) => setFile(e.target.files?.[0] ?? null)} />
{/* visually hidden, not display:none, so Tab reaches it; the dashed box shows its focus */}
<input className="sr-only" type="file" accept="video/*,.mkv,.mov,.mp4,.webm" onChange={(e) => setFile(e.target.files?.[0] ?? null)} />
</label>
{uploadPct !== null && (
<div className="flex items-center gap-3">
Expand Down
21 changes: 17 additions & 4 deletions apps/web/src/pages/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ export function ResetPasswordPage() {
{choosing ? (
<>
<div>
<label className="label">
<label className="label" htmlFor="reset-new-password">
<Trans>New password</Trans>
</label>
<input
id="reset-new-password"
className="input"
name="password"
type="password"
Expand All @@ -140,10 +141,11 @@ export function ResetPasswordPage() {
/>
</div>
<div>
<label className="label">
<label className="label" htmlFor="reset-confirm-password">
<Trans>Confirm password</Trans>
</label>
<input
id="reset-confirm-password"
className="input"
name="confirm-password"
type="password"
Expand All @@ -157,14 +159,25 @@ export function ResetPasswordPage() {
</>
) : (
<div>
<label className="label">
<label className="label" htmlFor="reset-email">
<Trans>Email</Trans>
</label>
<input className="input" name="email" type="email" autoComplete="email" required value={email} onChange={(e) => setEmail(e.target.value)} />
<input
id="reset-email"
className="input"
name="email"
type="email"
autoComplete="email"
required
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
)}
{!choosing && captcha && <Captcha key={captchaEpoch} provider={captcha.provider} siteKey={captcha.siteKey} onToken={onToken} />}
{/* always rendered, so screen readers hear each new message: at once for an error, politely otherwise */}
<p
aria-live={tone === "err" ? "assertive" : "polite"}
className={`min-h-10 rounded-[10px] px-3 py-2 text-sm leading-relaxed ${tone === "err" ? "bg-err-soft text-ink" : tone === "warn" ? "bg-warn-soft text-ink" : "text-ink2"}`}
>
{banner ?? ""}
Expand Down
2 changes: 1 addition & 1 deletion scripts/lint-baseline.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a11y/noAutofocus": 11,
"a11y/noLabelWithoutControl": 21,
"a11y/noLabelWithoutControl": 13,
"a11y/noStaticElementInteractions": 28,
"a11y/useAriaPropsSupportedByRole": 5,
"a11y/useButtonType": 209,
Expand Down
15 changes: 9 additions & 6 deletions website/components/clip-strip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { t, rich } from "@/lib/i18n";
import { ArrowRight } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { DEMO_RUN, clipPoster, clipVideo } from "@/content/demo";
import { LoopVideo } from "./loop-video";
import { LoopVideo, MotionToggle } from "./loop-video";

const { source, picks } = DEMO_RUN;

Expand Down Expand Up @@ -42,11 +42,14 @@ export function ClipStrip() {
<img src="/clips/podcast-source.jpg" alt="" className="block h-full w-full object-cover" />
<span className="absolute right-2 bottom-2 rounded-md bg-black/70 px-1.5 py-0.5 font-mono text-xs text-white">{source.length}</span>
</div>
<figcaption className="text-xs leading-snug text-ink3">
{rich(msg`The whole <0/>, 16:9. <1/> came out of it.`, {
0: source.kind,
1: <span className="text-ink2">{t(msg`${plural({ clips: DEMO_RUN.clips }, { one: "# clip", other: "# clips" })}`)}</span>,
})}
<figcaption className="flex items-start justify-between gap-2 text-xs leading-snug text-ink3">
<span>
{rich(msg`The whole <0/>, 16:9. <1/> came out of it.`, {
0: source.kind,
1: <span className="text-ink2">{t(msg`${plural({ clips: DEMO_RUN.clips }, { one: "# clip", other: "# clips" })}`)}</span>,
})}
</span>
<MotionToggle />
</figcaption>
</figure>

Expand Down
3 changes: 2 additions & 1 deletion website/components/feature-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import editor from "@/public/editor.png";
import transcriptFixes from "@/public/transcript-fixes.png";
import workspace from "@/public/workspace.png";
import { CAPTIONS_FILE, REFRAMES, clipPoster, clipVideo } from "@/content/demo";
import { LoopVideo, useInView, useReducedMotion } from "./loop-video";
import { LoopVideo, MotionToggle, useInView, useReducedMotion } from "./loop-video";

const HASH = "see-";
const ADVANCE_MS = 9000;
Expand Down Expand Up @@ -263,6 +263,7 @@ export function FeatureTabs() {
</div>
))}
</div>
<MotionToggle className="self-end" />
</div>
</div>
);
Expand Down
39 changes: 21 additions & 18 deletions website/components/hero-reel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { rich, t as tr } from "@/lib/i18n";

import { useCallback, useState } from "react";
import { HERO, clipPoster, clipVideo, fmtTime } from "@/content/demo";
import { LoopVideo } from "./loop-video";
import { LoopVideo, MotionToggle } from "./loop-video";

/** How long the hook shows with default settings (hookSeconds). */
const HOOK_SECONDS = 3.5;
Expand Down Expand Up @@ -126,23 +126,26 @@ export function HeroReel() {
</p>
))}
</div>
<div className="flex gap-1.5" role="group" aria-label={tr(msg`Show a pick`)}>
{HERO.map(({ pick: p, source: src }, k) => (
<button
key={p.file}
type="button"
onClick={() => {
setI(k);
setHeld(true);
setT(0);
}}
aria-label={tr(msg`${{ kind: src.kind }}, pick #${{ rank: p.rank }}: ${{ hook: p.hook }}`)}
aria-pressed={k === i}
className="grid h-6 place-items-center px-0.5"
>
<span className={`block h-1.5 rounded-full transition-all ${k === i ? "w-6 bg-acc" : "w-1.5 bg-line2 hover:bg-ink3"}`} />
</button>
))}
<div className="flex items-center gap-3">
<div className="flex gap-1.5" role="group" aria-label={tr(msg`Show a pick`)}>
{HERO.map(({ pick: p, source: src }, k) => (
<button
key={p.file}
type="button"
onClick={() => {
setI(k);
setHeld(true);
setT(0);
}}
aria-label={tr(msg`${{ kind: src.kind }}, pick #${{ rank: p.rank }}: ${{ hook: p.hook }}`)}
aria-pressed={k === i}
className="grid h-6 place-items-center px-0.5"
>
<span className={`block h-1.5 rounded-full transition-all ${k === i ? "w-6 bg-acc" : "w-1.5 bg-line2 hover:bg-ink3"}`} />
</button>
))}
</div>
<MotionToggle />
</div>
</figcaption>
</figure>
Expand Down
Loading
Loading