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

General accessibility fixes #36

Merged
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
8 changes: 5 additions & 3 deletions lib/assets/javascripts/_modules/collapsible-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@
var $topLevelItem = $($topLevelItems[i]);
var $heading = $topLevelItem.find('> a');
var $listing = $topLevelItem.find('> ul');
var id = 'toc-' + $heading.text().toLowerCase().replace(' ', '-')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for semantics, could we add trailing ;? :D

Not a blocker.

// Only add collapsible functionality if there are children.
if ($listing.length == 0) {
continue;
}
$topLevelItem.addClass('collapsible');
$listing.addClass('collapsible__body')
.attr('id', id)
.attr('aria-expanded', 'false');
$heading.addClass('collapsible__heading')
.after('<button class="collapsible__toggle"><span class="collapsible__toggle-label">Expand ' + $heading.text() + '</span><span class="collapsible__toggle-icon" aria-hidden="true"></button>')
.after('<button class="collapsible__toggle" aria-controls="' + id +'"><span class="collapsible__toggle-label">Expand ' + $heading.text() + '</span><span class="collapsible__toggle-icon" aria-hidden="true"></button>')
$topLevelItem.on('click', '.collapsible__toggle', function(e) {
e.preventDefault();
var $parent = $(this).parent();
Expand All @@ -51,11 +53,11 @@
function toggleHeading($topLevelItem) {
var isOpen = $topLevelItem.hasClass('is-open');
var $heading = $topLevelItem.find('> a');
var $body = $topLevelItem.find('collapsible__body');
var $body = $topLevelItem.find('.collapsible__body');
var $toggleLabel = $topLevelItem.find('.collapsible__toggle-label');

$topLevelItem.toggleClass('is-open', !isOpen);
$body.attr('aria-expanded', isOpen ? 'true' : 'false');
$body.attr('aria-expanded', isOpen ? 'false' : 'true');
$toggleLabel.text(isOpen ? 'Expand ' + $heading.text() : 'Collapse ' + $heading.text());
}

Expand Down
17 changes: 12 additions & 5 deletions lib/assets/stylesheets/modules/_collapsible.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
display: block
}
}
.collapsible__heading,
.toc__list > ul > li > a:link.collapsible__heading {
margin-right: 30px;
}
.collapsible__toggle {
position: absolute;
top: 0;
Expand All @@ -34,12 +38,15 @@
&::after {
content: '';
display: block;
background: no-repeat file-url('arrow-down.svg') center center;
background-size: 18px auto;
width: 20px;
height: 40px;
border: 2px solid $black;
border-width: 2px 2px 0 0;
transform: rotate(135deg);
width: 10px;
height: 10px;
margin-top: 10px;
}
.collapsible.is-open &::after {
background-image: file-url('arrow-up.svg');
transform: rotate(315deg);
margin-top: 18px;
}
}
2 changes: 1 addition & 1 deletion lib/assets/stylesheets/modules/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

a:link, a:visited {
display: block;
padding: 8px 40px 8px $gutter-half;
padding: 8px $gutter 8px $gutter-half;
margin: 0 $gutter-half * -1;
border-left: 5px solid transparent;

Expand Down
9 changes: 0 additions & 9 deletions lib/source/images/arrow-down.svg

This file was deleted.

9 changes: 0 additions & 9 deletions lib/source/images/arrow-up.svg

This file was deleted.

2 changes: 1 addition & 1 deletion lib/source/layouts/_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<% end %>
<% if config[:tech_docs][:show_govuk_logo] %>
<span class="govuk-logo">
<img class="govuk-logo__printable-crown" src="/images/gov.uk_logotype_crown_invert_trans.png" height="32" width="36">
<img class="govuk-logo__printable-crown" src="/images/gov.uk_logotype_crown_invert_trans.png" height="32" width="36" alt="">
GOV.UK
</span>
<% end %>
Expand Down