feat: first draft for dark mode support

This commit is contained in:
2021-12-18 13:53:56 +01:00
parent a5f724d167
commit 219a966860
3 changed files with 51 additions and 14 deletions
+17 -1
View File
@@ -30,6 +30,19 @@
]
});
});
<!-- [> WIP: Dark Mode <]
- document.documentElement.classList.toggle(
- 'dark',
- localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
- );
- document.addEventListener('DOMContentLoaded', () =>
- document.querySelectorAll('[toggle-dark-mode]').forEach((item) =>
- item.addEventListener('click', () => {
- localStorage.setItem('theme', localStorage.theme == 'dark' ? 'light' : 'dark');
- document.documentElement.classList.toggle('dark');
- })
- )
- ); -->
</script>
@@ -88,6 +101,9 @@
<a href="/login">Accedi</a>
</div>
{{end}}
<div class="nav-item toggle-dark-mode">
<a href=""><i class="fa-moon"></i></a>
</div>
</div>
</nav>
@@ -103,4 +119,4 @@
</body>
</html>
{{end}}
{{end}}