feat: change the way placeholders work

This commit is contained in:
Xyphyn committed 2023-08-26 10:59:19 -07:00
1 parent 8aa62b046e
commit e86d436c86
12 files changed
+121 -96

No files matched your search

+8 -2
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import Spinner from '$lib/components/ui/loader/Spinner.svelte' import Spinner from '$lib/components/ui/loader/Spinner.svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
type ButtonColor = keyof typeof buttonColor type ButtonColor = keyof typeof buttonColor
type ButtonSize = keyof typeof buttonSize type ButtonSize = keyof typeof buttonSize
@@ -66,6 +67,7 @@
export let size: ButtonSize = 'md' export let size: ButtonSize = 'md'
export let rounded: ButtonRoundness = 'md' export let rounded: ButtonRoundness = 'md'
export let alignment: ButtonAlignment = 'center' export let alignment: ButtonAlignment = 'center'
export let icon: IconSource | undefined = undefined
export let loaderWidth: number | undefined = undefined export let loaderWidth: number | undefined = undefined
@@ -108,8 +110,10 @@
? 16 ? 16
: 16} : 16}
/> />
{:else} {:else if $$slots.icon}
<slot name="icon" /> <slot name="icon" />
{:else if icon}
<Icon src={icon} size="16" mini />
{/if} {/if}
<slot /> <slot />
</div> </div>
@@ -148,8 +152,10 @@
? 16 ? 16
: 16} : 16}
/> />
{:else} {:else if $$slots.icon}
<slot name="icon" /> <slot name="icon" />
{:else if icon}
<Icon src={icon} size="16" mini />
{/if} {/if}
<slot /> <slot />
</div> </div>
@@ -12,10 +12,12 @@
{#if posts.length == 0} {#if posts.length == 0}
<div class="h-full grid place-items-center"> <div class="h-full grid place-items-center">
<Placeholder> <Placeholder
<Icon src={ArchiveBox} size="32" solid slot="icon" /> icon={ArchiveBox}
<span slot="title">No posts</span> title="No posts"
<Button href="/communities" class="mt-4" slot="action"> description="There are no posts that match this filter."
>
<Button href="/communities">
<Icon src={Plus} size="16" mini slot="icon" /> <Icon src={Plus} size="16" mini slot="icon" />
<span>Follow some communities</span> <span>Follow some communities</span>
</Button> </Button>
@@ -24,6 +24,7 @@
export let label: string | undefined = undefined export let label: string | undefined = undefined
export let previewButton: boolean = false export let previewButton: boolean = false
export let disabled: boolean = false export let disabled: boolean = false
export let rows: number = 4
export let beforePreview: (input: string) => string = (input) => input export let beforePreview: (input: string) => string = (input) => input
@@ -241,6 +242,7 @@ overflow-hidden focus-within:border-black focus-within:dark:border-white transit
} }
} }
}} }}
{rows}
{...$$restProps} {...$$restProps}
/> />
{/if} {/if}
+22 -11
View File
@@ -1,18 +1,29 @@
<script lang="ts">
import { Icon, type IconSource } from 'svelte-hero-icons'
export let icon: IconSource | undefined = undefined
export let title: string
export let description: string | undefined = undefined
</script>
<div <div
class="text-slate-600 dark:text-zinc-400 flex flex-col justify-center items-center gap-1" class="text-slate-700 dark:text-zinc-300 flex flex-col justify-center items-center gap-2"
> >
{#if $$slots.icon} {#if icon}
<div <div
class="bg-slate-100 border border-slate-200 dark:border-zinc-700 dark:bg-zinc-800 p-3 rounded-full" class="border border-slate-200 dark:border-zinc-700 dark:bg-zinc-800 p-3 rounded-full"
> >
<slot name="icon" /> <Icon src={icon} size="28" />
</div> </div>
{/if} {/if}
{#if $$slots.title} <div class="flex flex-col gap-1 text-center">
<h1 class="font-bold text-lg"><slot name="title" /></h1> <h1 class="text-slate-900 dark:text-zinc-100 text-lg font-medium">
{/if} {title}
{#if $$slots.description} </h1>
<p class="text-sm text-center"><slot name="description" /></p> {#if description}
{/if} <p class="text-sm text-center font-normal">{description}</p>
<slot name="action" /> {/if}
</div>
<slot />
</div> </div>
+5 -4
View File
@@ -38,8 +38,9 @@
</div> </div>
{/if} {/if}
{:else} {:else}
<Placeholder> <Placeholder
<Icon src={ClipboardDocumentCheck} size="28" slot="icon" /> icon={ClipboardDocumentCheck}
<span slot="title">No new applications</span> title="No new applications"
</Placeholder> description="Applications to join your instance will appear here."
/>
{/if} {/if}
+6 -4
View File
@@ -103,10 +103,12 @@
</form> </form>
{:else} {:else}
<div class="my-auto"> <div class="my-auto">
<Placeholder> <Placeholder
<Icon src={Plus} solid size="28" slot="icon" /> icon={Plus}
<span slot="title">No taglines</span> title="No taglines"
<div slot="action" class="mt-4 max-w-xl w-full flex flex-col gap-2"> description="A random tagline will appear when users visit your instance."
>
<div class="mt-4 max-w-xl w-full flex flex-col gap-2">
<form <form
class="flex flex-col gap-2 w-full" class="flex flex-col gap-2 w-full"
on:submit|preventDefault={() => { on:submit|preventDefault={() => {
+7 -10
View File
@@ -17,6 +17,7 @@
import { profile } from '$lib/auth.js' import { profile } from '$lib/auth.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { fly } from 'svelte/transition' import { fly } from 'svelte/transition'
import { searchParam } from '$lib/util.js'
export let data export let data
@@ -92,10 +93,11 @@
<div class="flex flex-col gap-4 list-none my-4 flex-1"> <div class="flex flex-col gap-4 list-none my-4 flex-1">
{#if !data.data || (data.data?.length ?? 0) == 0} {#if !data.data || (data.data?.length ?? 0) == 0}
<div class="mt-auto"> <div class="mt-auto">
<Placeholder> <Placeholder
<Icon src={Inbox} size="28" slot="icon" /> icon={Inbox}
<span slot="title">No new notifications</span> title="No new notifications"
</Placeholder> description="Messages, replies, and mentions will appear here."
/>
</div> </div>
{:else} {:else}
{#each data.data as item} {#each data.data as item}
@@ -105,12 +107,7 @@
{/each} {/each}
<Pageination <Pageination
page={data.page} page={data.page}
on:change={(p) => { on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
$page.url.searchParams.set('page', p.detail.toString())
goto($page.url.toString(), {
invalidateAll: true,
})
}}
/> />
{/if} {/if}
</div> </div>
+5 -4
View File
@@ -51,8 +51,9 @@
{/each} {/each}
</div> </div>
{:else} {:else}
<Placeholder> <Placeholder
<Icon src={Inbox} size="28" slot="icon" /> icon={Inbox}
<span slot="title">No new reports</span> title="No new reports"
</Placeholder> description="When submissions are reported, you can act on them here."
/>
{/if} {/if}
@@ -77,14 +77,12 @@
</EditableList> </EditableList>
</div> </div>
{:else} {:else}
<Placeholder> <Placeholder
<Icon src={Check} size="48" slot="icon" /> description="Go to a user's profile and click 'block' to stop seeing posts and
<span slot="title">No user blocks</span> comments from them."
<p slot="description"> title="No user blocks"
Go to a user's profile and click "block" to stop seeing posts and icon={Check}
comments from them. />
</p>
</Placeholder>
{/if} {/if}
{#if data.community_blocks.length > 0} {#if data.community_blocks.length > 0}
@@ -106,23 +104,19 @@
</EditableList> </EditableList>
</div> </div>
{:else} {:else}
<Placeholder> <Placeholder
<Icon src={Check} size="48" slot="icon" /> description="Go to a community's page and click 'block' to stop seeing posts and
<span slot="title">No community blocks</span> comments from it."
<p slot="description"> title="No community blocks"
Go to a community's page and click "block" to stop seeing submissions icon={Check}
from it. />
</p>
</Placeholder>
{/if} {/if}
{:else} {:else}
<div class="my-auto"> <div class="my-auto">
<Placeholder> <Placeholder
<Icon src={Check} size="48" slot="icon" /> description="Go to a community or user's page to stop seeing submissions from it."
<span slot="title">No blocks</span> title="No blocks"
<p slot="description"> icon={Check}
Go to a community or user's page to stop seeing submissions from it. />
</p>
</Placeholder>
</div> </div>
{/if} {/if}
+5 -4
View File
@@ -65,10 +65,11 @@
</div> </div>
</div> </div>
{#if !data.results} {#if !data.results}
<Placeholder> <Placeholder
<Icon src={MagnifyingGlass} size="28" solid slot="icon" /> icon={MagnifyingGlass}
<span slot="title">No results</span> title="No results"
</Placeholder> description="Search across the fediverse"
/>
{:else} {:else}
{#await data.streamed.object} {#await data.streamed.object}
<div <div
+17 -4
View File
@@ -8,6 +8,7 @@
import Markdown from '$lib/components/markdown/Markdown.svelte' import Markdown from '$lib/components/markdown/Markdown.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import Card from '$lib/components/ui/Card.svelte' import Card from '$lib/components/ui/Card.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import Spinner from '$lib/components/ui/loader/Spinner.svelte' import Spinner from '$lib/components/ui/loader/Spinner.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js' import { toast } from '$lib/components/ui/toasts/toasts.js'
import { getClient } from '$lib/lemmy.js' import { getClient } from '$lib/lemmy.js'
@@ -17,7 +18,9 @@
ExclamationCircle, ExclamationCircle,
ExclamationTriangle, ExclamationTriangle,
Icon, Icon,
Plus,
QuestionMarkCircle, QuestionMarkCircle,
XCircle,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
export let data export let data
@@ -102,10 +105,8 @@
{data.site_view.site.name} {data.site_view.site.name}
</span> </span>
<h1 class="font-bold text-3xl">Create account</h1> {#if data.site_view.local_site.registration_mode != 'Closed'}
{#if data.site_view.local_site.registration_mode == 'Closed'} <h1 class="font-bold text-3xl">Create account</h1>
<p class="mx-auto text-left">Registrations are closed for this instance.</p>
{:else}
<TextInput <TextInput
bind:value={email} bind:value={email}
label="Email" label="Email"
@@ -198,5 +199,17 @@
> >
Submit Submit
</Button> </Button>
{:else}
<div class="my-auto">
<Placeholder
icon={XCircle}
title="Registrations closed"
description="New account creation has been disabled on this instance."
>
<Button icon={Plus} href="https://join-lemmy.org">
Find another instance
</Button>
</Placeholder>
</div>
{/if} {/if}
</form> </form>
+21 -26
View File
@@ -33,6 +33,8 @@
import Menu from '$lib/components/ui/menu/Menu.svelte' import Menu from '$lib/components/ui/menu/Menu.svelte'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte' import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte' import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
import { searchParam } from '$lib/util.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
export let data export let data
@@ -123,7 +125,7 @@
bind:value={message} bind:value={message}
label="Message" label="Message"
placeholder="your hair looks nice today" placeholder="your hair looks nice today"
rows={3} rows={4}
/> />
<Button <Button
color="primary" color="primary"
@@ -145,40 +147,33 @@
options={['New', 'TopAll', 'Old']} options={['New', 'TopAll', 'Old']}
optionNames={['New', 'Top', 'Old']} optionNames={['New', 'Top', 'Old']}
selected={data.sort} selected={data.sort}
on:select={(e) => { on:select={(e) => searchParam($page.url, 'sort', e.detail, 'page')}
$page.url.searchParams.set('sort', e.detail)
goto($page.url.toString(), {
invalidateAll: true,
})
}}
/> />
<MultiSelect <MultiSelect
options={['all', 'posts', 'comments']} options={['all', 'posts', 'comments']}
optionNames={['All', 'Posts', 'Comments']} optionNames={['All', 'Posts', 'Comments']}
selected={data.type} selected={data.type}
on:select={(e) => { on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
$page.url.searchParams.set('type', e.detail)
goto($page.url.toString(), {
invalidateAll: true,
})
}}
/> />
</div> </div>
{#each data.items as item (item.counts.id)} {#if data.items.length == 0}
{#if isCommentView(item) && (data.type == 'all' || data.type == 'comments')} <Placeholder
<CommentItem comment={item} /> icon={PencilSquare}
{:else if !isCommentView(item) && (data.type == 'all' || data.type == 'posts')} title="No submissions"
<Post post={item} /> description="This user has no descriptions that match this filter."
{/if} />
{/each} {:else}
{#each data.items as item (item.counts.id)}
{#if isCommentView(item) && (data.type == 'all' || data.type == 'comments')}
<CommentItem comment={item} />
{:else if !isCommentView(item) && (data.type == 'all' || data.type == 'posts')}
<Post post={item} />
{/if}
{/each}
{/if}
<Pageination <Pageination
page={data.page} page={data.page}
on:change={(p) => { on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
$page.url.searchParams.set('page', p.detail.toString())
goto($page.url.toString(), {
invalidateAll: true,
})
}}
/> />
</div> </div>