-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/lennart
Signed-off-by: lennartrommeiss <lennart.rommeiss@deutschebahn.com>
- Loading branch information
Showing
13 changed files
with
207 additions
and
81 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function initCountrySelector() { | ||
|
||
const expandButton = document.querySelector('.o-header__expand-button'); | ||
const countryContainer = document.querySelector('.o-header__item-countries'); | ||
|
||
expandButton.addEventListener('click', () => { | ||
countryContainer.classList.toggle("o-header__item-countries--open"); | ||
|
||
if (expandButton.getAttribute("aria-expanded") === 'false') { | ||
expandButton.setAttribute("aria-expanded", "true"); | ||
} else { | ||
expandButton.setAttribute("aria-expanded", "false"); | ||
} | ||
}); | ||
} | ||
|
||
if (document.readyState === "interactive") { | ||
initCountrySelector(); | ||
} else { | ||
window.addEventListener("DOMContentLoaded", () => { | ||
initCountrySelector(); | ||
}); | ||
} | ||
|
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,2 +1,4 @@ | ||
import './mobileMenu.js'; | ||
import './countrySelector.js'; | ||
import './resizeObserver.js'; | ||
import './mediaqueries.js'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,46 @@ | ||
import * as mq from './mediaqueries'; | ||
|
||
function initMobileMenu() { | ||
console.log('huhu2'); | ||
|
||
const menuButton = document.querySelector('.o-nav__menu-button'); | ||
const closeButton = document.querySelector('.o-nav__close-button'); | ||
const navContainer = document.querySelector('.o-header__nav'); | ||
|
||
menuButton.addEventListener('click', () => { | ||
console.log('CLICKED'); | ||
navContainer.classList.add("o-header__nav--open"); | ||
openMobileMenu() | ||
}); | ||
|
||
closeButton.addEventListener('click', () => { | ||
console.log('CLICKED'); | ||
navContainer.classList.remove("o-header__nav--open"); | ||
closeMobileMenu() | ||
}); | ||
} | ||
|
||
function resizeObserver() { | ||
window.addEventListener("resize", () => { | ||
const navContainer = document.querySelector('.o-header__nav'); | ||
if (window.matchMedia(mq.minMD).matches) { | ||
navContainer.classList.remove("o-header__nav--open"); | ||
console.log('resized'); | ||
window.onclick = e => { | ||
if (e.target.classList.contains('o-header__curtain')) { | ||
closeMobileMenu(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function openMobileMenu() { | ||
const navContainer = document.querySelector('.o-header__nav'); | ||
const menuButton = document.querySelector('.o-nav__menu-button'); | ||
|
||
navContainer.classList.add("o-header__nav--open"); | ||
menuButton.setAttribute('aria-expanded', true); | ||
} | ||
|
||
function closeMobileMenu() { | ||
const navContainer = document.querySelector('.o-header__nav'); | ||
const menuButton = document.querySelector('.o-nav__menu-button'); | ||
|
||
navContainer.classList.remove("o-header__nav--open"); | ||
menuButton.setAttribute('aria-expanded', false); | ||
} | ||
|
||
if (document.readyState === "interactive") { | ||
console.log('DOM ready'); | ||
initMobileMenu(); | ||
resizeObserver(); | ||
} else { | ||
window.addEventListener("DOMContentLoaded", () => { | ||
console.log('DOM ready'); | ||
initMobileMenu(); | ||
resizeObserver(); | ||
}); | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as mq from './mediaqueries'; | ||
|
||
function resizeObserver() { | ||
const navContainer = document.querySelector('.o-header__nav'); | ||
const menuButton = document.querySelector('.o-nav__menu-button'); | ||
const countryContainer = document.querySelector('.o-header__item-countries'); | ||
|
||
window.addEventListener("resize", () => { | ||
|
||
//close mobile menu on viewports >= md | ||
if (window.matchMedia(mq.minMD).matches) { | ||
navContainer.classList.remove("o-header__nav--open"); | ||
menuButton.setAttribute('aria-expanded', false); | ||
} | ||
|
||
//close country selector on viewports < md | ||
if (window.matchMedia(mq.maxSM).matches) { | ||
countryContainer.classList.remove("o-header__item-countries--open"); | ||
} | ||
}); | ||
} | ||
|
||
if (document.readyState === "interactive") { | ||
resizeObserver(); | ||
} else { | ||
window.addEventListener("DOMContentLoaded", () => { | ||
resizeObserver(); | ||
}); | ||
} | ||
|
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
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
Oops, something went wrong.