feat: add placeholder component
This commit is contained in:
1 parent
92dfd91c23
commit
5c04bdb677
8 files changed
+48
-50
No files matched your search
+12
-36
@@ -15,6 +15,8 @@
|
||||
import Sort from '$lib/components/lemmy/Sort.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -49,48 +51,22 @@
|
||||
options={['Subscribed', 'Local', 'All']}
|
||||
disabled={[$profile?.jwt == undefined]}
|
||||
selected={data.listingType}
|
||||
on:select={(e) => {
|
||||
$page.url.searchParams.set('type', e.detail)
|
||||
$page.url.searchParams.delete('page')
|
||||
goto($page.url.toString(), {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
|
||||
/>
|
||||
<Sort selected={data.sort} />
|
||||
</div>
|
||||
<section class="flex flex-col gap-4">
|
||||
{#if data.posts.posts.length == 0}
|
||||
<div
|
||||
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center"
|
||||
>
|
||||
<Icon src={ArchiveBox} size="32" solid />
|
||||
<h1 class="font-bold text-2xl">No posts</h1>
|
||||
{#if data.listingType == 'Subscribed'}
|
||||
<Button href="/communities" class="mt-4">
|
||||
<Icon src={Plus} size="16" mini slot="icon" />
|
||||
<span>Follow some communities</span>
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
<Placeholder>
|
||||
<Icon src={ArchiveBox} size="32" solid slot="icon" />
|
||||
<span slot="title">No posts</span>
|
||||
<Button href="/communities" class="mt-4" slot="action">
|
||||
<Icon src={Plus} size="16" mini slot="icon" />
|
||||
<span>Follow some communities</span>
|
||||
</Button>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
{#each data.posts.posts as post, index (post.post.id)}
|
||||
{#if
|
||||
!($userSettings.hidePosts.deleted && post.post.deleted) &&
|
||||
!($userSettings.hidePosts.removed && post.post.removed)
|
||||
}
|
||||
<div
|
||||
in:fly={{
|
||||
y: -8,
|
||||
duration: 500,
|
||||
opacity: 0,
|
||||
delay: index < 4 ? index * 100 : 0,
|
||||
}}
|
||||
>
|
||||
<Post {post} />
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
<PostFeed posts={data.posts.posts} />
|
||||
</section>
|
||||
<Pageination
|
||||
page={data.page}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { instance } from '$lib/lemmy.js'
|
||||
import { instance } from '$lib/instance.js'
|
||||
import { error, redirect } from '@sveltejs/kit'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
buildCommentsTree,
|
||||
buildCommentsTreeAsync,
|
||||
} from '$lib/components/lemmy/comment/comments.js'
|
||||
import { buildCommentsTreeAsync } from '$lib/components/lemmy/comment/comments.js'
|
||||
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
||||
import { isImage, isVideo } from '$lib/ui/image.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
@@ -13,7 +10,6 @@
|
||||
import { page } from '$app/stores'
|
||||
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
||||
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||
|
||||
Reference in new issue
Block a user