Enable automatic dark mode
This commit is contained in:
parent
896bfaec73
commit
6feb8754ae
1 changed files with 15 additions and 1 deletions
|
@ -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>
|
||||||
|
|
Loading…
Add table
Reference in a new issue