mirror of
https://github.com/tchartron/blow
synced 2024-11-23 12:53:20 +00:00
update
This commit is contained in:
parent
cdb1ae5c8f
commit
c7b220f30d
1 changed files with 4 additions and 2 deletions
|
@ -11,8 +11,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
|
||||
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
||||
document.documentElement.classList.add('dark')
|
||||
document.getElementById('light').add('hidden');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
document.getElementById('dark').add('hidden');
|
||||
}
|
||||
// Switch theme action
|
||||
document.getElementById('switch-theme').addEventListener('click', switchTheme);
|
||||
|
@ -29,7 +31,7 @@ function switchTheme() {
|
|||
} else {
|
||||
localStorage.theme = 'dark';
|
||||
document.documentElement.classList.add('dark');
|
||||
document.getElementById('light').remove('hidden');
|
||||
document.getElementById('dark').add('hidden');
|
||||
document.getElementById('light').add('hidden');
|
||||
document.getElementById('dark').remove('hidden');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue