Skip to content

Commit 2f56bce

Browse files
committed
fix(a11y): toggle state, valid markup, focus-visible actions + tsx highlight
- M9: add aria-pressed to framework toggle buttons and role=group/aria-label on the selection bar so screen readers announce selected state. - M11: remove the interactive <button> nested inside the contribute <a> (invalid HTML, two overlapping interactive roles for one action). - F15: demote the per-framework label from h3 to h4 so headings nest h2 (section) > h3 (snippet) > h4 (framework) instead of duplicate h3s. - F17: reveal the editor's edit/copy actions on group-focus-within, not just group-hover, so they're reachable by keyboard and touch. - F9: alias Ripple .tsrx to tsx (not jsx) in Shiki to keep TS typing.
1 parent d43fe47 commit 2f56bce

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

build/lib/highlighter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function getHighlighter(): Promise<HighlighterGeneric<BundledLanguage, Bun
3131
"angular-html",
3232
],
3333
langAlias: {
34-
tsrx: "jsx",
34+
tsrx: "tsx",
3535
},
3636
});
3737
}

src/Index.svelte

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@
244244
class="flex px-6 lg:px-20 py-2 sticky top-0 z-20 w-full backdrop-blur bg-gray-900/80 border-b border-gray-700 whitespace-nowrap overflow-x-auto"
245245
data-framework-id-selected-list={frameworkIdsSelectedArr.join(",")}
246246
data-testid="framework-selection-bar"
247+
role="group"
248+
aria-label="Select frameworks to compare"
247249
>
248250
{#each headerFrameworks as framework (framework.id)}
249251
{#if framework}
@@ -258,6 +260,7 @@
258260
: "opacity-70 border-opacity-50 border-gray-700",
259261
]}
260262
data-testid={`framework-button-${framework.id}`}
263+
aria-pressed={frameworkIdsSelected.has(framework.id)}
261264
onclick={() => {
262265
toggleFrameworkId(framework.id);
263266
if (frameworkIdsSelectedArr.length === 0) {
@@ -356,12 +359,12 @@
356359
data-testid={`framework-snippet-${frameworkId}-${snippet.snippetId}`}
357360
>
358361
<div class="flex justify-between items-center space-x-3">
359-
<h3
362+
<h4
360363
class="m-0"
361364
data-testid={`framework-title-${frameworkId}-${snippet.snippetId}`}
362365
>
363366
<FrameworkLabel id={framework.id} />
364-
</h3>
367+
</h4>
365368
{#if frameworkSnippet}
366369
<div class="flex items-center space-x-3">
367370
{#if frameworkSnippet.playgroundURL}
@@ -421,13 +424,11 @@
421424
href={frameworkSnippet.snippetEditHref}
422425
data-testid={`contribute-link-${frameworkId}-${snippet.snippetId}`}
423426
>
424-
<button class="flex items-center space-x-3">
425-
<span>Contribute on Github</span>
426-
<span
427-
class="iconify simple-icons--github size-5"
428-
aria-hidden="true"
429-
></span>
430-
</button>
427+
<span>Contribute on Github</span>
428+
<span
429+
class="iconify simple-icons--github size-5"
430+
aria-hidden="true"
431+
></span>
431432
</a>
432433
</div>
433434
</div>

src/components/CodeEditor.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
{@html snippet.contentHtml}
6060
{/if}
6161
</div>
62-
<div class="absolute hidden group-hover:block transition-all top-0 right-0 mt-2 mr-2">
62+
<div
63+
class="absolute hidden group-hover:block group-focus-within:block transition-all top-0 right-0 mt-2 mr-2"
64+
>
6365
<div class="flex items-center space-x-3">
6466
<a
6567
href={snippetEditHref}

0 commit comments

Comments
 (0)