fix light toggle

This commit is contained in:
Nycki 2025-03-21 16:59:41 -07:00
parent a60c1fef23
commit dba1380966

View file

@ -1,5 +1,12 @@
function themeToggle() { function themeToggle() {
const oldValue = localStorage.getItem('theme'); let oldValue = localStorage.getItem('theme');
if (!oldValue) {
oldValue = 'light';
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
oldValue = 'dark';
}
}
let newValue; let newValue;
if (oldValue == 'light') { if (oldValue == 'light') {
newValue = 'dark'; newValue = 'dark';
@ -15,11 +22,7 @@ function themeClear() {
themeRefresh(); themeRefresh();
} }
function themeRefresh(newValue) { function themeRefresh() {
if (newValue !== undefined) {
localStorage.setItem('theme', newValue);
}
const theme = localStorage.getItem('theme') const theme = localStorage.getItem('theme')
const el = document.getElementsByTagName('html')[0]; const el = document.getElementsByTagName('html')[0];
if (theme == 'light') { if (theme == 'light') {