chore: cleanup

This commit is contained in:
Cory Dransfeldt 2024-06-27 14:04:17 -07:00
parent 46bcbc6617
commit 3d428bc99a
4 changed files with 2 additions and 52 deletions

View file

@ -1,27 +1,12 @@
window.addEventListener('load', () => {
const menuInput = document.getElementById('menu-toggle')
const menuLabelText = document.getElementById('menu-label-text')
const menuButtonContainer = document.querySelector('.menu-button-container')
const menuItems = document.querySelectorAll('.menu-primary li')
const isMobile = () => window.innerWidth <= 768
const udpateMenuState = () => {
const isExpanded = menuInput.checked
menuButtonContainer.setAttribute('aria-expanded', isExpanded)
if(isExpanded) menuLabelText.textContent = 'Close mobile menu'
if (!isExpanded) menuLabelText.textContent = 'Open mobile menu'
}
udpateMenuState()
menuInput.addEventListener('change', udpateMenuState)
menuButtonContainer.addEventListener('keydown', e => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
menuInput.checked = !menuInput.checked
udpateMenuState()
}
})
@ -35,9 +20,6 @@ window.addEventListener('load', () => {
})
document.addEventListener('keydown', e => {
if (e.key === 'Escape' && isMobile() && menuInput.checked) {
menuInput.checked = false
udpateMenuState()
}
if (e.key === 'Escape' && menuInput.checked) menuInput.checked = false
})
})

View file

@ -561,37 +561,6 @@ li {
display: none !important;
}
.hidden-visually {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
white-space: nowrap;
width: 1px;
&:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
}
.screen-readers-only:not(:focus):not(:active) {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.text-centered {
text-align: center !important;
}