feat: add loading animation to search/community pages

This commit is contained in:
James Xylight committed 2025-02-09 15:06:02 -08:00
1 parent d8e916d526
commit 9e1db2ea83
9 files changed
+169 -253

No files matched your search

-2
View File
@@ -172,8 +172,6 @@ $effect.root(() => {
}
})
$effect(() => {})
$effect(() => {
if (profile.data.id || profileData) fetchUserData(profile).then((res) => {})
})
@@ -5,10 +5,14 @@
import {
ChatBubbleOvalLeftEllipsis,
Check,
ExclamationTriangle,
Icon,
InformationCircle,
MapPin,
NoSymbol,
PencilSquare,
Plus,
Trash,
UserGroup,
} from 'svelte-hero-icons'
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"
>
<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
class="text-sm text-slate-600 dark:text-zinc-400 flex gap-0.5"
@@ -47,11 +47,9 @@
Spinner,
toast,
} from 'mono-svelte'
import { fediseer, type Data } from '$lib/fediseer/fediseer'
import { t } from '$lib/translations'
import { hidePost, postLink } from './helpers'
import { feature } from '$lib/version'
import Switch from '$lib/components/input/Switch.svelte'
import { instanceId, instanceToURL } from '$lib/util.svelte'
import { publishedToDate } from '$lib/components/util/date'
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>
-105
View File
@@ -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>
-65
View File
@@ -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')