Made page more responsive

This commit is contained in:
2026-06-05 22:18:47 +02:00
parent 52d551ab39
commit 419e05bb89
2 changed files with 60 additions and 57 deletions

View File

@@ -14,6 +14,9 @@
<div class="nav-container">
<div class="nav-left">
<div class="brand">Miau<span>Inv</span></div>
<button class="menu-trigger" id="menu-btn" aria-label="Menu">Menu</button>
<nav id="main-nav">
<a href="/dashboard">Dashboard</a>
<a href="/inventory">Inventory</a>
@@ -25,7 +28,6 @@
<div class="profile-dropdown">
<button class="profile-trigger" id="profile-btn">
<div class="avatar">M</div>
<span class="username">Profile</span>
</button>
<div class="dropdown-menu" id="dropdown-menu">
<a href="/profile/settings">Account Settings</a>
@@ -33,18 +35,7 @@
<hr class="dropdown-divider">
<button class="logout-btn"
hx-post="/api/logout"
hx-trigger="click"
hx-on::after-request="
if (event.detail.successful) {
localStorage.removeItem('access_token');
localStorage.removeItem('refresh_token');
document.cookie = 'access_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;';
document.cookie = 'refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;';
window.location.href = '/login';
} else {
alert('Logout failed. Please try again.');
}
">
hx-on::after-request="window.location.href='/login'">
Log Out
</button>
</div>
@@ -57,24 +48,31 @@
</main>
<script>
document.querySelectorAll('#main-nav a').forEach(link => {
if (link.getAttribute('href') === window.location.pathname) {
link.classList.add('active');
}
});
const profileBtn = document.getElementById('profile-btn');
const dropdownMenu = document.getElementById('dropdown-menu');
const menuBtn = document.getElementById('menu-btn');
const mainNav = document.getElementById('main-nav');
// Profil-Menü Toggle
profileBtn.addEventListener('click', (e) => {
e.stopPropagation();
dropdownMenu.classList.toggle('show');
mainNav.classList.remove('show'); // Mobile Nav schließen
});
document.addEventListener('click', () => {
if (dropdownMenu.classList.contains('show')) {
dropdownMenu.classList.remove('show');
}
// Mobile Nav Toggle
menuBtn.addEventListener('click', (e) => {
console.log("Button wurde geklickt!"); // Wird das im Browser angezeigt?
e.stopPropagation();
e.preventDefault(); // Verhindert Standard-Browser-Aktionen
mainNav.classList.toggle('show');
dropdownMenu.classList.remove('show');
});
// Alles schließen bei Klick in den Body
window.addEventListener('click', () => {
dropdownMenu.classList.remove('show');
mainNav.classList.remove('show');
});
</script>
</body>