Skip to content

Commit

Permalink
Merge pull request #44 from dxw/add-aria-labels-to-sorted-columns
Browse files Browse the repository at this point in the history
Add aria sort labelling to column
  • Loading branch information
richpjames authored Sep 17, 2024
2 parents 248ddfc + 5b7baa8 commit 86da319
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 86da319

Please sign in to comment.