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