misc: improve skeleton loaders

This commit is contained in:
Xylight committed 2026-02-11 20:05:11 -08:00
1 parent 064482b352
commit 16bcd76bd0
3 files changed
+67 -23

No files matched your search

+56 -10
View File
@@ -1,11 +1,57 @@
<div class="skeleton animate-pulse flex flex-col gap-2 w-full"> <script lang="ts">
<div const sizes = {
class="w-2/3 h-6 bg-slate-200 dark:bg-zinc-800 animate-pulse rounded-md" sm: 'h-20',
></div> md: 'h-30',
<div lg: 'h-36',
class="w-full h-20 bg-slate-200 dark:bg-zinc-800 animate-pulse rounded-md" }
></div>
<div interface Props {
class="w-32 h-6 bg-slate-200 dark:bg-zinc-800 animate-pulse rounded-md" size?: keyof typeof sizes
></div> }
let { size = 'lg' }: Props = $props()
</script>
<div class={['skeleton flex flex-col gap-2 w-full', sizes[size]]}>
<div class="w-2/3 h-1/6 rounded-lg"></div>
<div class="w-full h-4/6 rounded-lg"></div>
<div class="w-32 h-1/6 rounded-lg"></div>
</div> </div>
<style>
@reference '../../../app.css';
@keyframes pulse {
0% {
background-position: 100%;
}
50% {
background-position: 0%;
}
100% {
background-position: -100%;
}
}
.skeleton * {
background: linear-gradient(
to right,
var(--color-slate-100),
var(--color-slate-200),
var(--color-slate-100)
);
border: 1px solid var(--color-slate-300);
animation: pulse 1s infinite linear;
@variant dark {
border-color: var(--color-zinc-800);
background-image: linear-gradient(
to right,
var(--color-zinc-925),
var(--color-zinc-900),
var(--color-zinc-925)
) !important;
}
background-size: 200%;
}
</style>
@@ -15,6 +15,7 @@
PostMeta, PostMeta,
type Tag, type Tag,
} from '$lib/feature/post' } from '$lib/feature/post'
import Skeleton from '$lib/ui/generic/Skeleton.svelte'
import Placeholder from '$lib/ui/info/Placeholder.svelte' import Placeholder from '$lib/ui/info/Placeholder.svelte'
import { CommonList } from '$lib/ui/layout' import { CommonList } from '$lib/ui/layout'
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte' import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
@@ -23,8 +24,6 @@
import { Button, Expandable, toast } from 'mono-svelte' import { Button, Expandable, toast } from 'mono-svelte'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { ChatBubbleLeftRight, ChevronDoubleUp } from 'svelte-hero-icons/dist' import { ChatBubbleLeftRight, ChevronDoubleUp } from 'svelte-hero-icons/dist'
import { expoOut } from 'svelte/easing'
import { fly } from 'svelte/transition'
import CommentProvider from './CommentProvider.svelte' import CommentProvider from './CommentProvider.svelte'
let { data } = $props() let { data } = $props()
@@ -226,18 +225,12 @@
{#each new Array(10) as _, index} {#each new Array(10) as _, index}
{_} {_}
<div <div
in:fly|global={{ class="animate-pop-in"
duration: 500, style="animation-delay: {index * 50}ms; opacity: 0; width: {(1 /
easing: expoOut, ((index + 1) % 3)) *
y: 8, 100}%"
delay: index * 50,
}}
class="animate-pulse flex flex-col gap-2 w-full
*:bg-slate-100 dark:*:bg-zinc-800 *:rounded-md"
> >
<div class="w-96 h-3"></div> <Skeleton size="sm" />
<div class="w-full h-12"></div>
<div class="w-48 h-4"></div>
</div> </div>
{/each} {/each}
</div> </div>
+5
View File
@@ -0,0 +1,5 @@
<script lang="ts">
import { TextLoader } from 'mono-svelte'
</script>
<TextLoader>Hello textloader</TextLoader>