diff --git a/src/entities/Font/ui/FontVirtualList/FontVirtualList.svelte b/src/entities/Font/ui/FontVirtualList/FontVirtualList.svelte index d9761bd..c0b6f45 100644 --- a/src/entities/Font/ui/FontVirtualList/FontVirtualList.svelte +++ b/src/entities/Font/ui/FontVirtualList/FontVirtualList.svelte @@ -8,7 +8,10 @@ import { Skeleton, VirtualList, } from '$shared/ui'; -import type { ComponentProps } from 'svelte'; +import type { + ComponentProps, + Snippet, +} from 'svelte'; import { fade } from 'svelte/transition'; import { getFontUrl } from '../../lib'; import { @@ -28,19 +31,21 @@ interface Props extends * Callback for when visible items change */ onVisibleItemsChange?: (items: UnifiedFont[]) => void; - /** - * Weight of the font - */ /** * Weight of the font */ weight: number; + /** + * Skeleton snippet + */ + skeleton?: Snippet; } let { children, onVisibleItemsChange, weight, + skeleton, ...rest }: Props = $props(); @@ -100,32 +105,25 @@ function handleNearBottom(_lastVisibleIndex: number) { } -{#key isLoading} -
- {#if isLoading} -
- {#each Array(5) as _, i} -
-
- - -
- -
- {/each} -
- {:else} - - {#snippet children(scope)} - {@render children(scope)} - {/snippet} - - {/if} -
-{/key} +
+ {#if skeleton && isLoading && unifiedFontStore.fonts.length === 0} + +
+ {@render skeleton()} +
+ {:else} + + + {#snippet children(scope)} + {@render children(scope)} + {/snippet} + + {/if} +