-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from SpeciesFileGroup/development
Development
- Loading branch information
Showing
4 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<template> | ||
<ul | ||
aria-disabled="false" | ||
aria-label="Pagination" | ||
class="flex flex-row text-sm" | ||
> | ||
<li> | ||
<button | ||
type="button" | ||
:disabled="currentPage < 2" | ||
aria-label="Go to first page" | ||
class="border border-base-border rounded-l-md px-2 py-1.5" | ||
@click="currentPage = 1" | ||
> | ||
« | ||
</button> | ||
</li> | ||
<li | ||
role="presentation" | ||
class="page-item" | ||
> | ||
<button | ||
type="button" | ||
:disabled="currentPage < 2" | ||
aria-label="Go to previous page" | ||
class="border border-base-border px-2 py-1.5" | ||
@click="currentPage--" | ||
> | ||
‹ | ||
</button> | ||
</li> | ||
|
||
<li | ||
v-if="modelValue > props.rangePages" | ||
class="border border-base-border px-2 py-1.5" | ||
> | ||
<span class="page gap"> ... </span> | ||
</li> | ||
|
||
<template | ||
v-for="n in pages" | ||
:key="n" | ||
> | ||
<li | ||
v-if="n < rangeMax && rangeMin < n" | ||
class="page-item" | ||
> | ||
<button | ||
type="button" | ||
aria-label="Go to page 1" | ||
class="border border-base-border px-2 py-1.5" | ||
:disabled="currentPage === n" | ||
:class=" | ||
currentPage === n | ||
? 'text-primary-content bg-primary-color' | ||
: 'text-base-content' | ||
" | ||
@click="() => (currentPage = n)" | ||
> | ||
{{ n }} | ||
</button> | ||
</li> | ||
</template> | ||
|
||
<li | ||
v-if="pages - modelValue >= rangePages" | ||
class="border border-base-border px-2 py-1.5" | ||
> | ||
<span class="page gap"> ... </span> | ||
</li> | ||
|
||
<li class="page-item"> | ||
<button | ||
type="button" | ||
aria-label="Go to next page" | ||
class="border border-base-border px-2 py-1.5" | ||
:disabled="currentPage === pages" | ||
@click="() => currentPage++" | ||
> | ||
› | ||
</button> | ||
</li> | ||
<li role="presentation"> | ||
<button | ||
type="button" | ||
:disabled="currentPage === pages" | ||
aria-label="Go to last page" | ||
class="border border-base-border rounded-r-md px-2 py-1.5" | ||
@click="() => (currentPage = pages)" | ||
> | ||
» | ||
</button> | ||
</li> | ||
</ul> | ||
</template> | ||
|
||
<script setup> | ||
import { computed } from 'vue' | ||
const props = defineProps({ | ||
modelValue: { | ||
type: Number, | ||
required: true | ||
}, | ||
total: { | ||
type: Number, | ||
required: true | ||
}, | ||
per: { | ||
type: Number, | ||
required: true | ||
}, | ||
rangePages: { | ||
type: Number, | ||
default: 5 | ||
} | ||
}) | ||
const emit = defineEmits(['update:modelValue']) | ||
const pages = computed(() => Math.ceil(props.total / props.per)) | ||
const currentPage = computed({ | ||
get: () => props.modelValue, | ||
set: (value) => { | ||
emit('update:modelValue', value) | ||
} | ||
}) | ||
const rangeMax = computed(() => props.modelValue + props.rangePages) | ||
const rangeMin = computed(() => props.modelValue - props.rangePages) | ||
</script> |