Redesign header: theme toggle, user avatar, burger menu
The app was dark-only with the email shown as plain text and a bare
"Abmelden" button. Header now has:
- A light/dark theme toggle (sun/moon icon). Choice persists via
localStorage and is applied before first paint (inline script in
<head>) to avoid a flash of the wrong theme; falls back to the
system preference on first visit. Added a light CSS variable set
alongside the existing dark palette.
- A circular user icon (head-and-shoulders) showing the email as a
tooltip, replacing the plain-text address.
- A burger-menu dropdown with the email, disabled placeholder items
("Tags verwalten", "Einstellungen" — marked "bald") to make room
for future features, and the actual Abmelden action.
Dropdown opens/closes via a small vanilla-JS handler in base.html
(click outside or Escape closes it), consistent with the project's
no-build-step, mostly-HTMX frontend.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,13 +4,34 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}LinkVault{% endblock %}</title>
|
||||
<script>
|
||||
/* Theme so früh wie möglich setzen, damit die Seite nicht kurz hell aufblitzt. */
|
||||
(function () {
|
||||
try {
|
||||
var stored = localStorage.getItem('linkvault-theme');
|
||||
if (stored === 'light' || stored === 'dark') {
|
||||
document.documentElement.setAttribute('data-theme', stored);
|
||||
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
||||
document.documentElement.setAttribute('data-theme', 'light');
|
||||
}
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.3"></script>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #0f172a; --panel: #1e293b; --panel2: #273449;
|
||||
--text: #e2e8f0; --muted: #94a3b8; --accent: #6366f1;
|
||||
--accent-hover: #818cf8; --border: #334155; --danger: #ef4444;
|
||||
}
|
||||
:root[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
--bg: #f8fafc; --panel: #ffffff; --panel2: #f1f5f9;
|
||||
--text: #0f172a; --muted: #64748b; --accent: #6366f1;
|
||||
--accent-hover: #4f46e5; --border: #e2e8f0; --danger: #dc2626;
|
||||
}
|
||||
body { transition: background-color .15s, color .15s; }
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
@@ -136,6 +157,7 @@
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
width: 30px; height: 30px; padding: 0;
|
||||
}
|
||||
.theme-icon-dark, .theme-icon-light { display: inline-flex; }
|
||||
.icon-warn { color: #eab308; }
|
||||
.icon-bookmark-active { color: #eab308; }
|
||||
|
||||
@@ -149,6 +171,30 @@
|
||||
text-align: center; padding: 16px 24px; margin-top: 24px;
|
||||
color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.user-menu { position: relative; display: flex; align-items: center; gap: 4px; }
|
||||
.user-dropdown {
|
||||
position: absolute; top: calc(100% + 8px); right: 0; min-width: 230px;
|
||||
background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
|
||||
box-shadow: 0 12px 32px rgba(0,0,0,.35); padding: 6px; z-index: 50;
|
||||
}
|
||||
:root[data-theme="light"] .user-dropdown { box-shadow: 0 12px 32px rgba(15,23,42,.14); }
|
||||
.dropdown-email {
|
||||
padding: 8px 10px; font-size: .8rem; color: var(--muted);
|
||||
word-break: break-all;
|
||||
}
|
||||
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
|
||||
.dropdown-item {
|
||||
display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
|
||||
background: transparent; color: var(--text); border: none; border-radius: 6px;
|
||||
padding: 8px 10px; font-size: .875rem; font-weight: 400; cursor: pointer;
|
||||
}
|
||||
.dropdown-item:hover:not(:disabled) { background: var(--panel2); }
|
||||
.dropdown-item:disabled { color: var(--muted); cursor: default; opacity: .65; }
|
||||
.dropdown-item .soon {
|
||||
margin-left: auto; font-size: .65rem; text-transform: uppercase; letter-spacing: .04em;
|
||||
background: var(--panel2); color: var(--muted); padding: 2px 6px; border-radius: 99px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -156,5 +202,49 @@
|
||||
<footer class="app-footer">
|
||||
© {{ app_author }} · Version {{ app_version }} · {{ app_host }}
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var themeBtn = document.getElementById('theme-toggle');
|
||||
if (themeBtn) {
|
||||
var dark = themeBtn.querySelector('.theme-icon-dark');
|
||||
var light = themeBtn.querySelector('.theme-icon-light');
|
||||
var applyIcon = function (theme) {
|
||||
dark.style.display = theme === 'light' ? 'none' : 'inline-flex';
|
||||
light.style.display = theme === 'light' ? 'inline-flex' : 'none';
|
||||
};
|
||||
applyIcon(document.documentElement.getAttribute('data-theme') === 'light' ? 'light' : 'dark');
|
||||
themeBtn.addEventListener('click', function () {
|
||||
var next = document.documentElement.getAttribute('data-theme') === 'light' ? 'dark' : 'light';
|
||||
document.documentElement.setAttribute('data-theme', next);
|
||||
try { localStorage.setItem('linkvault-theme', next); } catch (e) {}
|
||||
applyIcon(next);
|
||||
});
|
||||
}
|
||||
|
||||
var menuBtn = document.getElementById('menu-toggle');
|
||||
var dropdown = document.getElementById('user-dropdown');
|
||||
if (menuBtn && dropdown) {
|
||||
var close = function () {
|
||||
dropdown.hidden = true;
|
||||
menuBtn.setAttribute('aria-expanded', 'false');
|
||||
};
|
||||
var open = function () {
|
||||
dropdown.hidden = false;
|
||||
menuBtn.setAttribute('aria-expanded', 'true');
|
||||
};
|
||||
menuBtn.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
if (dropdown.hidden) open(); else close();
|
||||
});
|
||||
document.addEventListener('click', function (e) {
|
||||
if (!dropdown.hidden && !dropdown.contains(e.target) && e.target !== menuBtn) close();
|
||||
});
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape') close();
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user