-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathAdminSidebar.svelte
More file actions
68 lines (64 loc) · 1.8 KB
/
AdminSidebar.svelte
File metadata and controls
68 lines (64 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!-- web-admin/src/features/admin/layout/AdminSidebar.svelte -->
<script lang="ts">
import { page } from "$app/stores";
const navGroups = [
{
heading: "People",
items: [
{ label: "Users", href: "/-/admin" },
{ label: "Superusers", href: "/-/admin/superusers" },
],
},
{
heading: "Billing & Plans",
items: [
{ label: "Billing", href: "/-/admin/billing" },
{ label: "Quotas", href: "/-/admin/quotas" },
],
},
{
heading: "Resources",
items: [
{ label: "Organizations", href: "/-/admin/organizations" },
{ label: "Projects", href: "/-/admin/projects" },
],
},
];
function isActive(href: string, pathname: string): boolean {
if (href === "/-/admin") return pathname === "/-/admin";
return pathname.startsWith(href);
}
</script>
<nav
class="w-56 flex-shrink-0 border-r border-slate-200 bg-slate-50 flex flex-col h-full"
>
<div class="px-4 py-4 border-b border-slate-200">
<span class="text-sm font-semibold text-slate-900">
Admin Console
</span>
</div>
<div class="flex-1 overflow-y-auto py-3 px-3">
{#each navGroups as group}
<div class="mb-4">
<span
class="text-[11px] font-semibold uppercase tracking-wider text-slate-400 px-2 mb-1 block"
>
{group.heading}
</span>
{#each group.items as item}
<a
href={item.href}
class="block px-2 py-1.5 text-sm rounded-md transition-colors {isActive(
item.href,
$page.url.pathname,
)
? 'bg-slate-100 text-slate-900 font-medium'
: 'text-slate-600 hover:bg-slate-100'}"
>
{item.label}
</a>
{/each}
</div>
{/each}
</div>
</nav>