feat(#35): make basket more prominent in nav

This commit is contained in:
OllyNicholass
2024-10-29 20:44:45 +00:00
parent 7c6afd169c
commit 4be732005e
7 changed files with 84 additions and 47 deletions
+38 -2
View File
@@ -1,10 +1,46 @@
<script lang="ts">
import { type NavLinkItem } from '$lib/types/Nav/NavLinkItem';
import type { Session } from '@supabase/supabase-js';
import NavLinkParent from './NavLinkParent.svelte';
import type SupabaseClient from '@supabase/supabase-js/dist/module/SupabaseClient';
export let session: Session | null;
export let supabase: SupabaseClient | null = null;
export let isMobile = false;
const userAccountLinks: NavLinkItem[] = [];
if (isMobile) {
if (session) {
userAccountLinks.push(
{
text: 'User', // TODO - replace with user's name - will require a database call to get the user's name - suggest setting up a user model to store user data.
isParent: true,
isUserAccount: true,
children: [
{
text: 'Account',
href: '/account'
},
{
text: 'Sign Out',
isSignout: true
}
]
}
);
} else {
userAccountLinks.push(
{
text: 'Log in',
href: '/login'
},
);
}
}
const links: NavLinkItem[] = [
...userAccountLinks,
{
text: 'Products',
href: '/products'
@@ -32,9 +68,9 @@
<ul class:flex={!isMobile} class:space-x-4={!isMobile}>
{#each links as link}
<li>
<li class:md:hidden={link.isUserAccount}>
{#if link.isParent}
<NavLinkParent text={link.text} children={link.children} {isMobile} />
<NavLinkParent linkItem={link} {isMobile} {supabase} />
{:else}
<a href={link.href}>{link.text}</a>
{/if}