Implement pagination properly

This commit is contained in:
Daniel_I_Am 2021-09-02 15:05:30 +02:00
parent a0fcb669bd
commit 1ded5a4bb2
4 changed files with 47 additions and 6 deletions

View File

@ -25,7 +25,7 @@
</ul>
<pagination
v-if="paginate"
v-if="paginate && !loading"
v-model:page="page"
v-model:itemsPerPage="itemsPerPage"
:max-pages="lastPage"
@ -88,6 +88,7 @@ export default {
this.$router.push({ name: 'blog-article', params: { year, month, day, id, slug }});
},
updateList(limit, page) {
this.loading = true;
axios.get("/api/blog/recent", {
params: {
limit: limit,

View File

@ -1,9 +1,11 @@
<template>
<div class="pagination">
<button @click="gotoPage(0)">First</button>
<button @click="gotoPage(page - 1)">Previous</button>
<span>{{ page + 1 }} / {{ maxPages }}</span>
<button class="unselectable">{{ page + 1 }} / {{ maxPages }}</button>
<button @click="gotoPage(page + 1)">Next</button>
<button @click="gotoPage(maxPages)">Last</button>
</div>
</template>
<script>

37
resources/scss/_pagination.scss vendored Normal file
View File

@ -0,0 +1,37 @@
.pagination {
display: flex;
justify-content: flex-start;
button {
background-color: #1c2d35;
border: 1px solid white;
color: white;
height: 40px;
width: 120px;
padding: .5rem;
flex-grow: 1;
}
button:not(.unselectable) {
cursor: pointer;
}
button:not(.unselectable):hover {
background-color: #2d3e46;
}
button:not(:last-child) {
border-right: none;
}
button:first-child {
border-top-left-radius: 15px;
border-bottom-left-radius: 15px;
}
button:last-child {
border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
}
}

View File

@ -16,3 +16,4 @@
@import "blog";
@import "footer";
@import "home";
@import "pagination";