make appearance consistent
This commit is contained in:
parent
a80789dc41
commit
6057eb7065
2 changed files with 11 additions and 0 deletions
10
src/assets/scripts/isDarkMode.js
Normal file
10
src/assets/scripts/isDarkMode.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
;(function () {
|
||||
const isDarkMode = () =>
|
||||
localStorage.theme === 'dark' ||
|
||||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
if (isDarkMode()) {
|
||||
document.documentElement.classList.add('dark')
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
}
|
||||
})()
|
Reference in a new issue