Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Pagination): improve slot props #2522

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,29 @@ const items = ref(Array(55))

<template>
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
<template #first="{ onClick }">
<template #first="{ onClick, canGoFirst }">
<UTooltip text="First page">
<UButton icon="i-heroicons-arrow-uturn-left" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:first-child]:rotate-180 me-2" @click="onClick" />
<UButton
icon="i-heroicons-arrow-uturn-left"
color="primary"
:ui="{ rounded: 'rounded-full' }"
class="rtl:[&_span:first-child]:rotate-180 me-2"
:disabled="!canGoFirst"
@click="onClick"
/>
benjamincanac marked this conversation as resolved.
Show resolved Hide resolved
</UTooltip>
</template>

<template #last="{ onClick }">
<template #last="{ onClick, canGoLast }">
<UTooltip text="Last page">
<UButton icon="i-heroicons-arrow-uturn-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:last-child]:rotate-180 ms-2" @click="onClick" />
<UButton
icon="i-heroicons-arrow-uturn-right-20-solid"
color="primary"
:ui="{ rounded: 'rounded-full' }"
class="rtl:[&_span:last-child]:rotate-180 ms-2"
:disabled="!canGoLast"
@click="onClick"
/>
</UTooltip>
</template>
</UPagination>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,29 @@ const items = ref(Array(55))

<template>
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-s-md last-of-type:rounded-e-md' }">
<template #prev="{ onClick }">
<template #prev="{ onClick, canGoPrev }">
<UTooltip text="Previous page">
<UButton icon="i-heroicons-arrow-small-left-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:first-child]:rotate-180 me-2" @click="onClick" />
<UButton
icon="i-heroicons-arrow-small-left-20-solid"
color="primary"
:ui="{ rounded: 'rounded-full' }"
class="rtl:[&_span:first-child]:rotate-180 me-2"
:disabled="!canGoPrev"
@click="onClick"
/>
</UTooltip>
</template>

<template #next="{ onClick }">
<template #next="{ onClick, canGoNext }">
<UTooltip text="Next page">
<UButton icon="i-heroicons-arrow-small-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="rtl:[&_span:last-child]:rotate-180 ms-2" @click="onClick" />
<UButton
icon="i-heroicons-arrow-small-right-20-solid"
color="primary"
:ui="{ rounded: 'rounded-full' }"
class="rtl:[&_span:last-child]:rotate-180 ms-2"
:disabled="!canGoNext"
@click="onClick"
/>
</UTooltip>
</template>
</UPagination>
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/components/navigation/Pagination.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="ui.wrapper" v-bind="attrs">
<slot name="first" :on-click="onClickFirst">
<slot name="first" :on-click="onClickFirst" :can-go-first="canGoFirstOrPrev">
<UButton
v-if="firstButton && showFirst"
:size="size"
Expand All @@ -14,7 +14,7 @@
/>
</slot>

<slot name="prev" :on-click="onClickPrev">
<slot name="prev" :on-click="onClickPrev" :can-go-prev="canGoFirstOrPrev">
<UButton
v-if="prevButton"
:size="size"
Expand All @@ -41,7 +41,7 @@
@click="() => onClickPage(page)"
/>

<slot name="next" :on-click="onClickNext">
<slot name="next" :on-click="onClickNext" :can-go-next="canGoLastOrNext">
<UButton
v-if="nextButton"
:size="size"
Expand All @@ -55,7 +55,7 @@
/>
</slot>

<slot name="last" :on-click="onClickLast">
<slot name="last" :on-click="onClickLast" :can-go-last="canGoLastOrNext">
<UButton
v-if="lastButton && showLast"
:size="size"
Expand Down