assetmapper
This commit is contained in:
parent
89c54af921
commit
caeb663251
23 changed files with 982 additions and 175 deletions
18
assets/theme.js
Normal file
18
assets/theme.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Theme detection and switching
|
||||
const getPreferredTheme = () => {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
const setTheme = theme => {
|
||||
document.documentElement.setAttribute('data-bs-theme', theme)
|
||||
}
|
||||
|
||||
// Set initial theme
|
||||
setTheme(getPreferredTheme())
|
||||
|
||||
// Listen for changes in user's preferred color scheme
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
||||
setTheme(getPreferredTheme())
|
||||
})
|
||||
|
||||
export { getPreferredTheme, setTheme };
|
Loading…
Add table
Add a link
Reference in a new issue