Skip to content

Commit 42cffe6

Browse files
heyoubclaude
authored andcommitted
fix(web): repair heading levels and landmark structure
A screen reader's heading outline is a navigation aid, and three index screens broke it by jumping h1 -> h3: the card components render h3, which is correct where those cards sit under a section h2 (TagDetail, Home, Volunteer) but leaves a gap on the index screens. Rather than change a shared card and break it in its other homes, each index gains an sr-only h2 over its results region — the grid genuinely is a section. ProjectsIndex was checked and does not have the defect; ProjectCard already renders h2. The detail-screen aside headings go h3 -> h2 directly. They sit under the screen h1 with nothing between, are used nowhere else, and keep their classes so nothing moves: heading level and visual size are independent. PersonCard wrapped the entire card in one <a>, so its accessible name was the avatar title, the name, the project count and every tag chip concatenated into one string. Restructured to the ProjectCard idiom with a stretched pseudo-element so the whole card stays clickable. The header's navs rendered bare links; a nav without a list does not tell you how many destinations it has. Both are now ul/li matching AppFooter, with the mobile sheet's three groups as three lists so the separators and the About heading are not list children. That "About" label was a styled <p>; it is now an h3, one level under the SheetTitle that Radix renders as an h2. HelpWantedIndex wrapped FacetSidebar — which renders its own labelled aside — in a second bare <aside>, nesting two complementary landmarks with the outer one unnamed. The outer element is now a div. Result-count badges move out of the h1 on all three index screens: a heading whose accessible name changes on every keystroke is not a stable landmark. The two GitHub links in this file also pick up their new-tab cues here rather than splitting one file's edits across two commits. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0179758 commit 42cffe6

8 files changed

Lines changed: 191 additions & 97 deletions

File tree

‎apps/web/src/components/AppHeader.tsx‎

Lines changed: 105 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function GitHubLink() {
197197
href={GITHUB_URL}
198198
target="_blank"
199199
rel="noopener noreferrer"
200-
aria-label="Code for Philly on GitHub"
200+
aria-label="Code for Philly on GitHub (opens in new tab)"
201201
>
202202
<GitHubIcon />
203203
</a>
@@ -235,20 +235,33 @@ export function AppHeader() {
235235

236236
{/* Desktop content cluster. The parent gap is the only source of
237237
spacing between children — no per-child margins. */}
238+
{/* A nav is a list of destinations — the <ul>/<li> is what tells a
239+
screen reader how many there are and where you are in them. The
240+
flex/gap spacing moves to the <ul>; the <li>s contribute none. */}
238241
<nav
239242
aria-label="Primary navigation"
240-
className="hidden md:flex items-center gap-2 ml-4 flex-1"
243+
className="hidden md:block ml-4 flex-1"
241244
>
242-
<NavLink to="/projects" className={navLinkClass}>
243-
Projects
244-
</NavLink>
245-
<NavLink to="/help-wanted" className={navLinkClass}>
246-
Help Wanted
247-
</NavLink>
248-
<NavLink to="/members" className={navLinkClass}>
249-
Members
250-
</NavLink>
251-
<AboutDropdown />
245+
<ul className="flex items-center gap-2">
246+
<li>
247+
<NavLink to="/projects" className={navLinkClass}>
248+
Projects
249+
</NavLink>
250+
</li>
251+
<li>
252+
<NavLink to="/help-wanted" className={navLinkClass}>
253+
Help Wanted
254+
</NavLink>
255+
</li>
256+
<li>
257+
<NavLink to="/members" className={navLinkClass}>
258+
Members
259+
</NavLink>
260+
</li>
261+
<li>
262+
<AboutDropdown />
263+
</li>
264+
</ul>
252265
</nav>
253266

254267
{/* Desktop utility cluster: GitHub, search, auth, then the Volunteer
@@ -295,58 +308,93 @@ export function AppHeader() {
295308
</SheetHeader>
296309
{/* min-h-0 + overflow-y-auto so the list stays reachable on
297310
short viewports instead of overflowing the panel. */}
311+
{/* Three lists with the separators and the group heading
312+
between them, rather than one list interrupted by
313+
non-list children. The nav keeps the flex column so the
314+
gap-2 rhythm between groups is unchanged. */}
298315
<nav
299316
aria-label="Mobile navigation"
300317
className="flex flex-col gap-2 px-4 min-h-0 overflow-y-auto"
301318
>
302-
<NavLink to="/projects" className={navLinkClass}>
303-
Projects
304-
</NavLink>
305-
<NavLink to="/help-wanted" className={navLinkClass}>
306-
Help Wanted
307-
</NavLink>
308-
<NavLink to="/members" className={navLinkClass}>
309-
Members
310-
</NavLink>
319+
<ul className="flex flex-col gap-2">
320+
<li>
321+
<NavLink to="/projects" className={navLinkClass}>
322+
Projects
323+
</NavLink>
324+
</li>
325+
<li>
326+
<NavLink to="/help-wanted" className={navLinkClass}>
327+
Help Wanted
328+
</NavLink>
329+
</li>
330+
<li>
331+
<NavLink to="/members" className={navLinkClass}>
332+
Members
333+
</NavLink>
334+
</li>
335+
</ul>
311336
<Separator />
312-
<p className="text-xs text-muted-foreground font-medium uppercase tracking-wide">
337+
{/* SheetTitle ("Menu") renders a Radix DialogTitle, i.e. an
338+
h2 — so this group label is an h3, not a styled <p>. */}
339+
<h3 className="text-xs text-muted-foreground font-medium uppercase tracking-wide">
313340
About
314-
</p>
315-
<NavLink to="/pages/mission" className={navLinkClass}>
316-
Mission
317-
</NavLink>
318-
<NavLink to="/pages/leadership" className={navLinkClass}>
319-
Leadership
320-
</NavLink>
321-
<NavLink to="/pages/code-of-conduct" className={navLinkClass}>
322-
Code of Conduct
323-
</NavLink>
324-
<NavLink to="/pages/hackathons" className={navLinkClass}>
325-
Hackathons
326-
</NavLink>
327-
<NavLink to="/sponsor" className={navLinkClass}>
328-
Sponsor
329-
</NavLink>
330-
<a
331-
href="mailto:hello@codeforphilly.org"
332-
className="text-sm font-medium text-muted-foreground hover:text-primary"
333-
onClick={() => setMobileOpen(false)}
334-
>
335-
Contact
336-
</a>
341+
</h3>
342+
<ul className="flex flex-col gap-2">
343+
<li>
344+
<NavLink to="/pages/mission" className={navLinkClass}>
345+
Mission
346+
</NavLink>
347+
</li>
348+
<li>
349+
<NavLink to="/pages/leadership" className={navLinkClass}>
350+
Leadership
351+
</NavLink>
352+
</li>
353+
<li>
354+
<NavLink to="/pages/code-of-conduct" className={navLinkClass}>
355+
Code of Conduct
356+
</NavLink>
357+
</li>
358+
<li>
359+
<NavLink to="/pages/hackathons" className={navLinkClass}>
360+
Hackathons
361+
</NavLink>
362+
</li>
363+
<li>
364+
<NavLink to="/sponsor" className={navLinkClass}>
365+
Sponsor
366+
</NavLink>
367+
</li>
368+
<li>
369+
<a
370+
href="mailto:hello@codeforphilly.org"
371+
className="text-sm font-medium text-muted-foreground hover:text-primary"
372+
onClick={() => setMobileOpen(false)}
373+
>
374+
Contact
375+
</a>
376+
</li>
377+
</ul>
337378
<Separator />
338-
<a
339-
href={GITHUB_URL}
340-
target="_blank"
341-
rel="noopener noreferrer"
342-
className="text-sm font-medium text-muted-foreground hover:text-primary"
343-
onClick={() => setMobileOpen(false)}
344-
>
345-
GitHub
346-
</a>
347-
<NavLink to="/volunteer" className={navLinkClass}>
348-
Volunteer
349-
</NavLink>
379+
<ul className="flex flex-col gap-2">
380+
<li>
381+
<a
382+
href={GITHUB_URL}
383+
target="_blank"
384+
rel="noopener noreferrer"
385+
className="text-sm font-medium text-muted-foreground hover:text-primary"
386+
onClick={() => setMobileOpen(false)}
387+
>
388+
GitHub
389+
<span className="sr-only"> (opens in new tab)</span>
390+
</a>
391+
</li>
392+
<li>
393+
<NavLink to="/volunteer" className={navLinkClass}>
394+
Volunteer
395+
</NavLink>
396+
</li>
397+
</ul>
350398
</nav>
351399
<Separator />
352400
<div className="px-4 pb-4">

‎apps/web/src/components/PersonCard.tsx‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@ interface PersonCardProps {
99

1010
export function PersonCard({ person }: PersonCardProps) {
1111
return (
12-
<Link
13-
to={`/members/${person.slug}`}
14-
className="block rounded-lg border border-border bg-card p-4 hover:shadow-md hover:-translate-y-0.5 transition-all"
15-
>
12+
// The whole card used to be one <a>, so its accessible name was the
13+
// avatar's title plus the name plus the project count plus every tag
14+
// chip, read as one run-on string. Follow the ProjectCard idiom instead:
15+
// an <article> whose heading wraps the only link, named by the person.
16+
// A stretched pseudo-element keeps the entire card clickable — safe here
17+
// because the avatar and chips are deliberately non-interactive.
18+
<article className="relative rounded-lg border border-border bg-card p-4 hover:shadow-md hover:-translate-y-0.5 transition-all">
1619
<div className="flex flex-col items-center text-center">
1720
<PersonAvatar person={{ slug: person.slug, fullName: person.fullName, avatarUrl: person.avatarUrl }} size={80} asLink={false} className="rounded-lg" />
18-
<h3 className="mt-3 font-semibold text-foreground">{person.fullName}</h3>
21+
<h3 className="mt-3 font-semibold text-foreground">
22+
<Link
23+
to={`/members/${person.slug}`}
24+
className="after:absolute after:inset-0 after:rounded-lg hover:text-primary transition-colors"
25+
>
26+
{person.fullName}
27+
</Link>
28+
</h3>
1929
{person.memberOfCount > 0 && (
2030
<p className="text-xs text-muted-foreground mt-0.5">
2131
Member of {person.memberOfCount} project{person.memberOfCount === 1 ? '' : 's'}
@@ -29,6 +39,6 @@ export function PersonCard({ person }: PersonCardProps) {
2939
</div>
3040
)}
3141
</div>
32-
</Link>
42+
</article>
3343
);
3444
}

‎apps/web/src/screens/HelpWantedIndex.tsx‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ export function HelpWantedIndex() {
9090
<div className="container mx-auto px-4 py-8">
9191
<header className="mb-6 flex items-start justify-between gap-3">
9292
<div>
93-
<h1 className="text-3xl font-bold flex items-center gap-3">
94-
Help Wanted
93+
{/* The count is a sibling of the h1, not part of it: an accessible
94+
name that mutates on every filter change is a moving target. */}
95+
<div className="flex items-center gap-3">
96+
<h1 className="text-3xl font-bold">Help Wanted</h1>
9597
<span className="inline-flex items-center rounded-full bg-muted text-muted-foreground px-2.5 py-0.5 text-sm">
9698
{totalItems}
9799
</span>
98-
</h1>
100+
</div>
99101
<p className="text-muted-foreground mt-2 max-w-3xl">
100102
Concrete, time-boxed ways to contribute to Code for Philly projects.
101103
</p>
@@ -107,7 +109,10 @@ export function HelpWantedIndex() {
107109
<PostRolePickerModal open={pickerOpen} onOpenChange={setPickerOpen} />
108110

109111
<div className="grid grid-cols-1 md:grid-cols-[16rem_1fr] gap-6">
110-
<aside>
112+
{/* A plain div, not an <aside>: FacetSidebar renders its own labelled
113+
<aside>, and wrapping it in another one nests two `complementary`
114+
landmarks — the outer one unlabelled. */}
115+
<div>
111116
<FacetSidebar
112117
facets={facets}
113118
activeTags={tags}
@@ -116,9 +121,9 @@ export function HelpWantedIndex() {
116121
/>
117122

118123
<div className="mt-6">
119-
<h3 className="text-xs font-semibold uppercase tracking-wide mb-2 text-muted-foreground">
124+
<h2 className="text-xs font-semibold uppercase tracking-wide mb-2 text-muted-foreground">
120125
Commitment
121-
</h3>
126+
</h2>
122127
<fieldset className="flex flex-col gap-1">
123128
<legend className="sr-only">Maximum commitment hours per week</legend>
124129
{COMMITMENT_OPTIONS.map((o) => (
@@ -146,9 +151,13 @@ export function HelpWantedIndex() {
146151
))}
147152
</fieldset>
148153
</div>
149-
</aside>
154+
</div>
150155

151156
<div>
157+
{/* HelpWantedCard renders an h3 (it also sits under section h2s on
158+
Home, TagDetail and Volunteer), so the results list needs its own
159+
h2 or the page skips h1 → h3. Visually redundant, hence sr-only. */}
160+
<h2 className="sr-only">Results</h2>
152161
<div className="flex items-center gap-2 flex-wrap text-sm mb-4">
153162
{hasActiveFilters && (
154163
<>

‎apps/web/src/screens/PeopleIndex.tsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ export function PeopleIndex() {
103103
return (
104104
<div className="container mx-auto px-4 py-8">
105105
<div className="flex items-center justify-between gap-4 mb-4">
106-
<h1 className="text-3xl font-bold flex items-center gap-3">
107-
Members
106+
{/* The count is a sibling of the h1, not part of it: an accessible
107+
name that mutates on every filter change is a moving target. */}
108+
<div className="flex items-center gap-3">
109+
<h1 className="text-3xl font-bold">Members</h1>
108110
<span className="inline-flex items-center rounded-full bg-muted text-muted-foreground px-2.5 py-0.5 text-sm">
109111
{totalItems}
110112
</span>
111-
</h1>
113+
</div>
112114
</div>
113115

114116
<Input
@@ -129,6 +131,10 @@ export function PeopleIndex() {
129131
/>
130132

131133
<div>
134+
{/* PersonCard renders an h3 (it also sits under section h2s on
135+
TagDetail), so the results grid needs its own h2 or the page
136+
skips h1 → h3. Visually redundant, hence sr-only. */}
137+
<h2 className="sr-only">Results</h2>
132138
<div className="flex items-center justify-between flex-wrap gap-3 mb-4">
133139
<div className="flex items-center gap-2 flex-wrap text-sm">
134140
{hasActiveFilters && (

‎apps/web/src/screens/PersonDetail.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ export function PersonDetail() {
219219
<aside className="space-y-4 text-sm">
220220
{(person.slackHandle || person.email) && (
221221
<section>
222-
<h3 className="text-sm font-semibold mb-2 text-muted-foreground uppercase tracking-wide">
222+
<h2 className="text-sm font-semibold mb-2 text-muted-foreground uppercase tracking-wide">
223223
Contact
224-
</h3>
224+
</h2>
225225
<ul className="space-y-1">
226226
{person.slackHandle && (
227227
<li>
@@ -249,9 +249,9 @@ export function PersonDetail() {
249249
</section>
250250
)}
251251
<section>
252-
<h3 className="text-sm font-semibold mb-2 text-muted-foreground uppercase tracking-wide">
252+
<h2 className="text-sm font-semibold mb-2 text-muted-foreground uppercase tracking-wide">
253253
Member since
254-
</h3>
254+
</h2>
255255
<p>{formatMonthYear(person.createdAt)}</p>
256256
</section>
257257
{isSelf && (

‎apps/web/src/screens/ProjectDetail.tsx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ export function ProjectDetail({ anchor }: ProjectDetailProps = {}) {
436436

437437
{/* Project info */}
438438
<section>
439-
<h3 className="text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide">
439+
<h2 className="text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide">
440440
Project Info
441-
</h3>
441+
</h2>
442442
<div className="flex flex-col gap-2">
443443
{project.links.usersUrl && (
444444
<Button asChild>
@@ -468,9 +468,9 @@ export function ProjectDetail({ anchor }: ProjectDetailProps = {}) {
468468
{project.memberships.length > 0 && (
469469
<section>
470470
<div className="flex items-center justify-between mb-3">
471-
<h3 className="text-sm font-semibold text-muted-foreground uppercase tracking-wide">
471+
<h2 className="text-sm font-semibold text-muted-foreground uppercase tracking-wide">
472472
Members ({project.counts.members})
473-
</h3>
473+
</h2>
474474
{perms.canManageMembers && (
475475
<Button
476476
size="sm"
@@ -499,9 +499,9 @@ export function ProjectDetail({ anchor }: ProjectDetailProps = {}) {
499499
{/* Tags */}
500500
{allTags.length > 0 && (
501501
<section>
502-
<h3 className="text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide">
502+
<h2 className="text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide">
503503
Tags
504-
</h3>
504+
</h2>
505505
<div className="space-y-2">
506506
{project.tags.tech.length > 0 && (
507507
<div>
@@ -539,9 +539,9 @@ export function ProjectDetail({ anchor }: ProjectDetailProps = {}) {
539539

540540
{/* Share */}
541541
<section>
542-
<h3 className="text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide">
542+
<h2 className="text-sm font-semibold mb-3 text-muted-foreground uppercase tracking-wide">
543543
Share
544-
</h3>
544+
</h2>
545545
<div className="flex flex-col gap-2">
546546
<Button
547547
variant="outline"

0 commit comments

Comments
 (0)