Skip to content

Commit

Permalink
badge with card link accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardScull committed Sep 4, 2024
1 parent 9243b1b commit b31553d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/examples/cards/card-link-with-badge.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ vueLink: "https://nhsappvuecomponentlibraryv1.nonlive.nhsapp.service.nhs.uk/?pat
title: 'Messages',
href: '#',
prefixIcon: 'messages',
linkAriaLabel: 'Messages, you have 4 unread messages',
badgeLarge: {
count: 4,
label: 'unread messages'
label: 'unread messages',
withCardLink: true
}
}) }}
1 change: 1 addition & 0 deletions src/components/badge/_badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
color: $color_nhsuk-white;
font-weight: bold;
padding: 0 nhsuk-spacing(2);
margin: 0;

@include mq($from: tablet) {
padding: 0 12px;
Expand Down
6 changes: 4 additions & 2 deletions src/components/badge/large/badge-large.njk
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% set cardLink = 'true' if params.withCardLink else 'null' %}

{%- if params.count -%}
<span class="nhsapp-badge">
<p class="nhsapp-badge" aria-hidden="{{ true if params.withCardLink }}">
<span class="nhsuk-u-visually-hidden">You have</span>
{% if params.count > 9 %}
9+
{% else %}
{{ params.count }}
{% endif %}
<span class="nhsuk-u-visually-hidden">{{ params.label }}</span>
</span>
</p>
{%- endif -%}
2 changes: 1 addition & 1 deletion src/components/card/card.njk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{ params.aboveContent.html | safe }}
</div>
{%- endif -%}
<a href="{{ params.href }}" class="nhsapp-card__link nhsuk-link--no-visited-state">
<a href="{{ params.href }}" class="nhsapp-card__link nhsuk-link--no-visited-state" aria-label="{{ params.linkAriaLabel }}">
{{ params.title }}
</a>
{% if params.description %}
Expand Down

0 comments on commit b31553d

Please sign in to comment.