Skip to content

Commit 1f4009c

Browse files
committed
Revise header icon button a11y, hide mmenu. (#43)
* Put icons into spans with aria-hidden="true" so screen readers won't read them. * Provide tooltips via title attribute. * Use sr-only spans for text labels. * Hide mmenu when not open so it doesn't peek behind main content.
1 parent c91d9c1 commit 1f4009c

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

asset/css/style.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

asset/sass/_screen.scss

+25-9
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,8 @@ header nav a:visited {
378378
text-indent: -9999px;
379379
position: relative;
380380

381-
&:before {
381+
.icon:before {
382382
content: "\f002";
383-
font-family: "Font Awesome 5 Free";
384-
text-indent: 0;
385-
position: absolute;
386-
top: 0;
387-
right: 0;
388-
left: 0;
389-
bottom: 0;
390-
line-height: 1.5 * $base-line-height;
391383
}
392384
}
393385

@@ -399,13 +391,37 @@ header nav a:visited {
399391
height: 1.5 * $spacing-l;
400392
text-align: center;
401393
font-size: 18px;
394+
position: relative;
395+
396+
.icon:before {
397+
font-family: "Font Awesome 5 Free";
398+
text-indent: 0;
399+
position: absolute;
400+
top: 0;
401+
right: 0;
402+
left: 0;
403+
bottom: 0;
404+
line-height: 1.5 * $base-line-height;
405+
}
406+
}
407+
408+
#menu-button .icon:before {
409+
content: "\f0c9";
402410
}
403411

404412
#search-form button {
405413
border-width: 0px 0px 0px 1px;
406414
border-radius: 0;
407415
}
408416

417+
#menu {
418+
display: none;
419+
}
420+
421+
.mm-wrapper--opened #menu {
422+
display: block;
423+
}
424+
409425
.banner {
410426
display: flex;
411427
justify-content: center;

view/common/search-form.phtml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
$translate = $this->plugin('translate');
3+
$searchType = $this->siteSetting('search_type', 'sitewide');
4+
switch ($searchType) {
5+
case 'cross-site':
6+
$searchAction = $this->url('site/cross-site-search', ['action' => 'results'], true);
7+
break;
8+
case 'sitewide':
9+
default:
10+
$searchAction = $this->url('site/resource', ['controller' => 'index', 'action' => 'search'], true);
11+
}
12+
$searchValue = $this->escapeHtml($this->params()->fromQuery('fulltext_search', ''));
13+
?>
14+
15+
<form action="<?php echo $this->escapeHtml($searchAction); ?>" id="search-form">
16+
<input type="text" name="fulltext_search" value="<?php echo $searchValue; ?>"
17+
placeholder="<?php echo $translate('Search'); ?>"
18+
aria-label="<?php echo $translate('Search'); ?>">
19+
<button type="submit" title="<?php echo $translate('Search'); ?>"><span class="sr-only"><?php echo $translate('Search'); ?></span><span class="icon" aria-hidden="true"></span></button>
20+
</form>

view/layout/layout.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $this->htmlElement('body')->appendAttribute('class', 'body-truncate-' . $bodyTru
5959
</h1>
6060
<?php echo $this->partial('common/search-form'); ?>
6161
<div id="oc-trigger">
62-
<a href="#menu" role="button" id="menu-button" class="o-icon-menu button" data-effect="oc-push" aria-label="<?php echo $this->translate('Menu'); ?>"></a>
62+
<a href="#menu" role="button" id="menu-button" class="button" data-effect="oc-push" title="<?php echo $this->translate('Menu'); ?>"><span class="sr-only"><?php echo $this->translate('Menu'); ?></span><span class="icon" aria-hidden="true"></span></a>
6363
</div>
6464
<nav id="menu" class="oc-menu oc-push">
6565
<?php echo $site->publicNav()->menu()->renderMenu(); ?>

0 commit comments

Comments
 (0)