feat: add loading animation to search/community pages
This commit is contained in:
9 files changed
+169
-253
No files matched your search
@@ -172,8 +172,6 @@ $effect.root(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$effect(() => {})
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (profile.data.id || profileData) fetchUserData(profile).then((res) => {})
|
if (profile.data.id || profileData) fetchUserData(profile).then((res) => {})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,10 +5,14 @@
|
|||||||
import {
|
import {
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
Check,
|
Check,
|
||||||
|
ExclamationTriangle,
|
||||||
Icon,
|
Icon,
|
||||||
InformationCircle,
|
InformationCircle,
|
||||||
|
MapPin,
|
||||||
|
NoSymbol,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
Plus,
|
Plus,
|
||||||
|
Trash,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
@@ -78,7 +82,43 @@
|
|||||||
class="flex flex-col overflow-hidden whitespace-nowrap flex-1 min-w-0 flex-shrink"
|
class="flex flex-col overflow-hidden whitespace-nowrap flex-1 min-w-0 flex-shrink"
|
||||||
>
|
>
|
||||||
<div class="font-medium text-base overflow-hidden overflow-ellipsis">
|
<div class="font-medium text-base overflow-hidden overflow-ellipsis">
|
||||||
{community.community.title}
|
<span>{community.community.title}</span>
|
||||||
|
{#if community.community.deleted}
|
||||||
|
<Icon
|
||||||
|
src={Trash}
|
||||||
|
class="text-red-500"
|
||||||
|
micro
|
||||||
|
size="14"
|
||||||
|
title={$t('post.badges.deleted')}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{#if community.community.nsfw}
|
||||||
|
<Icon
|
||||||
|
src={ExclamationTriangle}
|
||||||
|
class="text-red-500"
|
||||||
|
micro
|
||||||
|
size="14"
|
||||||
|
title={$t('post.badges.nsfw')}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{#if community.banned_from_community}
|
||||||
|
<Icon
|
||||||
|
src={NoSymbol}
|
||||||
|
class="text-red-500"
|
||||||
|
micro
|
||||||
|
size="14"
|
||||||
|
title={$t('comment.banned')}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{#if community.community.visibility == 'LocalOnly'}
|
||||||
|
<Icon
|
||||||
|
src={MapPin}
|
||||||
|
class="text-green-500"
|
||||||
|
micro
|
||||||
|
size="14"
|
||||||
|
title={$t('routes.admin.config.listingType.local')}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="text-sm text-slate-600 dark:text-zinc-400 flex gap-0.5"
|
class="text-sm text-slate-600 dark:text-zinc-400 flex gap-0.5"
|
||||||
|
|||||||
@@ -47,11 +47,9 @@
|
|||||||
Spinner,
|
Spinner,
|
||||||
toast,
|
toast,
|
||||||
} from 'mono-svelte'
|
} from 'mono-svelte'
|
||||||
import { fediseer, type Data } from '$lib/fediseer/fediseer'
|
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { hidePost, postLink } from './helpers'
|
import { hidePost, postLink } from './helpers'
|
||||||
import { feature } from '$lib/version'
|
import { feature } from '$lib/version'
|
||||||
import Switch from '$lib/components/input/Switch.svelte'
|
|
||||||
import { instanceId, instanceToURL } from '$lib/util.svelte'
|
import { instanceId, instanceToURL } from '$lib/util.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<div class="skeleton animate-pulse flex flex-col gap-2 w-full">
|
||||||
|
<div
|
||||||
|
class="w-2/3 h-6 bg-slate-300 dark:bg-zinc-700 animate-pulse rounded-md"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="w-full h-20 bg-slate-300 dark:bg-zinc-700 animate-pulse rounded-md"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="w-32 h-6 bg-slate-300 dark:bg-zinc-700 animate-pulse rounded-md"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { Badge, Modal } from 'mono-svelte'
|
|
||||||
import type { Data } from './fediseer'
|
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
open?: boolean
|
|
||||||
data: Data
|
|
||||||
}
|
|
||||||
|
|
||||||
let { open = $bindable(false), data }: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal bind:open title="Fediseer">
|
|
||||||
<div
|
|
||||||
class="flex flex-col [&>*]:py-2 divide-y divide-slate-300 dark:divide-zinc-800"
|
|
||||||
>
|
|
||||||
<Expandable class="flex flex-col gap-4">
|
|
||||||
{#snippet title()}
|
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row">
|
|
||||||
Endorsements <Badge class="w-max h-max" color="green-subtle">
|
|
||||||
{data.endorsements.instances.length}
|
|
||||||
</Badge>
|
|
||||||
</SectionTitle>
|
|
||||||
{/snippet}
|
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
|
||||||
{#each data.endorsements.instances as instance}
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<LabelStat
|
|
||||||
labelClass="!text-sm"
|
|
||||||
label={instance.domain}
|
|
||||||
formatted={false}
|
|
||||||
content={instance.endorsement_reasons?.[0] || '👍'}
|
|
||||||
></LabelStat>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</Expandable>
|
|
||||||
<Expandable class="flex flex-col gap-4">
|
|
||||||
{#snippet title()}
|
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row">
|
|
||||||
Guarantees <Badge class="w-max h-max" color="green-subtle">
|
|
||||||
{data.guarantees.instances.length}
|
|
||||||
</Badge>
|
|
||||||
</SectionTitle>
|
|
||||||
{/snippet}
|
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
|
||||||
{#each data.guarantees.instances as instance}
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<LabelStat
|
|
||||||
labelClass="!text-sm"
|
|
||||||
label={instance.domain}
|
|
||||||
formatted={false}
|
|
||||||
content={instance.guarantee_reasons?.[0] || '👍'}
|
|
||||||
></LabelStat>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</Expandable>
|
|
||||||
<Expandable class="flex flex-col gap-4">
|
|
||||||
{#snippet title()}
|
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row">
|
|
||||||
Censures <Badge class="w-max h-max" color="red-subtle">
|
|
||||||
{data.censures.instances.length}
|
|
||||||
</Badge>
|
|
||||||
</SectionTitle>
|
|
||||||
{/snippet}
|
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
|
||||||
{#each data.censures.instances as instance}
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<LabelStat
|
|
||||||
labelClass="!text-sm"
|
|
||||||
label={instance.domain}
|
|
||||||
formatted={false}
|
|
||||||
content={instance.censure_reasons?.[0] || '👎'}
|
|
||||||
></LabelStat>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</Expandable>
|
|
||||||
<Expandable class="flex flex-col gap-4">
|
|
||||||
{#snippet title()}
|
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row">
|
|
||||||
Hesitations <Badge class="w-max h-max" color="red-subtle">
|
|
||||||
{data.hesitations.instances.length}
|
|
||||||
</Badge>
|
|
||||||
</SectionTitle>
|
|
||||||
{/snippet}
|
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
|
||||||
{#each data.hesitations.instances as instance}
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<LabelStat
|
|
||||||
labelClass="!text-sm"
|
|
||||||
label={instance.domain}
|
|
||||||
formatted={false}
|
|
||||||
content={instance.hesitation_reasons?.[0] || '👎'}
|
|
||||||
></LabelStat>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</Expandable>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
export interface Endorsements {
|
|
||||||
instances: {
|
|
||||||
domain: string
|
|
||||||
endorsement_reasons: string[]
|
|
||||||
}[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Hesitations {
|
|
||||||
instances: {
|
|
||||||
domain: string
|
|
||||||
hesitation_reasons: string[]
|
|
||||||
}[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Censures {
|
|
||||||
instances: {
|
|
||||||
domain: string
|
|
||||||
censure_reasons: string[]
|
|
||||||
}[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Guarantees {
|
|
||||||
instances: {
|
|
||||||
domain: string
|
|
||||||
guarantee_reasons: string[]
|
|
||||||
}[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Data {
|
|
||||||
endorsements: Endorsements
|
|
||||||
hesitations: Hesitations
|
|
||||||
guarantees: Guarantees
|
|
||||||
censures: Censures
|
|
||||||
}
|
|
||||||
|
|
||||||
class Fediseer {
|
|
||||||
url: string
|
|
||||||
|
|
||||||
constructor(url: string) {
|
|
||||||
this.url = url
|
|
||||||
}
|
|
||||||
|
|
||||||
async getInstanceInfo(domain: string): Promise<Data> {
|
|
||||||
const [endorsements, hesitations, guarantees, censures] = await Promise.all(
|
|
||||||
[
|
|
||||||
fetch(`${this.url}/v1/endorsements/${domain}`).then((r) =>
|
|
||||||
r.json(),
|
|
||||||
) as Promise<Endorsements>,
|
|
||||||
fetch(`${this.url}/v1/hesitations/${domain}`).then((r) =>
|
|
||||||
r.json(),
|
|
||||||
) as Promise<Hesitations>,
|
|
||||||
fetch(`${this.url}/v1/guarantees/${domain}`).then((r) =>
|
|
||||||
r.json(),
|
|
||||||
) as Promise<Guarantees>,
|
|
||||||
fetch(`${this.url}/v1/censures/${domain}`).then((r) =>
|
|
||||||
r.json(),
|
|
||||||
) as Promise<Censures>,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
return { endorsements, hesitations, guarantees, censures }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const fediseer = new Fediseer('https://fediseer.com/api')
|
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import { backOut, expoOut } from 'svelte/easing'
|
import { backOut, expoOut } from 'svelte/easing'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
|
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
@@ -107,77 +108,95 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<ul
|
{#if navigating.to?.route.id == '/communities'}
|
||||||
class="flex flex-col divide-y divide-slate-100 dark:divide-zinc-800 my-6 h-full"
|
<div class="flex flex-col gap-3 mt-6">
|
||||||
>
|
{#each new Array(5) as _, index}
|
||||||
{#if communities.length == 0}
|
<div
|
||||||
<Placeholder
|
in:fly|global={{
|
||||||
icon={QuestionMarkCircle}
|
duration: 800,
|
||||||
title={$t('routes.search.noResults.title')}
|
easing: expoOut,
|
||||||
description={$t('routes.search.noResults.description')}
|
y: 12,
|
||||||
/>
|
delay: index * 100,
|
||||||
{/if}
|
}}
|
||||||
|
style="width: {(1 / ((index + 1) % 3)) * 100}%"
|
||||||
|
>
|
||||||
|
<Skeleton />
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<ul
|
||||||
|
class="flex flex-col divide-y divide-slate-100 dark:divide-zinc-800 my-6 h-full"
|
||||||
|
>
|
||||||
|
{#if communities.length == 0}
|
||||||
|
<Placeholder
|
||||||
|
icon={QuestionMarkCircle}
|
||||||
|
title={$t('routes.search.noResults.title')}
|
||||||
|
description={$t('routes.search.noResults.description')}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if showTop}
|
{#if showTop}
|
||||||
<SectionTitle class="!border-0 pb-2">
|
<SectionTitle class="!border-0 pb-2">
|
||||||
{$t('routes.search.top')}
|
{$t('routes.search.top')}
|
||||||
</SectionTitle>
|
</SectionTitle>
|
||||||
<div
|
<div
|
||||||
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 !border-0"
|
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 !border-0"
|
||||||
>
|
>
|
||||||
{#each communities.slice(0, 3) as community, index (community.community.id)}
|
{#each communities.slice(0, 3) as community, index (community.community.id)}
|
||||||
<div
|
<div
|
||||||
class="h-full"
|
class="h-full"
|
||||||
in:fly|global={{
|
in:fly|global={{
|
||||||
duration: 1000,
|
duration: 1000,
|
||||||
easing: expoOut,
|
easing: expoOut,
|
||||||
delay: index < 20 ? index * 100 : 0,
|
delay: index < 20 ? index * 100 : 0,
|
||||||
y: 16,
|
y: 16,
|
||||||
}}
|
}}
|
||||||
>
|
|
||||||
<Material
|
|
||||||
color="distinct"
|
|
||||||
padding="none"
|
|
||||||
rounding="xl"
|
|
||||||
class="dark:border-t-zinc-800 h-full"
|
|
||||||
>
|
>
|
||||||
<CommunityItem
|
<Material
|
||||||
{community}
|
color="distinct"
|
||||||
showCounts={false}
|
padding="none"
|
||||||
class="w-full p-4 text-center"
|
rounding="xl"
|
||||||
view="cozy"
|
class="dark:border-t-zinc-800 h-full"
|
||||||
/>
|
>
|
||||||
</Material>
|
<CommunityItem
|
||||||
</div>
|
{community}
|
||||||
{/each}
|
showCounts={false}
|
||||||
</div>
|
class="w-full p-4 text-center"
|
||||||
{/if}
|
view="cozy"
|
||||||
|
/>
|
||||||
|
</Material>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if communities.slice(showTop ? 3 : 0).length > 0}
|
{#if communities.slice(showTop ? 3 : 0).length > 0}
|
||||||
<SectionTitle class="!border-0 pb-2">
|
<SectionTitle class="!border-0 pb-2">
|
||||||
{$t('routes.search.other')}
|
{$t('routes.search.other')}
|
||||||
</SectionTitle>
|
</SectionTitle>
|
||||||
{/if}
|
{/if}
|
||||||
{#if communities}
|
{#if communities}
|
||||||
{@const sliced = communities.slice(showTop ? 3 : 0)}
|
{@const sliced = communities.slice(showTop ? 3 : 0)}
|
||||||
<div class="-mx-4 sm:-mx-6 h-full">
|
<div class="-mx-4 sm:-mx-6 h-full">
|
||||||
{#each sliced as community, index (community.community.id)}
|
{#each sliced as community, index (community.community.id)}
|
||||||
<div
|
<div
|
||||||
class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container
|
class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container
|
||||||
border-b border-slate-100 dark:border-zinc-900"
|
border-b border-slate-100 dark:border-zinc-900"
|
||||||
in:fly|global={{
|
in:fly|global={{
|
||||||
duration: 1000,
|
duration: 1000,
|
||||||
easing: expoOut,
|
easing: expoOut,
|
||||||
delay: index < 20 ? index * 35 : 0,
|
delay: index < 20 ? index * 35 : 0,
|
||||||
y: 16,
|
y: 16,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CommunityItem {community} showCounts={false} class="py-3" />
|
<CommunityItem {community} showCounts={false} class="py-3" />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
|
{/if}
|
||||||
{#if communities.length > 0}
|
{#if communities.length > 0}
|
||||||
<div
|
<div
|
||||||
class="sticky z-30 mx-auto max-w-full"
|
class="sticky z-30 mx-auto max-w-full"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export async function load({ url, fetch }) {
|
|||||||
page: page,
|
page: page,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
type_: type,
|
type_: type,
|
||||||
|
show_nsfw: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -34,13 +34,14 @@
|
|||||||
MagnifyingGlass,
|
MagnifyingGlass,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
import { t } from '$lib/translations.js'
|
import { t } from '$lib/translations.js'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||||
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||||
|
|
||||||
type Result = PostView | CommentView | PersonView | CommunityView
|
type Result = PostView | CommentView | PersonView | CommunityView
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
class="flex-shrink-0 h-full aspect-square"
|
class="flex-shrink-0 h-full aspect-square"
|
||||||
title="Search"
|
title="Search"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
loading={navigating.to != null}
|
loading={navigating.to?.route.id == '/search'}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={MagnifyingGlass} size="16" micro />
|
<Icon src={MagnifyingGlass} size="16" micro />
|
||||||
@@ -145,15 +146,33 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if !data.results}
|
{#if !data.results}
|
||||||
<div class="my-auto">
|
{#if navigating.to?.route.id == '/search'}
|
||||||
<Placeholder
|
<div class="flex flex-col gap-3 mt-6">
|
||||||
icon={MagnifyingGlass}
|
{#each new Array(5) as _, index}
|
||||||
title={$t('routes.search.noResults.title')}
|
<div
|
||||||
description={query == ''
|
in:fly|global={{
|
||||||
? $t('routes.search.noResults.alt')
|
duration: 800,
|
||||||
: $t('routes.search.noResults.description')}
|
easing: expoOut,
|
||||||
/>
|
y: 12,
|
||||||
</div>
|
delay: index * 100,
|
||||||
|
}}
|
||||||
|
style="width: {(1 / ((index + 1) % 3)) * 100}%"
|
||||||
|
>
|
||||||
|
<Skeleton />
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="my-auto">
|
||||||
|
<Placeholder
|
||||||
|
icon={MagnifyingGlass}
|
||||||
|
title={$t('routes.search.noResults.title')}
|
||||||
|
description={query == ''
|
||||||
|
? $t('routes.search.noResults.alt')
|
||||||
|
: $t('routes.search.noResults.description')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
{:else}
|
{:else}
|
||||||
{#await data.streamed.object}
|
{#await data.streamed.object}
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in new issue
Block a user