Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge with card link accessibility #141

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
ariaHidden: 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
edwardscull marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{%- if params.count -%}
<span class="nhsapp-badge">
<p class="nhsapp-badge
{{ params.classes if params.classes }}"
{%- if params.ariaHidden %} aria-hidden="{{ params.ariaHidden }}"{% endif %}>
<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 -%}
4 changes: 3 additions & 1 deletion src/components/card/card-group.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

{% from "./macro.njk" import nhsappCard %}

<ol class="nhsapp-cards {{ stackedClass }}">
<ol class="nhsapp-cards {{ stackedClass }}
{{ params.classes if params.classes }}">
{% for cardItem in params.cards %}
{{ nhsappCard({
title: cardItem.title,
href: cardItem.href,
html: cardItem.html,
classes: cardItem.classes,
aboveContent: cardItem.aboveContent,
description: cardItem.description,
badgeLarge: cardItem.badgeLarge,
Expand Down
13 changes: 9 additions & 4 deletions src/components/card/card.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
{% set hasBadgeLarge = true if params.badgeLarge.count > 1 %}

{%- if params.isListItem -%}
<li class="nhsapp-card">
<li class="nhsapp-card
{{ params.classes if params.classes }}">
{%- else -%}
<div class="nhsapp-card">
<div class="nhsapp-card
{{ params.classes if params.classes }}">
{%- endif -%}
<div class="nhsapp-card__container">
{%- if params.prefixIcon -%}
Expand All @@ -18,7 +20,8 @@
{{ 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"
{%- if params.linkAriaLabel %} aria-label="{{ params.linkAriaLabel }}" {% endif %}>
{{ params.title }}
</a>
{% if params.description %}
Expand All @@ -32,7 +35,9 @@
{% if hasBadgeLarge %}
{{ nhsappBadgeLarge({
count: params.badgeLarge.count,
label: params.badgeLarge.label
label: params.badgeLarge.label,
classes: params.badgeLarge.classes,
ariaHidden: params.badgeLarge.ariaHidden
}) }}
{% endif %}
{{ nhsappIcon('chevronRight') }}
Expand Down
3 changes: 2 additions & 1 deletion src/components/timeline/timeline.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
</li>
{% endmacro %}

<ol class="nhsapp-timeline">
<ol class="nhsapp-timeline
{{ params.classes if params.classes }}">
{% for item in params.items %}
{% if item %}{{ _timelineItem(params, item) }}{% endif %}
{% endfor %}
Expand Down
3 changes: 2 additions & 1 deletion src/styles/section-heading/section-heading.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% set subheadingClass = 'nhsuk-u-margin-bottom-3' if params.subheadingText else '' %}

<div class="nhsapp-section-heading">
<div class="nhsapp-section-heading
{{ params.classes if params.classes }}">
<h2 class="nhsuk-heading-s {{ subheadingClass }}">
{{ params.headingText }}
</h2>
Expand Down