From ee2b171fbd0c79b7374dda807fe223c72f81e9d5 Mon Sep 17 00:00:00 2001 From: welpo Date: Wed, 22 Nov 2023 00:18:05 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(theme-switcher):=20match=20f?= =?UTF-8?q?unctionality=20of=20minified=20and=20non-minified=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/themeSwitcher.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/static/js/themeSwitcher.js b/static/js/themeSwitcher.js index d6a0be57f..3ec6a84d7 100644 --- a/static/js/themeSwitcher.js +++ b/static/js/themeSwitcher.js @@ -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; @@ -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.