added templates, more solid DarkMode
All checks were successful
/ push_to_registry (push) Successful in 1m13s
All checks were successful
/ push_to_registry (push) Successful in 1m13s
This commit is contained in:
48
templates/base.html
Normal file
48
templates/base.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ block "title" . }}Passwort-Generator{{ end }}</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const root = document.documentElement;
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
const themeToggle = document.getElementById('theme-toggle');
|
||||
|
||||
// Setze das Theme basierend auf localStorage oder Systemeinstellung
|
||||
if (savedTheme === 'dark') {
|
||||
root.classList.add('dark');
|
||||
} else if (savedTheme === 'light') {
|
||||
root.classList.remove('dark');
|
||||
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
root.classList.add('dark');
|
||||
}
|
||||
|
||||
// Toggle-Button-Logik
|
||||
themeToggle.addEventListener('click', function() {
|
||||
if (root.classList.contains('dark')) {
|
||||
root.classList.remove('dark');
|
||||
localStorage.setItem('theme', 'light');
|
||||
} else {
|
||||
root.classList.add('dark');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
}
|
||||
});
|
||||
|
||||
// Systemtheme-Änderungen abhören
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(e) {
|
||||
if (!localStorage.getItem('theme')) {
|
||||
e.matches ? root.classList.add('dark') : root.classList.remove('dark');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{ block "head" . }}{{ end }}
|
||||
</head>
|
||||
<body>
|
||||
<button id="theme-toggle">🌓</button>
|
||||
{{ block "body" . }}{{end}}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user