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'
+5 -39
View File
@@ -6,10 +6,6 @@
import 'nprogress/nprogress.css'
import ToastContainer from '$lib/components/ui/toasts/ToastContainer.svelte'
import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
import { user } from '$lib/lemmy.js'
import Button from '$lib/components/input/Button.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { Home, Icon } from 'svelte-hero-icons'
import Sidebar from '$lib/components/ui/Sidebar.svelte'
nProgress.configure({
@@ -34,47 +30,17 @@
}
</script>
<div class="flex flex-col">
<div class="flex flex-col min-h-screen">
<Navbar />
<ToastContainer />
<Moderation />
<div
class="flex flex-row w-full max-w-full lg:divide-x dark:divide-zinc-800
divide-slate-200"
class="flex flex-row h-full w-full max-w-full lg:divide-x dark:divide-zinc-800
divide-slate-200 flex-1"
>
<Sidebar let: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}
</Sidebar>
<Sidebar />
<main
class="p-3 lg:p-6 min-w-0 w-full flex-[3] xl:rounded-tl-lg
class="p-3 lg:p-6 min-w-0 w-full flex-[3] lg:rounded-tl-lg
border-slate-200 dark:border-zinc-900 border-t"
>
<slot />
+1 -1
View File
@@ -93,7 +93,7 @@
}}
/>
</div>
<aside class="hidden md:block">
<aside class="hidden 2xl:block">
{#await data.streamed.site}
<StickyCard>
<div class="h-64 grid place-items-center">
+1 -1
View File
@@ -67,7 +67,7 @@
</svelte:head>
<Card class="p-6 max-w-lg w-full mx-auto">
<form on:submit|preventDefault={logIn} class="flex flex-col gap-4">
<form on:submit|preventDefault={logIn} class="flex flex-col gap-6">
<h1 class="font-bold text-2xl">Log in</h1>
<div class="flex flex-row w-full items-center gap-2">
<TextInput