misc: add buttons for 0 communities

This commit is contained in:
Xyphyn committed 2023-07-31 13:21:33 -07:00
1 parent b4bcadf40d
commit 13a4b06e41
6 files changed
+69 -46

No files matched your search

@@ -7,7 +7,7 @@
import { ToastType, addToast } from '$lib/components/ui/toasts/toasts.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { authData, getClient } from '$lib/lemmy.js'
import { authData, getClient, user } from '$lib/lemmy.js'
import { Color } from '$lib/ui/colors.js'
import type { CommunityView } from 'lemmy-js-client'
import {
+55 -3
View File
@@ -1,12 +1,20 @@
<script lang="ts">
import { ChevronDoubleLeft, Icon } from 'svelte-hero-icons'
import {
ArrowLeftOnRectangle,
ChevronDoubleLeft,
Home,
Icon,
Plus,
} from 'svelte-hero-icons'
import Button from '../input/Button.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { user } from '$lib/lemmy.js'
let expanded = true
</script>
<nav
class="hidden xl:flex flex-col pl-4 pr-4 py-4 overflow-auto sticky top-16 bottom-0
class="hidden lg:flex flex-col pl-4 pr-4 py-4 overflow-auto sticky top-16 bottom-0
gap-1 max-h-[calc(100vh-4rem)] w-full bg-slate-100 dark:bg-black"
class:flex-1={expanded}
class:w-max={!expanded}
@@ -22,5 +30,49 @@
class="transition-transform {expanded ? '' : 'rotate-180'}"
/>
</Button>
<slot {expanded} />
<Button
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
href="/"
color="tertiary"
alignment="left"
>
<Icon src={Home} solid size="20" />
<span class:hidden={!expanded}>Frontpage</span>
</Button>
{#if $user}
{#each $user.follows
.map((f) => f.community)
.sort((a, b) => a.title.localeCompare(b.title)) as follow}
<Button
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
color="tertiary"
alignment="left"
href="/c/{follow.name}@{new URL(follow.actor_id).hostname}"
>
<Avatar url={follow.icon} alt={follow.name} width={20} slot="icon" />
<span class:hidden={!expanded}>{follow.title}</span>
</Button>
{/each}
{#if $user.follows.length == 0}
<Button
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
href="/communities"
color="tertiary"
alignment="left"
>
<Icon src={Plus} solid size="20" />
<span class:hidden={!expanded}>Add communities</span>
</Button>
{/if}
{:else}
<Button
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
href="/login"
color="tertiary"
alignment="left"
>
<Icon src={ArrowLeftOnRectangle} solid size="20" />
<span class:hidden={!expanded}>Log in</span>
</Button>
{/if}
</nav>
+6 -1
View File
@@ -1,4 +1,9 @@
import { LemmyHttp, type MyUserInfo, type PersonView } from 'lemmy-js-client'
import {
type GetSiteResponse,
LemmyHttp,
type MyUserInfo,
type PersonView,
} from 'lemmy-js-client'
import { get, writable } from 'svelte/store'
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
import { userSettings } from '$lib/settings.js'