feat: add placeholder component

This commit is contained in:
Xyphyn committed 2023-08-05 12:48:15 -07:00
1 parent 92dfd91c23
commit 5c04bdb677
8 files changed
+48 -50

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@
export let hideCommunity = false
</script>
<Card class="bg-white flex flex-col w-full p-5 gap-2.5">
<Card class="bg-white flex flex-col w-full p-5 gap-2.5" id={post.post.id}>
<div class="flex flex-row w-full gap-2.5">
<div class="flex flex-col gap-1.5 grow">
<PostMeta
@@ -0,0 +1,23 @@
<script lang="ts">
import Post from '$lib/components/lemmy/post/Post.svelte'
import { userSettings } from '$lib/settings.js'
import type { PostView } from 'lemmy-js-client'
import { fly } from 'svelte/transition'
export let posts: PostView[]
</script>
{#each 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}
+1
View File
@@ -18,6 +18,7 @@
<div
class="bg-white break-words
{getColor(cardColor)} rounded-md {clazz}"
{...$$restProps}
>
<slot />
</div>
+8
View File
@@ -0,0 +1,8 @@
<div
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center"
>
<slot name="icon" />
{#if $$slots.title}
<h1 class="font-bold text-2xl"><slot name="title" /></h1>{/if}
<slot name="action" />
</div>
+1 -7
View File
@@ -1,11 +1,5 @@
import {
type GetSiteResponse,
LemmyHttp,
type MyUserInfo,
type PersonView,
} from 'lemmy-js-client'
import { type GetSiteResponse, LemmyHttp } from 'lemmy-js-client'
import { get, writable } from 'svelte/store'
import { env } from '$env/dynamic/public'
import { profile } from '$lib/auth.js'
import { error } from '@sveltejs/kit'
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
+12 -36
View File
@@ -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 -1
View File
@@ -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'