-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathHeader.svelte
82 lines (78 loc) · 1.48 KB
/
Header.svelte
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<script lang="ts">
import { getSessionStore } from "$lib/stores/session";
import {
faBars,
faChartLine,
faCog,
faHeart,
faRocket,
faSignIn,
faSignOut,
} from "@fortawesome/free-solid-svg-icons";
import Fa from "svelte-fa";
import "../app.postcss";
const session = getSessionStore();
$: menu_items = $session?.user
? [
{
href: "/dashboard",
icon: faChartLine,
label: "Dashboard",
},
{
href: "/settings",
icon: faCog,
label: "Settings",
},
{
href: "/logout",
icon: faSignOut,
label: "Log Out",
reload: true,
},
]
: [
{
href: "/login",
icon: faSignIn,
label: "Log In",
},
{
href: "/signup",
icon: faHeart,
label: "Sign Up",
},
];
</script>
<header class="bg-base-200 px-6">
<div class="max-w-screen-md mx-auto flex items-center py-2">
<h1>
<a href="/" class="btn btn-ghost gap-3">
<Fa icon={faRocket} />
SvelteKit Auth
</a>
</h1>
<nav class="dropdown dropdown-end ml-auto">
<label tabindex="0" class="btn btn-ghost gap-3">
<Fa icon={faBars} />
Menu
</label>
<ul
tabindex="0"
class="dropdown-content menu p-2 shadow-md bg-base-200 rounded-box w-52 "
>
{#each menu_items as item}
<li>
<a
href={item.href}
data-sveltekit-reload={item.reload ? "" : "off"}
>
<Fa icon={item.icon} />
{item.label}
</a>
</li>
{/each}
</ul>
</nav>
</div>
</header>