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

Announce whitespace in screen reader announcements of visually hidden text #960

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions app/pages/examples.njk
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@

<h2>Styles</h2>
<ul class="nhsuk-list">
<li><a href="../styles/typography.html">Typography</a></li>
<li><a href="../styles/lists.html">Lists</a></li>
</ul>
{% endblock %}
Expand Down
83 changes: 83 additions & 0 deletions app/styles/typography.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{% set title = 'Typography' %}

{% extends 'page.njk' %}

{% block header %}
{{ super() }}
{% endblock %}

{% block breadcrumb %}
{{ breadcrumb({
items: [
{
href: "../../",
text: "NHS.UK frontend"
},
{
href: "../pages/examples.html",
text: "Examples"
}
]
}) }}
{% endblock %}

{% block content %}

<h1 class="nhsuk-heading-xl">Typography</h1>


<h2 class="nhsuk-heading-l">Visually-hidden text</h2>

<h3 class="nhsuk-heading-m">Heading with visually hidden text at the beginning</h3>

<h4 class="nhsuk-heading-s"><span class="nhsuk-u-visually-hidden">Countries starting with </span>A</h4>

<h3 class="nhsuk-heading-m">Heading with visually hidden text at the end</h3>

<h4 class="nhsuk-heading-s">Search <span class="nhsuk-u-visually-hidden">all content</span></h4>

<h3 class="nhsuk-heading-m">Heading that is visually hidden</h3>

<h4 class="nhsuk-u-visually-hidden">Navigation menu</h4>

<hr class="nhsuk-section-break nhsuk-section-break--visible nhsuk-section-break--xl">

<h3 class="nhsuk-heading-m">Paragraph that contains visually hidden text</h3>

<p class="nhsuk-body">This is a paragraph <span class="nhsuk-u-visually-hidden">with some visually hidden text</span>.</p>

<hr class="nhsuk-section-break nhsuk-section-break--visible nhsuk-section-break--xl">

<h3 class="nhsuk-heading-m">Table with visually hidden text</h3>

<table class="nhsuk-table">
<caption class="nhsuk-table__caption nhsuk-!-margin-bottom-4">2019</caption>
<thead role="rowgroup" class="nhsuk-table__head">
<tr role="row">
<th role="columnheader" class="nhsuk-u-visually-hidden" scope="col">
Date
</th>
<th role="columnheader" class="nhsuk-u-visually-hidden" scope="col">
Day
</th>
<th role="columnheader" class="nhsuk-u-visually-hidden" scope="col">
Name
</th>
</tr>
</thead>
<tbody class="nhsuk-table__body">
<tr role="row" class="nhsuk-table__row">
<td class="nhsuk-table__cell">19 April</td>
<td class="nhsuk-table__cell ">Friday</td>
<td class="nhsuk-table__cell ">Good Friday</td>
</tr>
<tr role="row" class="nhsuk-table__row">
<td class="nhsuk-table__cell">22 April</td>
<td class="nhsuk-table__cell ">Monday</td>
<td class="nhsuk-table__cell ">Easter Monday</td>
</tr>
</tbody>
</table>


{% endblock %}
12 changes: 12 additions & 0 deletions packages/core/tools/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
//

@mixin visually-hidden() {
// Absolute positioning has the unintended consequence of removing any
// whitespace surrounding visually hidden text from the accessibility tree.
// Insert a space character before and after visually hidden text to separate
// it from any visible text surrounding it.
frankieroberto marked this conversation as resolved.
Show resolved Hide resolved
&::before {
content: "\00a0";
}

&::after {
content: "\00a0";
}

border: 0;
clip: rect(0 0 0 0);
-webkit-clip-path: inset(50%);
Expand Down
Loading