Thomas G. Lopes commited on
Commit
75ab73e
·
1 Parent(s): 288702f

readability

Browse files
Files changed (1) hide show
  1. src/app.html +8 -8
src/app.html CHANGED
@@ -10,22 +10,22 @@
10
  <body data-sveltekit-preload-data="hover" class="dark:bg-gray-900">
11
  <script>
12
  (function () {
13
- // Get theme from URL search params
14
  const urlParams = new URLSearchParams(window.location.search);
15
  const theme = urlParams.get("__theme");
16
 
17
- // Check system preferences
18
  let systemPrefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
19
 
20
- // Update theme based on params or system preference
21
  function updateTheme() {
22
- if (theme === "dark" || (theme === "system" && systemPrefersDark)) {
23
  document.body.classList.add("dark");
24
- } else if (theme === "light" || (theme === "system" && !systemPrefersDark)) {
25
  document.body.classList.remove("dark");
26
- } else if (theme === null || theme === undefined) {
27
- // Default behavior if no theme specified
28
- systemPrefersDark ? document.body.classList.add("dark") : document.body.classList.remove("dark");
 
 
 
29
  }
30
  }
31
 
 
10
  <body data-sveltekit-preload-data="hover" class="dark:bg-gray-900">
11
  <script>
12
  (function () {
 
13
  const urlParams = new URLSearchParams(window.location.search);
14
  const theme = urlParams.get("__theme");
15
 
 
16
  let systemPrefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
17
 
 
18
  function updateTheme() {
19
+ if (theme === "dark") {
20
  document.body.classList.add("dark");
21
+ } else if (theme === "light") {
22
  document.body.classList.remove("dark");
23
+ } else if (theme === "system" || theme === null || theme === undefined) {
24
+ if (systemPrefersDark) {
25
+ document.body.classList.add("dark");
26
+ } else {
27
+ document.body.classList.remove("dark");
28
+ }
29
  }
30
  }
31