🐛 fix(theme-switcher): match functionality of minified and non-minified files
This commit is contained in:
parent
130aa51144
commit
ee2b171fbd
@ -5,7 +5,6 @@ const themeResetter = document.querySelector(".theme-resetter");
|
|||||||
// Retrieve theme from either the localStorage or the data-theme attribute on the document element.
|
// Retrieve theme from either the localStorage or the data-theme attribute on the document element.
|
||||||
let currentTheme = localStorage.getItem("theme") || document.documentElement.getAttribute('data-theme');
|
let currentTheme = localStorage.getItem("theme") || document.documentElement.getAttribute('data-theme');
|
||||||
|
|
||||||
// Function to set theme.
|
|
||||||
function setTheme(theme, saveToLocalStorage = false) {
|
function setTheme(theme, saveToLocalStorage = false) {
|
||||||
document.documentElement.setAttribute("data-theme", theme);
|
document.documentElement.setAttribute("data-theme", theme);
|
||||||
currentTheme = theme;
|
currentTheme = theme;
|
||||||
@ -30,9 +29,7 @@ function setTheme(theme, saveToLocalStorage = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetTheme() {
|
function resetTheme() {
|
||||||
const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
setTheme(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
||||||
const defaultTheme = isSystemDark ? "dark" : "light";
|
|
||||||
setTheme(defaultTheme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to switch between dark and light themes.
|
// Function to switch between dark and light themes.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user