1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 11:45:17 +02:00

Add UserAvatar component and update Navbar.svelte

This commit is contained in:
Sean Morley 2024-04-06 01:59:10 +00:00
parent cd11ce2d97
commit de2dd6cd7e
3 changed files with 16 additions and 6 deletions

View file

@ -4,6 +4,7 @@
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import type { DatabaseUser } from "$lib/server/auth"; import type { DatabaseUser } from "$lib/server/auth";
export let user: any; export let user: any;
import UserAvatar from "./UserAvatar.svelte";
async function goHome() { async function goHome() {
goto("/"); goto("/");
} }
@ -16,6 +17,9 @@
async function toToLogin() { async function toToLogin() {
goto("/login"); goto("/login");
} }
async function toToSignup() {
goto("/signup");
}
let count = 0; let count = 0;
visitCount.subscribe((value) => { visitCount.subscribe((value) => {
@ -54,8 +58,10 @@
<p>Adventures: {count}</p> <p>Adventures: {count}</p>
{#if !user} {#if !user}
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button> <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}
{#if user} {#if user}
<UserAvatar {user} />
<form method="post" use:enhance> <form method="post" use:enhance>
<button class="btn btn-primary ml-4">Sign out</button> <button class="btn btn-primary ml-4">Sign out</button>
</form> </form>

View 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>

View file

@ -31,9 +31,3 @@
</div> </div>
</div> </div>
</div> </div>
{#if data.user}
<form method="post" use:enhance>
<button class="btn btn-primary">Sign out</button>
</form>
{/if}