Skip to content

Commit

Permalink
chore:loading animation
Browse files Browse the repository at this point in the history
  • Loading branch information
SureshPradhana committed May 4, 2024
1 parent cd75477 commit 9d71937
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"clsx": "^2.1.0",
"feather-icons": "^4.29.1",
"javascript-time-ago": "^2.5.9",
"svelte-loading-animation": "^0.0.1",
"tailwind-merge": "^2.2.2",
"tailwind-variants": "^0.2.1",
"time-difference-js": "^1.0.1"
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { onMount } from 'svelte';
import type { NewsItem } from '$lib/types';
import { getIds, getItems } from '$lib/utils/utils';
import { LoadBars } from 'svelte-loading-animation';
let items: NewsItem[] = [];
let nextIndex = 15;
Expand All @@ -22,11 +23,16 @@
}
</script>

{#each items as item, i}
<News key={i} {item} />
{/each}

<button on:click={loadMoreItems}>More</button>
{#if items.length === 0}
<div class="flex justify-center content-center">
<LoadBars size="32px" color="red" class="mx-auto" />
</div>
{:else}
{#each items as item, i}
<News key={i} {item} />
{/each}
<button on:click={loadMoreItems}>More</button>
{/if}

<style lang="postcss">
:global(html) {
Expand Down

0 comments on commit 9d71937

Please sign in to comment.