Update themeSwitch.html

This commit is contained in:
Tara Rostami 2024-02-28 09:35:33 +03:30 committed by GitHub
parent 8b02617fe9
commit f1369a4d4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,10 +11,10 @@
function createThemeSwitcher() {
const isDarkTheme = localStorage.getItem('dark-mode') === 'true';
const isUltra = localStorage.getItem('isUltraDarkThemeEnabled') === 'true';
const theme = isDarkTheme ? 'dark' : 'light';
if (isUltra) {
document.documentElement.setAttribute('data-theme', 'ultra-dark');
}
const theme = isDarkTheme ? 'dark' : 'light';
document.querySelector('body').setAttribute('class', theme);
return {
isDarkTheme,
@ -32,11 +32,10 @@
this.isUltra = !this.isUltra;
if (this.isUltra) {
document.documentElement.setAttribute('data-theme', 'ultra-dark');
localStorage.setItem('isUltraDarkThemeEnabled', 'true');
} else {
document.documentElement.removeAttribute('data-theme');
localStorage.setItem('isUltraDarkThemeEnabled', 'false');
}
localStorage.setItem('isUltraDarkThemeEnabled', this.isUltra.toString());
}
};
}