Skip to content

Commit

Permalink
for of
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 7, 2024
1 parent a88e377 commit 3de999b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions docs/assets/js/color-modes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"] i`)
const initialIconOfActiveBtn = [...btnToActive.classList].find(cl => cl.startsWith('bi-'))

document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
for (const element of document.querySelectorAll('[data-bs-theme-value]')) {
element.classList.remove('active')
element.setAttribute('aria-pressed', 'false')
})
}

btnToActive.classList.add('active')
btnToActive.setAttribute('aria-pressed', 'true')
Expand All @@ -66,15 +66,14 @@
window.addEventListener('DOMContentLoaded', () => {
showActiveTheme(getPreferredTheme())

document.querySelectorAll('[data-bs-theme-value]')
.forEach(toggle => {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value')
localStorage.setItem('theme', theme)
setStoredTheme(theme)
setTheme(theme)
showActiveTheme(theme, true)
})
for (const toggle of document.querySelectorAll('[data-bs-theme-value]')) {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value')
localStorage.setItem('theme', theme)
setStoredTheme(theme)
setTheme(theme)
showActiveTheme(theme, true)
})
}
})
})()

0 comments on commit 3de999b

Please sign in to comment.