Skip to content

Commit

Permalink
Add aria sort labelling to column
Browse files Browse the repository at this point in the history
In order to improve the dashboard for screen reader users we add aria
labelling to the columns
  • Loading branch information
rich authored and richpjames committed Sep 17, 2024
1 parent 248ddfc commit 5b7baa8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions macros.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@
{%endset%}



{% set sortingOnThisParam = id === sortBy %}
{% set linkParams = "?sortBy=" + id + "&sortDirection=asc" %}
{%set ariaSort = "none"%}

{%if sortingOnThisParam and sortDirection === "asc"%}
{% set linkParams = "?sortBy=" + id + "&sortDirection=desc" %}
{%set ariaSort = "ascending"%}
{%endif%}

{%if sortingOnThisParam and sortDirection === "desc"%}
{% set linkParams = "?sortBy=" + id + "&sortDirection=asc" %}
{%set ariaSort = "descending"%}
{%endif%}

<th class="py-2 pl-2" scope="col"><a href="/{{linkParams}}"> {{name}}


<th class="py-2 pl-2" scope="col" aria-sort="{{ariaSort}}"><a href="/{{linkParams}}"> {{name}}

<span class="text-xs ml-1">
{% if sortDirection === "asc" and sortingOnThisParam %}
Expand Down

0 comments on commit 5b7baa8

Please sign in to comment.