diff --git a/frontend/main.ts b/frontend/main.ts index fb951e0..304d6f6 100644 --- a/frontend/main.ts +++ b/frontend/main.ts @@ -77,17 +77,15 @@ function colorThemeWatcher() { function setTheme(theme: string, setLocalStorage = true) { let toggleBtn = document.querySelector('#theme-toggle-js'); - if(toggleBtn) { - if (setLocalStorage) { - localStorage.setItem('theme', theme); - } - toggleBtn.setAttribute('data-theme', theme); + if (setLocalStorage) { + localStorage.setItem('theme', theme); + } + if (toggleBtn) toggleBtn.setAttribute('data-theme', theme); - if (document.documentElement.classList.contains('dark') && theme === 'light') { - document.documentElement.classList.remove('dark'); - } else if(theme === 'dark'){ - document.documentElement.classList.add('dark'); - } + if (document.documentElement.classList.contains('dark') && theme === 'light') { + document.documentElement.classList.remove('dark'); + } else if(theme === 'dark'){ + document.documentElement.classList.add('dark'); } } diff --git a/templates/base.html.tera b/templates/base.html.tera index 1dff697..c33fefc 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -30,7 +30,7 @@ {% endif %} -
{% block content %}{% endblock content %} +
{% block content %}{% endblock content %}
{% if loggedin_user %}