Skip to content

Commit

Permalink
šŸ› fix(theme-switcher): match functionality of minified and non-minifiā€¦
Browse files Browse the repository at this point in the history
ā€¦ed files
  • Loading branch information
welpo committed Nov 21, 2023
1 parent 130aa51 commit ee2b171
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions static/js/themeSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
let currentTheme = localStorage.getItem("theme") || document.documentElement.getAttribute('data-theme');

// Function to set theme.
function setTheme(theme, saveToLocalStorage = false) {
document.documentElement.setAttribute("data-theme", theme);
currentTheme = theme;
Expand All @@ -30,9 +29,7 @@ function setTheme(theme, saveToLocalStorage = false) {
}

function resetTheme() {
const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const defaultTheme = isSystemDark ? "dark" : "light";
setTheme(defaultTheme);
setTheme(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
}

// Function to switch between dark and light themes.
Expand Down

0 comments on commit ee2b171

Please sign in to comment.