Skip to content

Commit 2b7d325

Browse files
committed
fix(gallery): improve accessibility of landing and cards
Expose screenshot descriptions to screen readers via a visually-hidden span, since the thumbnail alt sat inside an aria-hidden link and was dropped from the accessibility tree. Set the decorative thumbnail image alt to empty. Emit a single h1 on the landing by demoting the hero to h2, and stop category names being announced twice by rendering the chooser titles as spans instead of headings. Darken the image-less card gradient so white text meets WCAG AA contrast, and add an opens-in-new-window cue to external card links.
1 parent 1e4e755 commit 2b7d325

5 files changed

Lines changed: 16 additions & 14 deletions

File tree

‎docs/gallery/assets/_card.ejs.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
<li class="gal-card<%= item.slug ? ' cat-' + item.slug : '' %>" <%= metadataAttrs(item) %>>
66
<% if (item.image) { %>
77
<a href="<%- cardHref %>" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-hidden="true">
8-
<img class="thumb-img" src="<%- item.image %>" alt="<%= item.alt || (item.name + ' screenshot') %>"/>
8+
<img class="thumb-img" src="<%- item.image %>" alt=""/>
99
</a>
1010
<% } else { %>
1111
<div class="thumb" aria-hidden="true"><%= item.name || item.title %></div>
1212
<% } %>
1313
<div class="body">
14-
<p class="job"><a class="listing-title" href="<%- cardHref %>" target="_blank" rel="noopener noreferrer"><%= item.title %></a></p>
14+
<p class="job"><a class="listing-title" href="<%- cardHref %>" target="_blank" rel="noopener noreferrer" aria-label="<%= item.title %>, opens in new window"><%= item.title %></a></p>
15+
<% if (item.alt) { %><span class="visually-hidden">Screenshot: <%= item.alt %></span><% } %>
1516
<p class="who"><span class="listing-name"><%= item.name %></span><% if (item.author) { %> by <span class="listing-author"><%= item.author %></span><% } %></p>
1617
<% if (item.categories && item.categories.length) { %>
1718
<div class="gal-cats listing-categories">
@@ -25,8 +26,8 @@
2526
<% } %>
2627
<% if (item.description) { %><p class="why listing-description"><%= item.description %></p><% } %>
2728
<div class="foot">
28-
<% if (item.live) { %><a href="<%- item.live %>" target="_blank" rel="noopener noreferrer" aria-label="Live demo of <%= item.name || item.title %>">Live &#8599;</a><% } %>
29-
<% if (item.code) { %><a href="<%- item.code %>" target="_blank" rel="noopener noreferrer" aria-label="Source for <%= item.name || item.title %>">&lt;/&gt; Source</a><% } %>
29+
<% if (item.live) { %><a href="<%- item.live %>" target="_blank" rel="noopener noreferrer" aria-label="Live demo of <%= item.name || item.title %>, opens in new window">Live &#8599;</a><% } %>
30+
<% if (item.code) { %><a href="<%- item.code %>" target="_blank" rel="noopener noreferrer" aria-label="Source for <%= item.name || item.title %>, opens in new window">&lt;/&gt; Source</a><% } %>
3031
</div>
3132
</div>
3233
</li>

‎docs/gallery/assets/_chooser.ejs.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<span class="row">
77
<span class="ic" aria-hidden="true"><% if (item.icon) { %><i class="bi bi-<%- item.icon %>"></i><% } %></span>
88
</span>
9-
<h2 class="no-anchor"><%= item.category %></h2>
9+
<span class="gal-choice-title"><%= item.category %></span>
1010
<p><%= item.tagline %></p>
1111
</a>
1212
</li>

‎docs/gallery/assets/_featured.ejs.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
<% for (const item of featured) { %>
3333
<li class="gal-card">
3434
<% if (item.preview) { %>
35-
<a href="<%- item.live || '#' %>" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-hidden="true" class="thumb-stack"><img class="thumb-img" src="<%- item.image %>" alt="<%= item.alt || (item.name + ' screenshot') %>"/><video class="thumb-img gal-preview" muted loop playsinline preload="none" tabindex="-1" aria-hidden="true"><source src="<%- item.preview %>.webm" type="video/webm"><source src="<%- item.preview %>.mp4" type="video/mp4"></video></a>
35+
<a href="<%- item.live || '#' %>" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-hidden="true" class="thumb-stack"><img class="thumb-img" src="<%- item.image %>" alt=""/><video class="thumb-img gal-preview" muted loop playsinline preload="none" tabindex="-1" aria-hidden="true"><source src="<%- item.preview %>.webm" type="video/webm"><source src="<%- item.preview %>.mp4" type="video/mp4"></video></a>
3636
<% } else if (item.image) { %>
37-
<a href="<%- item.live || '#' %>" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-hidden="true"><img class="thumb-img" src="<%- item.image %>" alt="<%= item.alt || (item.name + ' screenshot') %>"/></a>
37+
<a href="<%- item.live || '#' %>" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-hidden="true"><img class="thumb-img" src="<%- item.image %>" alt=""/></a>
3838
<% } else { %>
3939
<div class="thumb" aria-hidden="true"><%= item.name || item.title %></div>
4040
<% } %>
4141
<div class="body">
42-
<p class="job"><a href="<%- item.live || '#' %>" target="_blank" rel="noopener noreferrer"><%= item.title %></a></p>
42+
<p class="job"><a href="<%- item.live || '#' %>" target="_blank" rel="noopener noreferrer" aria-label="<%= item.title %>, opens in new window"><%= item.title %></a></p>
43+
<% if (item.alt) { %><span class="visually-hidden">Screenshot: <%= item.alt %></span><% } %>
4344
<% if (item.author) { %><p class="who">by <%= item.author %></p><% } %>
4445
<% if ((item.categories && item.categories.length) || (item.features && item.features.length)) { %>
4546
<div class="feats">
@@ -49,8 +50,8 @@
4950
<% } %>
5051
<% if (item.description) { %><p class="why"><%= item.description %></p><% } %>
5152
<div class="foot">
52-
<% if (item.live) { %><a href="<%- item.live %>" target="_blank" rel="noopener noreferrer" aria-label="Live demo of <%= item.name || item.title %>">Live &#8599;</a><% } %>
53-
<% if (item.code) { %><a href="<%- item.code %>" target="_blank" rel="noopener noreferrer" aria-label="Source for <%= item.name || item.title %>">&lt;/&gt; Source</a><% } %>
53+
<% if (item.live) { %><a href="<%- item.live %>" target="_blank" rel="noopener noreferrer" aria-label="Live demo of <%= item.name || item.title %>, opens in new window">Live &#8599;</a><% } %>
54+
<% if (item.code) { %><a href="<%- item.code %>" target="_blank" rel="noopener noreferrer" aria-label="Source for <%= item.name || item.title %>, opens in new window">&lt;/&gt; Source</a><% } %>
5455
</div>
5556
</div>
5657
</li>

‎docs/gallery/assets/_gallery.scss‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ header#title-block-header:empty { display: none; }
7070

7171
// ---------------------------------------------------------------- hero chooser
7272
.gal-hero { padding: 0.5rem 0 0.4rem; }
73-
.gal-hero h1 { font-size: 2.25rem; line-height: 1.1; margin: 0.4rem 0 0.3rem; font-weight: 800; }
73+
.gal-hero h2 { font-size: 2.25rem; line-height: 1.1; margin: 0.4rem 0 0.3rem; font-weight: 800; }
7474
.gal-hero .lede { color: var(--gal-muted); font-size: 1rem; margin: 0 0 1.4rem; }
7575

7676
.gal-chooser {
@@ -92,7 +92,7 @@ header#title-block-header:empty { display: none; }
9292
.gal-choice:focus-visible { outline: 3px solid var(--gal-ring); outline-offset: 2px; }
9393
.gal-choice .row { display: flex; align-items: center; justify-content: space-between; }
9494
.gal-choice .ic { font-size: 1.2rem; }
95-
.gal-choice h2 { margin: 0.55rem 0 0.2rem; font-size: 1rem; }
95+
.gal-choice .gal-choice-title { display: block; margin: 0.55rem 0 0.2rem; font-size: 1rem; font-weight: 700; }
9696
.gal-choice p { margin: 0; font-size: 0.8rem; color: var(--gal-muted); line-height: 1.35; }
9797

9898
// --------------------------------------------------------- floating jump rail
@@ -252,7 +252,7 @@ $gal-rail-bp: 991.98px;
252252

253253
.gal-card { border: 1px solid var(--gal-line); border-radius: 12px; overflow: hidden; background: var(--gal-panel); display: flex; flex-direction: column; }
254254
.gal-card:focus-within { outline: 3px solid var(--gal-ring); outline-offset: 2px; }
255-
.gal-card .thumb { height: 172px; display: flex; align-items: flex-end; padding: 0.6rem 0.75rem; color: #fff; font-size: 0.74rem; font-weight: 600; background: linear-gradient(135deg, var(--c, var(--gal-accent)), color-mix(in srgb, var(--c, var(--gal-accent)) 68%, #000)); }
255+
.gal-card .thumb { height: 172px; display: flex; align-items: flex-end; padding: 0.6rem 0.75rem; color: #fff; font-size: 0.74rem; font-weight: 600; background: linear-gradient(135deg, color-mix(in srgb, var(--c, var(--gal-accent)) 55%, #000), color-mix(in srgb, var(--c, var(--gal-accent)) 32%, #000)); }
256256
// `contain` shows the whole screenshot; the letterbox blanks take the card's
257257
// category colour (the same accent used for image-less card headers), falling back
258258
// to the neutral surface where a card is not scoped to one category (browse grid).

‎docs/gallery/index.qmd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ aliases:
2424
---
2525

2626
::: {.gal-hero}
27-
# What do you want to make?
27+
## What do you want to make? {.no-anchor}
2828

2929
::: {.lede}
3030
Ready to make something with Quarto? If you already know the kind of content you want, choose a category below and browse its examples.

0 commit comments

Comments
 (0)