Skip to content

Commit

Permalink
Update Theme and fix SW Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
smashedr committed Aug 22, 2024
1 parent 1f950d8 commit 09bebaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions app/static/bootstrap/theme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// BS Theme Switcher JS
// JS Bootstrap Theme Switcher

;(() => {
const getStoredTheme = () => localStorage.getItem('theme')
Expand Down Expand Up @@ -39,7 +39,8 @@
// console.debug(`showActiveTheme: ${theme}`)
const themeIcon = document.querySelector('#theme-icon')
if (!themeIcon) {
return console.debug('No Theme Icon to Set.')
// console.debug('No Theme Icon to Set.')
return
}
document.querySelectorAll('[data-bs-theme-value]').forEach((el) => {
if (el.dataset.bsThemeValue === theme) {
Expand All @@ -54,6 +55,14 @@
})
}

window.addEventListener('storage', (event) => {
// console.log('storage:', event)
if (event.key === 'theme') {
setTheme(event.newValue)
showActiveTheme(event.newValue)
}
})

window
.matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', () => {
Expand Down
2 changes: 1 addition & 1 deletion app/static/js/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const resources = [
'/static/dist/bootstrap/bootstrap.bundle.min.js',
'/static/dist/clipboard/clipboard.min.js',
'/static/dist/fontawesome/css/all.min.css',
'/static/dist/fontawesome/js/all.min.js',
// '/static/dist/fontawesome/js/all.min.js',
'/static/dist/fontawesome/webfonts/fa-brands-400.woff2',
'/static/dist/fontawesome/webfonts/fa-regular-400.woff2',
'/static/dist/fontawesome/webfonts/fa-solid-900.woff2',
Expand Down

0 comments on commit 09bebaf

Please sign in to comment.