-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from maniflames/282-a11y-navigation-fixes
Merge navigation open and close triggers
- Loading branch information
Showing
3 changed files
with
23 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
document.getElementById('load-on-javascript').removeAttribute('hidden'); | ||
|
||
|
||
if (!document.getElementById('load-on-javascript').hasAttribute('hidden')) { | ||
const openToggle = document.getElementById('navigation-open'); | ||
const closeToggle = document.getElementById('navigation-close'); | ||
|
||
const navToggle = document.getElementById('navigation-toggle'); | ||
|
||
function handleInteraction() { | ||
if (document.body.classList.contains('navigation-opened')) { | ||
const isExpanded = navToggle.getAttribute('aria-expanded') === 'true'; | ||
|
||
if (isExpanded) { | ||
navToggle.setAttribute('aria-expanded', 'false'); | ||
document.body.classList.remove('navigation-opened'); | ||
document.body.classList.add('navigation-closed'); | ||
} else { | ||
document.body.classList.add('navigation-opened'); | ||
navToggle.setAttribute('aria-expanded', 'true'); | ||
document.body.classList.remove('navigation-closed'); | ||
document.body.classList.add('navigation-opened'); | ||
} | ||
} | ||
|
||
openToggle.addEventListener('click', handleInteraction); | ||
closeToggle.addEventListener('click', handleInteraction); | ||
navToggle.addEventListener('click', handleInteraction); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters