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">
<div
class="w-2/3 h-6 bg-slate-200 dark:bg-zinc-800 animate-pulse rounded-md"
></div>
<div
class="w-full h-20 bg-slate-200 dark:bg-zinc-800 animate-pulse rounded-md"
></div>
<div
class="w-32 h-6 bg-slate-200 dark:bg-zinc-800 animate-pulse rounded-md"
></div>
<script lang="ts">
const sizes = {
sm: 'h-20',
md: 'h-30',
lg: 'h-36',
}
interface Props {
size?: keyof typeof sizes
}
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>
<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,
type Tag,
} from '$lib/feature/post'
import Skeleton from '$lib/ui/generic/Skeleton.svelte'
import Placeholder from '$lib/ui/info/Placeholder.svelte'
import { CommonList } from '$lib/ui/layout'
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
@@ -23,8 +24,6 @@
import { Button, Expandable, toast } from 'mono-svelte'
import { onMount } from 'svelte'
import { ChatBubbleLeftRight, ChevronDoubleUp } from 'svelte-hero-icons/dist'
import { expoOut } from 'svelte/easing'
import { fly } from 'svelte/transition'
import CommentProvider from './CommentProvider.svelte'
let { data } = $props()
@@ -226,18 +225,12 @@
{#each new Array(10) as _, index}
{_}
<div
in:fly|global={{
duration: 500,
easing: expoOut,
y: 8,
delay: index * 50,
}}
class="animate-pulse flex flex-col gap-2 w-full
*:bg-slate-100 dark:*:bg-zinc-800 *:rounded-md"
class="animate-pop-in"
style="animation-delay: {index * 50}ms; opacity: 0; width: {(1 /
((index + 1) % 3)) *
100}%"
>
<div class="w-96 h-3"></div>
<div class="w-full h-12"></div>
<div class="w-48 h-4"></div>
<Skeleton size="sm" />
</div>
{/each}
</div>
+5
View File
@@ -0,0 +1,5 @@
<script lang="ts">
import { TextLoader } from 'mono-svelte'
</script>
<TextLoader>Hello textloader</TextLoader>