feat: implement chart toggles without jss

This commit is contained in:
Cory Dransfeldt 2024-08-10 21:20:12 -07:00
parent 2bf2fba325
commit f84c7e10d6
No known key found for this signature in database
5 changed files with 63 additions and 44 deletions

View file

@ -1,27 +0,0 @@
window.addEventListener('load', () => {
const buttonSets = document.querySelectorAll('.section-header-buttons')
const initializeButtonSet = (buttonSet) => {
const buttons = buttonSet.querySelectorAll('button')
const buttonIds = Array.from(buttons).map((button) => button.getAttribute('data-toggle'))
buttons.forEach(button => {
button.addEventListener('click', function () {
const targetId = this.getAttribute('data-toggle')
const targetContent = document.getElementById(targetId)
buttons.forEach(btn => {
btn.classList.toggle('active', btn === this)
btn.classList.toggle('secondary', btn !== this)
})
buttonIds.forEach(id => {
document.getElementById(id).classList.toggle('hidden', id !== targetId)
})
targetContent.classList.remove('hidden')
})
})
}
buttonSets.forEach(initializeButtonSet)
})