Nav: group sidebar links, add mobile slide-out drawer

Sidebar now separates Dashboard/Mein Profil/Mitglieder from Raids/
Premades with a thin divider, keeping the existing Admin section as its
own group below. On narrow screens the sidebar no longer collapses into
a horizontal icon strip - it becomes a full off-canvas drawer (same
layout and labels as desktop) toggled by a hamburger button in a new
mobile top bar, with a backdrop and Escape/backdrop-click/link-click to
close (assets/js/nav.js).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-20 01:37:12 +02:00
parent c8d9fb6baf
commit 1fb6a5fabd
5 changed files with 131 additions and 35 deletions

View file

@ -114,6 +114,61 @@ a:hover { color: var(--gold-hover); text-decoration: underline; }
color: var(--text-muted); color: var(--text-muted);
} }
/* Unbeschrifteter Trenner zwischen "Dashboard/Mein Profil/Mitglieder" und
"Raids/Premades" - optisch etwas getrennter, aber ohne eigene Ueberschrift
wie beim Admin-Bereich. */
.sidebar-nav-gap {
height: 0;
margin-top: 0.6rem;
padding-top: 0.6rem;
border-top: 1px solid var(--border);
}
/* Mobile Kopfleiste mit Burger-Button: ersetzt auf schmalen Bildschirmen die
Sidebar, die dort stattdessen als ausklappbare Schublade (siehe unten)
fungiert. Auf Desktop-Breiten bleibt sie unsichtbar. */
.mobile-topbar {
display: none;
align-items: center;
gap: 0.75rem;
padding: 0.6rem 1rem;
background: var(--bg-panel);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 900;
}
.mobile-topbar-brand img {
display: block;
height: 32px;
width: auto;
}
.sidebar-toggle {
display: none;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
flex-shrink: 0;
background: var(--bg-panel-alt);
border: 1px solid var(--border);
border-radius: 6px;
color: var(--text);
cursor: pointer;
}
.sidebar-toggle:hover { border-color: var(--gold); color: var(--gold); background: var(--bg-panel-alt); }
.sidebar-backdrop {
display: none;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
z-index: 999;
}
.sidebar-link { .sidebar-link {
display: flex; display: flex;
align-items: center; align-items: center;
@ -625,41 +680,31 @@ input:focus, select:focus, textarea:focus {
min-height: 0; min-height: 0;
} }
/* Die Sidebar selbst wird auf schmalen Bildschirmen zur ausklappbaren
Schublade: per Default ausserhalb des Viewports (transform), das
".open"-Klasse (via assets/js/nav.js) schiebt sie rein. Sie behaelt
dabei exakt die gleiche Optik/Beschriftung wie am Desktop. */
.mobile-topbar { display: flex; }
.sidebar-toggle { display: inline-flex; }
.sidebar { .sidebar {
position: static; position: fixed;
width: 100%; top: 0;
height: auto; left: 0;
flex-direction: row; width: min(280px, 82vw);
align-items: center; height: 100vh;
gap: 0.5rem; transform: translateX(-100%);
padding: 0.6rem 0.75rem; transition: transform 0.25s ease;
overflow-x: auto; z-index: 1000;
padding: 1.25rem 1rem;
} }
.sidebar-brand { padding: 0 0.75rem 0 0; } .sidebar.open {
.sidebar-brand img { height: 32px; } transform: translateX(0);
box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
.sidebar-nav {
flex-direction: row;
flex: none;
} }
.sidebar-section-label { display: none; } .sidebar-backdrop.open { display: block; }
.sidebar-link .label { display: none; }
.sidebar-footer {
flex-direction: row;
align-items: center;
margin-top: 0;
margin-left: auto;
padding-top: 0;
padding-left: 0.75rem;
border-top: none;
border-left: 1px solid var(--border);
}
.sidebar-user { display: none; }
} }
/* --- Raid-Verwaltung: Icon-Buttons, Editor-Modus, Modal, Drag & Drop --- */ /* --- Raid-Verwaltung: Icon-Buttons, Editor-Modus, Modal, Drag & Drop --- */

38
assets/js/nav.js Normal file
View file

