mirror of
https://github.com/welpo/tabi.git
synced 2025-10-11 07:46:15 +02:00
🐛 fix(theme-switcher): match functionality of minified and non-minified files
This commit is contained in:
parent
130aa51144
commit
ee2b171fbd
1 changed files with 1 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue