76 lines
2.4 KiB
Plaintext
76 lines
2.4 KiB
Plaintext
package adminview
|
|
|
|
import "git.haelnorr.com/h/oslstats/internal/view/baseview"
|
|
|
|
templ DashboardLayout(activeSection string) {
|
|
@baseview.Layout("Admin Dashboard") {
|
|
<div class="max-w-screen-2xl mx-auto px-2">
|
|
<div class="flex flex-col md:flex-row gap-4">
|
|
<!-- Sidebar Navigation -->
|
|
<aside
|
|
class="w-full md:w-64 flex-shrink-0"
|
|
x-data="{ mobileOpen: false }"
|
|
>
|
|
<!-- Mobile toggle button -->
|
|
<button
|
|
@click="mobileOpen = !mobileOpen"
|
|
class="md:hidden w-full bg-surface0 border border-surface1 rounded-lg px-4 py-3 mb-2 flex items-center justify-between hover:bg-surface1 transition"
|
|
>
|
|
<span class="font-semibold text-text">Admin Menu</span>
|
|
<svg
|
|
class="w-5 h-5 transition-transform"
|
|
:class="mobileOpen ? 'rotate-180' : ''"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
viewBox="0 0 24 24"
|
|
>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
|
</svg>
|
|
</button>
|
|
<!-- Navigation links -->
|
|
<nav
|
|
class="bg-surface0 border border-surface1 rounded-lg p-4"
|
|
:class="mobileOpen ? 'block' : 'hidden md:block'"
|
|
@click.away="mobileOpen = false"
|
|
>
|
|
<h2 class="text-lg font-bold text-text mb-4 px-2">Admin Dashboard</h2>
|
|
<ul class="space-y-1">
|
|
@navItem("users", "Users", activeSection)
|
|
@navItem("roles", "Roles", activeSection)
|
|
@navItem("permissions", "Permissions", activeSection)
|
|
@navItem("audit", "Audit Logs", activeSection)
|
|
</ul>
|
|
</nav>
|
|
</aside>
|
|
<!-- Main content area -->
|
|
<main class="flex-1 min-w-0" id="admin-content">
|
|
{ children... }
|
|
</main>
|
|
</div>
|
|
</div>
|
|
<script src="/static/js/admin.js"></script>
|
|
}
|
|
}
|
|
|
|
templ navItem(section string, label string, activeSection string) {
|
|
{{
|
|
isActive := section == activeSection
|
|
baseClasses := "block px-4 py-2 rounded-lg transition-colors cursor-pointer"
|
|
activeClasses := "bg-blue text-mantle font-semibold"
|
|
inactiveClasses := "text-subtext0 hover:bg-surface1 hover:text-text"
|
|
}}
|
|
<li>
|
|
<a
|
|
href={ templ.SafeURL("/admin/" + section) }
|
|
hx-post={ "/admin/" + section }
|
|
hx-target="#admin-content"
|
|
hx-swap="innerHTML"
|
|
hx-push-url={ "/admin/" + section }
|
|
class={ baseClasses, templ.KV(activeClasses, isActive), templ.KV(inactiveClasses, !isActive) }
|
|
@click="if (window.innerWidth < 768) mobileOpen = false"
|
|
>
|
|
{ label }
|
|
</a>
|
|
</li>
|
|
}
|