1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-05 08:29:57 +00:00
elk/components/common/CommonPaginator.vue

32 lines
795 B
Vue
Raw Normal View History

2022-11-16 16:11:08 +00:00
<script setup lang="ts">
2022-11-17 07:35:42 +00:00
import type { Paginator } from 'masto'
2022-11-16 16:11:08 +00:00
2022-11-17 07:35:42 +00:00
const { paginator, keyProp = 'id' } = defineProps<{
paginator: Paginator<any, any[]>
keyProp?: string
2022-11-16 16:11:08 +00:00
}>()
2022-11-17 07:35:42 +00:00
const { items, state, endAnchor, error } = usePaginator(paginator)
2022-11-16 16:11:08 +00:00
</script>
<template>
2022-11-17 07:35:42 +00:00
<div>
<slot
v-for="item of items"
:key="item[keyProp]"
:item="item"
/>
<div ref="endAnchor" />
2022-11-20 20:32:20 +00:00
<div v-if="state === 'loading'" p5 text-center flex="~ col" items-center animate-pulse>
<div op50 i-ri:loader-2-fill animate-spin text-2xl />
<span op50>Loading...</span>
2022-11-17 07:35:42 +00:00
</div>
2022-11-20 20:32:20 +00:00
<div v-else-if="state === 'done'" p5 op50 italic text-center>
End of the list
2022-11-17 07:35:42 +00:00
</div>
2022-11-20 20:32:20 +00:00
<div v-else-if="state === 'error'" p5 op50>
2022-11-17 07:35:42 +00:00
ERROR: {{ error }}
</div>
2022-11-16 16:11:08 +00:00
</div>
</template>