Skip to content

Commit

Permalink
resolves #47 add aria- attributes to mobile menu button; replace data…
Browse files Browse the repository at this point in the history
…-target with aria-controls (PR #133)
  • Loading branch information
mojavelinux authored Nov 7, 2023
1 parent 753f4d7 commit 5440bf1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/js/05-mobile-navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
function toggleNavbarMenu (e) {
e.stopPropagation() // trap event
var html = document.documentElement
var menu = document.getElementById(this.dataset.target)
var menu = document.getElementById(this.getAttribute('aria-controls') || this.dataset.target)
if (!menu.classList.contains('is-active') && /mobi/i.test(window.navigator.userAgent)) {
if (Math.round(parseFloat(window.getComputedStyle(html).minHeight)) !== window.innerHeight) {
html.style.setProperty('--vh', window.innerHeight / 100 + 'px')
Expand All @@ -17,7 +17,7 @@
}
}
html.classList.toggle('is-clipped--navbar')
this.classList.toggle('is-active')
navbarBurger.setAttribute('aria-expanded', this.classList.toggle('is-active'))
menu.classList.toggle('is-active')
}
})()
2 changes: 1 addition & 1 deletion src/partials/header-content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="navbar-brand">
<a class="navbar-item logo" title="Asciidoctor" href="https://asciidoctor.org"><img src="{{{uiRootPath}}}/img/asciidoctor-logo.svg" alt="Asciidoctor" width="48"></a>
<a class="navbar-item title" href="{{#with (and site.url site.homeUrl)}}{{{@root.site.url}}}{{{this}}}{{else}}{{{siteRootPath}}}{{/with}}">{{site.title}}</a>
<button class="navbar-burger" data-target="topbar-nav">
<button class="navbar-burger" aria-controls="topbar-nav" aria-expanded="false" aria-label="Toggle main menu">
<span></span>
<span></span>
<span></span>
Expand Down

0 comments on commit 5440bf1

Please sign in to comment.