From 3de35fd75bfc7973a6de8c806a0b2af05ca656c1 Mon Sep 17 00:00:00 2001 From: Anthony Torres Date: Fri, 29 May 2026 09:10:59 -0600 Subject: [PATCH] fix: improve APY dashboard accessibility --- .../src/components/dashboard/ApyDashboard.tsx | 154 ++++++++++++++---- .../dashboard/__tests__/ApyDashboard.test.tsx | 49 ++++++ 2 files changed, 174 insertions(+), 29 deletions(-) diff --git a/client/src/components/dashboard/ApyDashboard.tsx b/client/src/components/dashboard/ApyDashboard.tsx index 0bba569e6..cf26b3501 100644 --- a/client/src/components/dashboard/ApyDashboard.tsx +++ b/client/src/components/dashboard/ApyDashboard.tsx @@ -63,6 +63,13 @@ type SortField = "apy" | "tvl" | "risk" | "protocol"; type SortDirection = "asc" | "desc"; type ViewMode = "grid" | "table"; +const SORT_LABELS: Record = { + apy: "APY", + tvl: "TVL", + risk: "risk", + protocol: "protocol", +}; + interface ApiApyEntry { protocol?: unknown; asset?: unknown; @@ -165,6 +172,27 @@ function getErrorMessage(error: unknown): string { return "Unable to fetch live APY data right now"; } +function getSortButtonLabel( + field: SortField, + activeField: SortField, + direction: SortDirection, +): string { + const label = SORT_LABELS[field]; + if (field !== activeField) return `Sort by ${label}`; + return `Sort by ${label}, currently ${ + direction === "asc" ? "ascending" : "descending" + }`; +} + +function getAriaSort( + field: SortField, + activeField: SortField, + direction: SortDirection, +): "ascending" | "descending" | "none" { + if (field !== activeField) return "none"; + return direction === "asc" ? "ascending" : "descending"; +} + // ── Skeleton Components ───────────────────────────────────────────────── function SkeletonCard() { @@ -352,6 +380,7 @@ export default function ApyDashboard() { const SortIcon = ({ field }: { field: SortField }) => (