@ -0,0 +1,38 @@
(function () {
'use strict';
var toggle = document.querySelector('.sidebar-toggle');
var sidebar = document.querySelector('.sidebar');
var backdrop = document.querySelector('.sidebar-backdrop');
if (!toggle || !sidebar || !backdrop) return;
function openSidebar() {
sidebar.classList.add('open');
backdrop.classList.add('open');
toggle.setAttribute('aria-expanded', 'true');
}
function closeSidebar() {
sidebar.classList.remove('open');
backdrop.classList.remove('open');
toggle.setAttribute('aria-expanded', 'false');
}
toggle.addEventListener('click', function () {
if (sidebar.classList.contains('open')) {
closeSidebar();
} else {
openSidebar();
}
});
backdrop.addEventListener('click', closeSidebar);
sidebar.querySelectorAll('.sidebar-link').forEach(function (link) {
link.addEventListener('click', closeSidebar);
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') closeSidebar();
});
})();

View file

@ -2,6 +2,7 @@
</main> </main>
</div> </div>
</div> </div>
<script src="/assets/js/nav.js"></script>
<?php else: ?> <?php else: ?>
</main> </main>
<?php endif; ?> <?php endif; ?>

View file

@ -123,6 +123,7 @@ function icon(string $name): string
'restore' => '<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>', 'restore' => '<polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/>',
'trash' => '<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/>', 'trash' => '<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/>',
'crown' => '<path d="M4 8l4 3 4-6 4 6 4-3-2 9H6z"/><path d="M6 20h12"/>', 'crown' => '<path d="M4 8l4 3 4-6 4 6 4-3-2 9H6z"/><path d="M6 20h12"/>',
'menu' => '<line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="17" x2="20" y2="17"/>',
]; ];
$path = $paths[$name] ?? ''; $path = $paths[$name] ?? '';

View file

@ -50,6 +50,13 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
<body> <body>
<?php if ($currentUser): ?> <?php if ($currentUser): ?>
<div class="app-shell"> <div class="app-shell">
<div class="mobile-topbar">
<button type="button" class="sidebar-toggle" aria-label="Menü öffnen" aria-expanded="false">
<?= icon('menu') ?>
</button>
<a href="/" class="mobile-topbar-brand"><img src="/assets/images/logo-mark.svg" alt="Aion2 Gilde"></a>
</div>
<div class="sidebar-backdrop"></div>
<aside class="sidebar"> <aside class="sidebar">
<div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Aion2 Gilde"></a></div> <div class="sidebar-brand"><a href="/"><img src="/assets/images/logo-mark.svg" alt="Aion2 Gilde"></a></div>
<nav class="sidebar-nav"> <nav class="sidebar-nav">
@ -59,6 +66,15 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
<a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil"> <a href="/profile.php" class="sidebar-link<?= $isProfileActive ? ' active' : '' ?>" title="Mein Profil">
<?= icon('profile') ?><span class="label">Mein Profil</span> <?= icon('profile') ?><span class="label">Mein Profil</span>
</a> </a>
<?php if ($canViewMembers): ?>
<a href="/members.php" class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
<?= icon('users') ?><span class="label">Mitglieder</span>
</a>
<?php endif; ?>
<?php if ($canViewRaids || $canViewPremades): ?>
<div class="sidebar-nav-gap"></div>
<?php endif; ?>
<?php if ($canViewRaids): ?> <?php if ($canViewRaids): ?>
<a href="/raids.php" class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids"> <a href="/raids.php" class="sidebar-link<?= $isRaidsActive ? ' active' : '' ?>" title="Raids">
<?= icon('calendar') ?><span class="label">Raids</span> <?= icon('calendar') ?><span class="label">Raids</span>
@ -69,11 +85,6 @@ $pageBackgroundClass = $pageBackgrounds[$currentScript] ?? '';
<?= icon('shield') ?><span class="label">Premades</span> <?= icon('shield') ?><span class="label">Premades</span>
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php if ($canViewMembers): ?>
<a href="/members.php" class="sidebar-link<?= $isMembersActive ? ' active' : '' ?>" title="Mitglieder">
<?= icon('users') ?><span class="label">Mitglieder</span>
</a>
<?php endif; ?>
<?php if ($showAdminMenu): ?> <?php if ($showAdminMenu): ?>
<div class="sidebar-section-label">Admin</div> <div class="sidebar-section-label">Admin</div>
<?php if ($canViewUsers): ?> <?php if ($canViewUsers): ?>