From 5d6d4bd4d48477d48a64ef694dfc7a61c3bc6225 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Sat, 18 Dec 2021 22:20:52 +0100 Subject: [PATCH] Fix: Lieve modifica al codice per la dark-mode --- views/base.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/views/base.html b/views/base.html index 22a052c..38edfb6 100644 --- a/views/base.html +++ b/views/base.html @@ -34,9 +34,8 @@ const $toggle = document.querySelector('#toggle-dark-mode'); const $toggleIcon = document.querySelector('#toggle-dark-mode i'); - // Loads prefered dark from from localStorage or default to media query. - let prefersDarkMode = localStorage.getItem('theme') === 'dark' - || window.matchMedia('(prefers-color-scheme: dark)').matches; + // Loads prefered dark from from localStorage or defaults to media query. + let prefersDarkMode = localStorage.getItem('theme') !== undefined ? localStorage.getItem('theme') === 'dark' : window.matchMedia('(prefers-color-scheme: dark)').matches; function storePrefersDarkMode(mode) { prefersDarkMode = mode;