Jelajahi Sumber

#3655 - Artificer dark/light mode switcher

RomanL 4 tahun lalu
induk
melakukan
b54b9cab7c
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      modules/boonex/artificer/js/utils.js

+ 3 - 1
modules/boonex/artificer/js/utils.js

@@ -1,7 +1,9 @@
 //for custom JS
+if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) 
+        $('html').addClass('dark')
+
 $(document).ready(function() {
     if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
-        $('html').addClass('dark')
         $('.bx-sb-theme-switcher .sys-icon').addClass('moon');
     } else {
         document.documentElement.classList.remove('dark');