mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 19:55:18 +02:00
Add UserAvatar component and update Navbar.svelte
This commit is contained in:
parent
cd11ce2d97
commit
de2dd6cd7e
3 changed files with 16 additions and 6 deletions
|
@ -4,6 +4,7 @@
|
|||
import { goto } from "$app/navigation";
|
||||
import type { DatabaseUser } from "$lib/server/auth";
|
||||
export let user: any;
|
||||
import UserAvatar from "./UserAvatar.svelte";
|
||||
async function goHome() {
|
||||
goto("/");
|
||||
}
|
||||
|
@ -16,6 +17,9 @@
|
|||
async function toToLogin() {
|
||||
goto("/login");
|
||||
}
|
||||
async function toToSignup() {
|
||||
goto("/signup");
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
visitCount.subscribe((value) => {
|
||||
|
@ -54,8 +58,10 @@
|
|||
<p>Adventures: {count}</p>
|
||||
{#if !user}
|
||||
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
|
||||
<button class="btn btn-primary ml-4" on:click={toToSignup}>Signup</button>
|
||||
{/if}
|
||||
{#if user}
|
||||
<UserAvatar {user} />
|
||||
<form method="post" use:enhance>
|
||||
<button class="btn btn-primary ml-4">Sign out</button>
|
||||
</form>
|
||||
|
|
10
src/lib/components/UserAvatar.svelte
Normal file
10
src/lib/components/UserAvatar.svelte
Normal file
|
@ -0,0 +1,10 @@
|
|||
<script lang="ts">
|
||||
export let user: any;
|
||||
let firstLetter = user.first_name.charAt(0);
|
||||
</script>
|
||||
|
||||
<div class="avatar placeholder">
|
||||
<div class="bg-neutral text-neutral-content rounded-full w-10 ml-4">
|
||||
<span class="text-2xl">{firstLetter}</span>
|
||||
</div>
|
||||
</div>
|
|
@ -31,9 +31,3 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if data.user}
|
||||
<form method="post" use:enhance>
|
||||
<button class="btn btn-primary">Sign out</button>
|
||||
</form>
|
||||
{/if}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue