feat: add account switching from sidebar
This commit is contained in:
1 parent
6bb47c2b1d
commit
482265475b
1 file changed
+39
-4
@@ -6,10 +6,13 @@
|
|||||||
Home,
|
Home,
|
||||||
Icon,
|
Icon,
|
||||||
Plus,
|
Plus,
|
||||||
|
UserCircle,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Button from '../input/Button.svelte'
|
import Button from '../input/Button.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile, profileData, setUserID } from '$lib/auth.js'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
|
||||||
let expanded = true
|
let expanded = true
|
||||||
</script>
|
</script>
|
||||||
@@ -29,6 +32,7 @@
|
|||||||
mini
|
mini
|
||||||
size="16"
|
size="16"
|
||||||
class="transition-transform {expanded ? '' : 'rotate-180'}"
|
class="transition-transform {expanded ? '' : 'rotate-180'}"
|
||||||
|
title="Toggle expanded"
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -37,7 +41,7 @@
|
|||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
>
|
>
|
||||||
<Icon src={Home} solid size="20" />
|
<Icon src={Home} solid size="20" title="Frontpage" />
|
||||||
<span class:hidden={!expanded}>Frontpage</span>
|
<span class:hidden={!expanded}>Frontpage</span>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
@@ -46,9 +50,40 @@
|
|||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
>
|
>
|
||||||
<Icon src={Cog6Tooth} solid size="20" />
|
<Icon src={Cog6Tooth} solid size="20" title="Settings" />
|
||||||
<span class:hidden={!expanded}>Settings</span>
|
<span class:hidden={!expanded}>Settings</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
{#if $profileData.profiles.length >= 1}
|
||||||
|
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
||||||
|
{#each $profileData.profiles as prof, index}
|
||||||
|
<Button
|
||||||
|
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'} {$profile?.id ==
|
||||||
|
prof.id
|
||||||
|
? expanded
|
||||||
|
? 'font-bold'
|
||||||
|
: 'text-sky-500'
|
||||||
|
: ''}"
|
||||||
|
color="tertiary"
|
||||||
|
alignment="left"
|
||||||
|
on:click={() => {
|
||||||
|
setUserID(prof.id)
|
||||||
|
goto($page.url, {
|
||||||
|
invalidateAll: true,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
src={UserCircle}
|
||||||
|
mini={$profile?.id == prof.id}
|
||||||
|
size="20"
|
||||||
|
title={prof.username}
|
||||||
|
class="text-blue-500"
|
||||||
|
style="filter: hue-rotate({index * 50}deg)"
|
||||||
|
/>
|
||||||
|
<span class:hidden={!expanded}>{prof.username}</span>
|
||||||
|
</Button>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
||||||
{#if $profile?.user}
|
{#if $profile?.user}
|
||||||
{#each $profile.user.follows
|
{#each $profile.user.follows
|
||||||
@@ -84,7 +119,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<Button
|
<Button
|
||||||
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
|
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
|
||||||
href="/login"
|
href="/accounts"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user