From f5d2b417e68edfca5e0b9a1aa7d15c3d7b4cf1b9 Mon Sep 17 00:00:00 2001 From: Nathan Cummins Date: Thu, 15 Oct 2026 15:30:24 +1030 Subject: [PATCH] Make track cards, track links, and project filters keyboard-operable --- src/components/Token.astro | 7 +++++-- src/components/TrackCard.astro | 12 +++++++----- src/components/TrackInline.astro | 6 ++++-- src/pages/projects.astro | 12 +++++++++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/components/Token.astro b/src/components/Token.astro index d1d9c13..8a0475b 100644 --- a/src/components/Token.astro +++ b/src/components/Token.astro @@ -6,6 +6,7 @@ interface Props extends HTMLAttributes<"span"> { textColour?: String; size?: String; hover?: String; + as?: "span" | "button"; } const { @@ -14,11 +15,13 @@ const { size = "text-xs", hover = "hover:bg-white hover:text-primary hover:ring-primary hover:ring-2", class: className, + as: Tag = "span", ...attrs } = Astro.props as Props; --- - diff --git a/src/components/TrackCard.astro b/src/components/TrackCard.astro index dc0647c..22257e4 100644 --- a/src/components/TrackCard.astro +++ b/src/components/TrackCard.astro @@ -20,7 +20,9 @@ if (!track.data.card) { } --- -
-
{track.data.card.text.secondary}{track.data.card.text.primary} -
-
+ + diff --git a/src/components/TrackInline.astro b/src/components/TrackInline.astro index 4a1e58c..0d4a023 100644 --- a/src/components/TrackInline.astro +++ b/src/components/TrackInline.astro @@ -21,7 +21,9 @@ const fullFilePath = join(process.cwd(), "public", track.data.src); const duration = await getAudioDurationInSeconds(fullFilePath); --- -
{track.data.metadata.title} -
+ diff --git a/src/pages/projects.astro b/src/pages/projects.astro index e9454e3..a49a2da 100644 --- a/src/pages/projects.astro +++ b/src/pages/projects.astro @@ -23,12 +23,16 @@ const types = [...new Set(projects.map((project) => project.data.type))]; Recent Projects
All { types.map((type) => ( @@ -70,14 +74,15 @@ const types = [...new Set(projects.map((project) => project.data.type))]; const token = (e.target as Element).closest(".filter-token"); if (!token) return; - tokens.forEach((t) => + tokens.forEach((t) => { t.classList.remove( "bg-white", "!text-primary", "ring-primary", "ring-2" - ) - ); + ); + t.setAttribute("aria-pressed", "false"); + }); token.classList.add( "bg-white", @@ -85,6 +90,7 @@ const types = [...new Set(projects.map((project) => project.data.type))]; "ring-primary", "ring-2" ); + token.setAttribute("aria-pressed", "true"); const type = token.dataset.type;