Add JS tests, refactor SitemapController, extract JS modules
- Extract mobile-menu.js and tabs.js from app.js - Add Vitest tests with happy-dom and v8 coverage (100% on modules) - Add JS test step to CI frontend and SonarQube workflows - SonarQube: add JS lcov coverage report path - SitemapController: extract URLSET_TEMPLATE constant, deduplicate methods Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
assets/modules/mobile-menu.js
Normal file
16
assets/modules/mobile-menu.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export function initMobileMenu() {
|
||||
const btn = document.getElementById('mobile-menu-btn')
|
||||
const menu = document.getElementById('mobile-menu')
|
||||
const iconOpen = document.getElementById('menu-icon-open')
|
||||
const iconClose = document.getElementById('menu-icon-close')
|
||||
|
||||
if (btn && menu) {
|
||||
btn.addEventListener('click', () => {
|
||||
const isOpen = !menu.classList.contains('hidden')
|
||||
menu.classList.toggle('hidden')
|
||||
iconOpen.classList.toggle('hidden')
|
||||
iconClose.classList.toggle('hidden')
|
||||
btn.setAttribute('aria-expanded', String(!isOpen))
|
||||
})
|
||||
}
|
||||
}
|
||||
13
assets/modules/tabs.js
Normal file
13
assets/modules/tabs.js
Normal file
@@ -0,0 +1,13 @@
|
||||
export function initTabs() {
|
||||
document.querySelectorAll('[data-tab]').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const targetId = button.dataset.tab
|
||||
document.querySelectorAll('[data-tab]').forEach(b => {
|
||||
const isActive = b.dataset.tab === targetId
|
||||
b.style.backgroundColor = isActive ? '#111827' : 'white'
|
||||
b.style.color = isActive ? 'white' : '#111827'
|
||||
document.getElementById(b.dataset.tab).style.display = isActive ? 'block' : 'none'
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user