feat: add cursor pagination
This commit is contained in:
1 parent
24c0c248f3
commit
0239d6cef9
5 files changed
+26
-10
No files matched your search
@@ -10,8 +10,9 @@
|
||||
} from 'svelte-hero-icons'
|
||||
|
||||
export let page: number
|
||||
export let next_cursor: string | undefined = undefined
|
||||
|
||||
const dispatcher = createEventDispatcher<{ change: number }>()
|
||||
const dispatcher = createEventDispatcher<{ change: number, cursor: string }>()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row w-full gap-4 items-center">
|
||||
@@ -21,6 +22,7 @@
|
||||
</span>
|
||||
<hr class="border-slate-200 dark:border-zinc-800 flex-1" />
|
||||
{/if}
|
||||
{#if !next_cursor}
|
||||
<Button
|
||||
on:click={() => {
|
||||
dispatcher('change', --page)
|
||||
@@ -31,10 +33,14 @@
|
||||
<Icon src={ChevronLeft} size="18" mini slot="prefix" />
|
||||
Back
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
<Button
|
||||
on:click={() => {
|
||||
dispatcher('change', ++page)
|
||||
if (next_cursor)
|
||||
dispatcher('cursor', next_cursor)
|
||||
else
|
||||
dispatcher('change', ++page)
|
||||
}}
|
||||
class={$$slots.default ? '' : 'flex-1'}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user