mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-13 11:03:49 +00:00
refactor(#35): iNdEnTaTiOn
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
<script lang="ts">
|
||||
import type { NavLinkItem } from "$lib/types/Nav/NavLinkItem";
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
import SignOut from "../SignOut.svelte";
|
||||
|
||||
export let linkItem: NavLinkItem;
|
||||
export let supabase: SupabaseClient | null = null;
|
||||
import type { NavLinkItem } from '$lib/types/Nav/NavLinkItem';
|
||||
import type { SupabaseClient } from '@supabase/supabase-js';
|
||||
import SignOut from '../SignOut.svelte';
|
||||
|
||||
export let linkItem: NavLinkItem;
|
||||
export let supabase: SupabaseClient | null = null;
|
||||
</script>
|
||||
|
||||
{#if !linkItem.isSignout}
|
||||
<a href={linkItem.href}>{linkItem.text}</a>
|
||||
<a href={linkItem.href}>{linkItem.text}</a>
|
||||
{:else if supabase && linkItem.isSignout}
|
||||
<SignOut {supabase} />
|
||||
{/if}
|
||||
<SignOut {supabase} />
|
||||
{/if}
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
export let linkItem: NavLinkItem;
|
||||
export let isMobile: boolean;
|
||||
export let supabase: SupabaseClient | null;
|
||||
|
||||
export let supabase: SupabaseClient | null;
|
||||
|
||||
let isOpen = false;
|
||||
</script>
|
||||
@@ -35,7 +34,7 @@
|
||||
transition:slide={{ duration: 200, easing: cubicInOut }}
|
||||
>
|
||||
{#each linkItem.children ?? [] as child (child.text.replace(' ', '-').toLowerCase())}
|
||||
<li><NavLink linkItem={child} {supabase} /></li>
|
||||
<li><NavLink linkItem={child} {supabase} /></li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
@@ -4,43 +4,39 @@
|
||||
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 session: Session | null;
|
||||
export let supabase: SupabaseClient | null = null;
|
||||
export let isMobile = false;
|
||||
|
||||
const userAccountLinks: NavLinkItem[] = [];
|
||||
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'
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
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,
|
||||
...userAccountLinks,
|
||||
{
|
||||
text: 'Products',
|
||||
href: '/products'
|
||||
|
||||
Reference in New Issue
Block a user