misc: update sidebar

This commit is contained in:
Xylight committed 2024-04-13 15:37:55 -07:00
1 parent 79891ad2e2
commit 09d1e3ee6d
3 files changed
+39 -13

No files matched your search

@@ -43,7 +43,7 @@
{index} {index}
{guest} {guest}
selected={$profile?.id == prof.id} selected={$profile?.id == prof.id}
slot="prefix" slot="icon"
/> />
<span <span
class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-semibold' : ''}" class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-semibold' : ''}"
+27 -10
View File
@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { import {
ArrowLeftOnRectangle, ArrowLeftOnRectangle,
Bookmark,
ChevronDoubleRight, ChevronDoubleRight,
Cog6Tooth, Cog6Tooth,
GlobeAlt, GlobeAlt,
@@ -10,6 +11,7 @@
Inbox, Inbox,
MagnifyingGlass, MagnifyingGlass,
ServerStack, ServerStack,
UserCircle,
UserGroup, UserGroup,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { profile, profileData } from '$lib/auth.js' import { profile, profileData } from '$lib/auth.js'
@@ -23,8 +25,6 @@
import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js' import { DEFAULT_INSTANCE_URL, LINKED_INSTANCE_URL } from '$lib/instance.js'
import Expandable from '$lib/components/ui/Expandable.svelte' import Expandable from '$lib/components/ui/Expandable.svelte'
import EndPlaceholder from '../EndPlaceholder.svelte' import EndPlaceholder from '../EndPlaceholder.svelte'
export let route = ''
</script> </script>
<nav <nav
@@ -32,6 +32,23 @@
gap-1 h-screen {$$props.class}" gap-1 h-screen {$$props.class}"
style={$$props.style} style={$$props.style}
> >
{#if $profile}
<SidebarButton icon={UserCircle} href="/profile/user">
Profile
</SidebarButton>
<SidebarButton icon={Inbox} href="/inbox">
Inbox
{#if $profile?.user?.notifications.inbox}
<Badge
class="w-5 h-5 !p-0 grid place-items-center ml-auto"
color="red-subtle"
>
{$profile?.user?.notifications.inbox}
</Badge>
{/if}
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved">Saved</SidebarButton>
{/if}
{#if $profileData.profiles.length >= 1} {#if $profileData.profiles.length >= 1}
<hr class="border-slate-200 dark:border-zinc-900 my-1" /> <hr class="border-slate-200 dark:border-zinc-900 my-1" />
{#each [...$profileData.profiles] as prof, index (prof.id)} {#each [...$profileData.profiles] as prof, index (prof.id)}
@@ -48,8 +65,7 @@
}} }}
guest guest
/> />
<SidebarButton href="/accounts" selected={route == '/accounts'}> <SidebarButton href="/accounts" icon={UserGroup}>
<Icon src={UserGroup} mini={route == '/accounts'} size="20" />
<span slot="label">Accounts</span> <span slot="label">Accounts</span>
</SidebarButton> </SidebarButton>
{/if} {/if}
@@ -77,17 +93,18 @@
<CommunityList items={$profile.user.follows.map((i) => i.community)} /> <CommunityList items={$profile.user.follows.map((i) => i.community)} />
</Expandable> </Expandable>
{:else} {:else}
<SidebarButton href="/login" title="Log In"> <SidebarButton href="/login" title="Log In" icon={ArrowLeftOnRectangle}>
<Icon mini src={ArrowLeftOnRectangle} size="20" />
<span slot="label">Log In</span> <span slot="label">Log In</span>
</SidebarButton> </SidebarButton>
<SidebarButton href="/signup" title="Sign Up"> <SidebarButton href="/signup" title="Sign Up" icon={Identification}>
<Icon mini src={Identification} size="20" />
<span slot="label">Sign Up</span> <span slot="label">Sign Up</span>
</SidebarButton> </SidebarButton>
{#if LINKED_INSTANCE_URL === undefined} {#if LINKED_INSTANCE_URL === undefined}
<SidebarButton href="/accounts" title="Change Instance"> <SidebarButton
<Icon mini src={ServerStack} size="20" /> href="/accounts"
title="Change Instance"
icon={ServerStack}
>
<span slot="label">Change Instance</span> <span slot="label">Change Instance</span>
</SidebarButton> </SidebarButton>
{/if} {/if}
@@ -1,12 +1,17 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores'
import { userSettings } from '$lib/settings.js' import { userSettings } from '$lib/settings.js'
import { Button } from 'mono-svelte' import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
export let selected: boolean = false export let href: string | undefined = undefined
export let icon: IconSource | undefined = undefined
$: selected = href != undefined && $page.url.pathname == href
</script> </script>
<Button <Button
{...$$restProps} {...$$restProps}
{href}
color="tertiary" color="tertiary"
alignment="left" alignment="left"
on:click on:click
@@ -16,7 +21,11 @@
? '' ? ''
: 'max-lg:!p-1 [&>*]:max-lg:!justify-center'} {$$props.class}" : 'max-lg:!p-1 [&>*]:max-lg:!justify-center'} {$$props.class}"
> >
<slot name="prefix" slot="prefix" /> {#if icon}
<Icon src={icon} solid={selected} size="20" />
{:else}
<slot {selected} name="icon" />
{/if}
<slot /> <slot />
<div class={$userSettings.expandSidebar ? 'contents' : 'max-lg:hidden'}> <div class={$userSettings.expandSidebar ? 'contents' : 'max-lg:hidden'}>
<slot name="label" /> <slot name="label" />