darkmode #34

Open
Gonne wants to merge 2 commits from darkmode into main
Showing only changes of commit 3bc8df0174 - Show all commits

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de" data-bs-theme="auto">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="keywords" content="Mathebau, Sprechstunde, Sprechstunden, Mathe, Mathematik, technische, Universität, Darmstadt, TU, Fachschaft"> <meta name="keywords" content="Mathebau, Sprechstunde, Sprechstunden, Mathe, Mathematik, technische, Universität, Darmstadt, TU, Fachschaft">
@ -42,5 +42,19 @@
</footer> </footer>
<script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- switch to dark mode if browser likes it -->
<script>
;(function () {
const htmlElement = document.querySelector("html")
if(htmlElement.getAttribute("data-bs-theme") === 'auto') {
function updateTheme() {
document.querySelector("html").setAttribute("data-bs-theme",
window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light")
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', updateTheme)
updateTheme()
}
})()
</script>
</body> </body>
</html> </html>