feat: add placeholder component
This commit is contained in:
1 parent
92dfd91c23
commit
5c04bdb677
8 files changed
+48
-50
No files matched your search
@@ -15,7 +15,7 @@
|
|||||||
export let hideCommunity = false
|
export let hideCommunity = false
|
||||||
</script>
|
</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-row w-full gap-2.5">
|
||||||
<div class="flex flex-col gap-1.5 grow">
|
<div class="flex flex-col gap-1.5 grow">
|
||||||
<PostMeta
|
<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}
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<div
|
<div
|
||||||
class="bg-white break-words
|
class="bg-white break-words
|
||||||
{getColor(cardColor)} rounded-md {clazz}"
|
{getColor(cardColor)} rounded-md {clazz}"
|
||||||
|
{...$$restProps}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
@@ -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
@@ -1,11 +1,5 @@
|
|||||||
import {
|
import { type GetSiteResponse, LemmyHttp } from 'lemmy-js-client'
|
||||||
type GetSiteResponse,
|
|
||||||
LemmyHttp,
|
|
||||||
type MyUserInfo,
|
|
||||||
type PersonView,
|
|
||||||
} from 'lemmy-js-client'
|
|
||||||
import { get, writable } from 'svelte/store'
|
import { get, writable } from 'svelte/store'
|
||||||
import { env } from '$env/dynamic/public'
|
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||||
|
|||||||
+12
-36
@@ -15,6 +15,8 @@
|
|||||||
import Sort from '$lib/components/lemmy/Sort.svelte'
|
import Sort from '$lib/components/lemmy/Sort.svelte'
|
||||||
import { searchParam } from '$lib/util.js'
|
import { searchParam } from '$lib/util.js'
|
||||||
import { userSettings } from '$lib/settings.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
|
export let data
|
||||||
|
|
||||||
@@ -49,48 +51,22 @@
|
|||||||
options={['Subscribed', 'Local', 'All']}
|
options={['Subscribed', 'Local', 'All']}
|
||||||
disabled={[$profile?.jwt == undefined]}
|
disabled={[$profile?.jwt == undefined]}
|
||||||
selected={data.listingType}
|
selected={data.listingType}
|
||||||
on:select={(e) => {
|
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
|
||||||
$page.url.searchParams.set('type', e.detail)
|
|
||||||
$page.url.searchParams.delete('page')
|
|
||||||
goto($page.url.toString(), {
|
|
||||||
invalidateAll: true,
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Sort selected={data.sort} />
|
<Sort selected={data.sort} />
|
||||||
</div>
|
</div>
|
||||||
<section class="flex flex-col gap-4">
|
<section class="flex flex-col gap-4">
|
||||||
{#if data.posts.posts.length == 0}
|
{#if data.posts.posts.length == 0}
|
||||||
<div
|
<Placeholder>
|
||||||
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center"
|
<Icon src={ArchiveBox} size="32" solid slot="icon" />
|
||||||
>
|
<span slot="title">No posts</span>
|
||||||
<Icon src={ArchiveBox} size="32" solid />
|
<Button href="/communities" class="mt-4" slot="action">
|
||||||
<h1 class="font-bold text-2xl">No posts</h1>
|
<Icon src={Plus} size="16" mini slot="icon" />
|
||||||
{#if data.listingType == 'Subscribed'}
|
<span>Follow some communities</span>
|
||||||
<Button href="/communities" class="mt-4">
|
</Button>
|
||||||
<Icon src={Plus} size="16" mini slot="icon" />
|
</Placeholder>
|
||||||
<span>Follow some communities</span>
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#each data.posts.posts as post, index (post.post.id)}
|
<PostFeed posts={data.posts.posts} />
|
||||||
{#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}
|
|
||||||
</section>
|
</section>
|
||||||
<Pageination
|
<Pageination
|
||||||
page={data.page}
|
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 { error, redirect } from '@sveltejs/kit'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import { buildCommentsTreeAsync } from '$lib/components/lemmy/comment/comments.js'
|
||||||
buildCommentsTree,
|
|
||||||
buildCommentsTreeAsync,
|
|
||||||
} from '$lib/components/lemmy/comment/comments.js'
|
|
||||||
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
||||||
import { isImage, isVideo } from '$lib/ui/image.js'
|
import { isImage, isVideo } from '$lib/ui/image.js'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
@@ -13,7 +10,6 @@
|
|||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
||||||
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
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 Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||||
import Card from '$lib/components/ui/Card.svelte'
|
import Card from '$lib/components/ui/Card.svelte'
|
||||||
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
|
||||||
|
|||||||
Reference in new issue
Block a user