Skip to content

Commit

Permalink
feat: added auth to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Wamy-Dev committed Aug 10, 2023
1 parent 32aa0a4 commit 9feeccc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 25 additions & 2 deletions apps/web/src/lib/components/layout/NavBar.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<script>
import { Link } from 'ui/link';
import { Button } from 'ui/button';
import { env } from '$env/dynamic/public';
import { isAuthenticated, user } from '$lib/stores/user';
$: isAuthenticated;
$: user;
</script>

<div class="beatforge-page-navbar flex w-full items-center py-8 px-4 mx-auto max-w-7xl z-[100] text-sm font-bold">
Expand All @@ -8,8 +14,25 @@
</Link>

<div class="ml-auto mr-4 flex flex-row gap-8 items-center">
<Link variant="text" href="https://discord.gg/HTVrjFENaZ" external>
Discord
<Link variant="text" href="/discover">
Discover Mods
</Link>
{#if $isAuthenticated}
<Link variant="text" href="/dashboard">
<Button variant="secondary" disabled={false}>
{user.username}
<img slot="trailing" alt="user icon" src={user.avatar} draggable="false" class="w-10 h-10 rounded-full">
</Button>
</Link>
{:else}
<Link variant="text" href="https://discord.gg/HTVrjFENaZ" external>
Discord
</Link>
<Link variant="text" href={env.PUBLIC_GITHUB_CALL_URL}>
<Button variant="secondary" disabled={false}>
Login
</Button>
</Link>
{/if}
</div>
</div>
4 changes: 4 additions & 0 deletions apps/web/src/lib/stores/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { writable } from "svelte/store";

export const isAuthenticated = writable(false);
export const user = writable(null);

0 comments on commit 9feeccc

Please sign in to comment.