Skip to content

Commit fc2d2c2

Browse files
author
Gareth Redfern
committed
move pagination page count inside BasePagination
1 parent cc4a77d commit fc2d2c2

File tree

2 files changed

+50
-52
lines changed

2 files changed

+50
-52
lines changed

src/components/BasePagination.vue

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
11
<template>
2-
<div aria-label="Pagination" class="flex justify-center">
3-
<button
4-
rel="first"
5-
type="button"
6-
@click="firstPage"
7-
v-if="links.prev"
8-
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
9-
>
10-
First
11-
</button>
2+
<div aria-label="Pagination" class="flex items-center justify-between py-4">
3+
<p class="text-sm text-gray-500">
4+
Page {{ meta.current_page }} of {{ meta.last_page }}
5+
</p>
6+
<div class="flex">
7+
<button
8+
rel="first"
9+
type="button"
10+
@click="firstPage"
11+
v-if="links.prev"
12+
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
13+
>
14+
First
15+
</button>
1216

13-
<button
14-
rel="prev"
15-
type="button"
16-
@click="prevPage"
17-
:class="{ 'rounded-r': !links.next }"
18-
v-if="links.prev"
19-
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
20-
>
21-
Previous
22-
</button>
17+
<button
18+
rel="prev"
19+
type="button"
20+
@click="prevPage"
21+
:class="{ 'rounded-r': !links.next }"
22+
v-if="links.prev"
23+
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
24+
>
25+
Previous
26+
</button>
2327

24-
<button
25-
rel="next"
26-
type="button"
27-
@click="nextPage"
28-
:class="{ 'rounded-l': !links.prev }"
29-
v-if="links.next"
30-
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
31-
>
32-
Next
33-
</button>
28+
<button
29+
rel="next"
30+
type="button"
31+
@click="nextPage"
32+
:class="{ 'rounded-l': !links.prev }"
33+
v-if="links.next"
34+
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
35+
>
36+
Next
37+
</button>
3438

35-
<button
36-
rel="last"
37-
type="button"
38-
@click="lastPage"
39-
v-if="links.next"
40-
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
41-
>
42-
Last
43-
</button>
39+
<button
40+
rel="last"
41+
type="button"
42+
@click="lastPage"
43+
v-if="links.next"
44+
class="px-4 py-2 m-1 text-sm text-pink-400 border rounded hover:text-pink-500"
45+
>
46+
Last
47+
</button>
48+
</div>
4449
</div>
4550
</template>
4651

src/views/Users.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,13 @@
3636
<FlashMessage :error="error" v-if="error" key="error" />
3737
</transition>
3838
<transition name="fade">
39-
<div
40-
class="flex items-center justify-between py-4"
39+
<BasePagination
40+
path="users"
41+
:meta="meta"
42+
:links="links"
43+
action="user/paginateUsers"
4144
v-if="meta && meta.last_page > 1"
42-
>
43-
<p class="text-sm text-gray-500">
44-
Page {{ meta.current_page }} of {{ meta.last_page }}
45-
</p>
46-
<BasePagination
47-
path="users"
48-
:meta="meta"
49-
:links="links"
50-
action="user/paginateUsers"
51-
/>
52-
</div>
45+
/>
5346
</transition>
5447
</div>
5548
</template>

0 commit comments

Comments
 (0)