189 lines
5.5 KiB
Svelte
189 lines
5.5 KiB
Svelte
<script lang="ts">
|
|
import { notifications, profile, profileData } from '$lib/auth.svelte.js'
|
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
|
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
|
|
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
|
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
|
import { t } from '$lib/i18n/translations'
|
|
import { settings } from '$lib/settings.svelte.js'
|
|
import { Badge } from 'mono-svelte'
|
|
import {
|
|
ArrowLeftOnRectangle,
|
|
Bookmark,
|
|
Cog6Tooth,
|
|
Identification,
|
|
Inbox,
|
|
UserCircle,
|
|
UserGroup,
|
|
} from 'svelte-hero-icons'
|
|
import EndPlaceholder from '../EndPlaceholder.svelte'
|
|
import type { ClassValue } from 'svelte/elements'
|
|
|
|
interface Props {
|
|
style?: string
|
|
class?: ClassValue
|
|
}
|
|
|
|
let { style = '', class: clazz = '' }: Props = $props()
|
|
</script>
|
|
|
|
<nav
|
|
class={['flex flex-col p-4 overflow-auto gap-1 h-fit max-h-screen', clazz]}
|
|
{style}
|
|
>
|
|
{#if profile.data?.jwt}
|
|
<SidebarButton icon={UserCircle} href="/profile">
|
|
{#snippet label()}
|
|
<span>
|
|
{$t('profile.profile')}
|
|
</span>
|
|
{/snippet}
|
|
</SidebarButton>
|
|
<SidebarButton icon={Inbox} href="/inbox">
|
|
{#snippet label()}
|
|
<span class="flex items-center gap-2">
|
|
{$t('profile.inbox')}
|
|
{#if $notifications.inbox}
|
|
<Badge
|
|
class="min-w-5 h-5 p-0! px-0.5 grid place-items-center ml-auto"
|
|
color="red-subtle"
|
|
>
|
|
{$notifications.inbox > 99 ? '∞' : $notifications.inbox}
|
|
</Badge>
|
|
{/if}
|
|
</span>
|
|
{/snippet}
|
|
</SidebarButton>
|
|
<SidebarButton icon={Bookmark} href="/saved">
|
|
{#snippet label()}
|
|
<span>{$t('profile.saved')}</span>
|
|
{/snippet}
|
|
</SidebarButton>
|
|
{:else}
|
|
<SidebarButton
|
|
href="/login"
|
|
title={$t('account.login')}
|
|
icon={ArrowLeftOnRectangle}
|
|
>
|
|
{#snippet label()}
|
|
<span>{$t('account.login')}</span>
|
|
{/snippet}
|
|
</SidebarButton>
|
|
<SidebarButton
|
|
href="/signup"
|
|
title={$t('account.signup')}
|
|
icon={Identification}
|
|
>
|
|
{#snippet label()}
|
|
<span>{$t('account.signup')}</span>
|
|
{/snippet}
|
|
</SidebarButton>
|
|
<SidebarButton
|
|
href="/settings"
|
|
title={$t('nav.menu.settings')}
|
|
icon={Cog6Tooth}
|
|
>
|
|
{#snippet label()}
|
|
<span>{$t('nav.menu.settings')}</span>
|
|
{/snippet}
|
|
</SidebarButton>
|
|
{/if}
|
|
{#if profileData.profiles.length >= 1}
|
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
|
|
|
<Expandable
|
|
class="max-w-full min-w-0 w-full"
|
|
bind:open={settings.expand.accounts}
|
|
>
|
|
{#snippet title()}
|
|
<span class="px-2 py-1 w-full">
|
|
<EndPlaceholder>
|
|
{$t('account.accounts')}
|
|
{#snippet action()}
|
|
<span class="dark:text-white text-black">
|
|
{profileData.profiles.length}
|
|
</span>
|
|
{/snippet}
|
|
</EndPlaceholder>
|
|
</span>
|
|
{/snippet}
|
|
<div class="w-full flex gap-px flex-col">
|
|
{#each [...profileData.profiles] as prof, index}
|
|
<div class="w-full">
|
|
<ProfileButton {index} {prof} />
|
|
</div>
|
|
{/each}
|
|
</div>
|
|
<SidebarButton href="/accounts" icon={UserGroup}>
|
|
{$t('account.accounts')}
|
|
</SidebarButton>
|
|
</Expandable>
|
|
{/if}
|
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
|
{#if profile.data?.favorites && profile.data?.favorites.length > 0}
|
|
<Expandable
|
|
class="max-w-full min-w-0 w-full"
|
|
bind:open={settings.expand.favorites}
|
|
>
|
|
{#snippet title()}
|
|
<span class="px-2 py-1 w-full">
|
|
<EndPlaceholder>
|
|
{$t('routes.profile.favorites')}
|
|
{#snippet action()}
|
|
<span class="dark:text-white text-black">
|
|
{profile.data.favorites?.length}
|
|
</span>
|
|
{/snippet}
|
|
</EndPlaceholder>
|
|
</span>
|
|
{/snippet}
|
|
<CommunityList isFavorites items={profile.data.favorites} />
|
|
</Expandable>
|
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
|
{/if}
|
|
{#if profile.data?.user}
|
|
{#if profile.data?.user.moderates.length > 0}
|
|
<Expandable
|
|
class="max-w-full min-w-0 w-full"
|
|
bind:open={settings.expand.moderates}
|
|
>
|
|
{#snippet title()}
|
|
<span class="px-2 py-1 w-full">
|
|
<EndPlaceholder>
|
|
{$t('routes.profile.moderates')}
|
|
{#snippet action()}
|
|
<span class="dark:text-white text-black">
|
|
{profile.data.user?.moderates.length}
|
|
</span>
|
|
{/snippet}
|
|
</EndPlaceholder>
|
|
</span>
|
|
{/snippet}
|
|
<CommunityList
|
|
items={profile.data.user.moderates.map(i => i.community)}
|
|
/>
|
|
</Expandable>
|
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
|
{/if}
|
|
|
|
<Expandable
|
|
class="max-w-full min-w-0 w-full"
|
|
bind:open={settings.expand.communities}
|
|
>
|
|
{#snippet title()}
|
|
<span class="px-2 py-1 w-full">
|
|
<EndPlaceholder>
|
|
{$t('profile.subscribed')}
|
|
{#snippet action()}
|
|
<span class="dark:text-white text-black">
|
|
{profile.data.user?.follows.length}
|
|
</span>
|
|
{/snippet}
|
|
</EndPlaceholder>
|
|
</span>
|
|
{/snippet}
|
|
<CommunityList items={profile.data.user.follows.map(i => i.community)} />
|
|
</Expandable>
|
|
{/if}
|
|
</nav>
|