/
Pagination.vue
153 lines (137 loc) · 3.82 KB
/
Pagination.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
<div v-if="enable" class="pagination-wrapper">
<div class="pagination-list">
<div class="btn-group">
<div
v-if="currentPage > 1"
class="btn"
role="navigation"
unselectable="on"
@click="navigate(currentPage - 1)"
>
{{ i18n.prev }}
</div>
<div v-if="displayLeftEllipsis" role="navigation" @click="navigate(1)">
1
</div>
<div v-if="displayLeftEllipsis" class="ellipsis">...</div>
<div
v-for="num in indexs"
:key="num"
:class="{ active: currentPage === num }"
role="navigation"
@click="navigate(num)"
>
{{ num }}
</div>
<div
v-if="displayRightEllipsis && currentPage < totalPages - 3"
class="ellipsis"
>
...
</div>
<div
v-if="displayRightEllipsis && currentPage < totalPages - 3"
role="navigation"
@click="navigate(totalPages)"
>
{{ totalPages }}
</div>
<div
v-if="currentPage < totalPages"
class="btn"
role="navigation"
@click="navigate(currentPage + 1)"
>
{{ i18n.next }}
</div>
</div>
<div class="navigate-wrapper">
<div class="text">{{ i18n.navigate }}: </div>
<input v-model="input" type="text" @keypress.enter="jumpPage(input)" />
<div class="navigate-button" role="navigation" @click="jumpPage(input)">
{{ i18n.button }}
</div>
</div>
</div>
</div>
</template>
<script src="./Pagination" />
<style lang="stylus">
$bgColor ?= #fff
.pagination-wrapper
margin 1.25rem 0 0.75rem
font-family Arial, Helvetica, sans-serif
font-weight 600
font-size 15px
line-height 2
.pagination-list
display flex
justify-content space-evenly
align-items center
flex-wrap wrap
user-select none
.btn-group
display flex
align-items stretch
height 30px
margin 0 0.5rem
border 1px solid var(--border-color, $borderColor)
border-radius 0.25rem
overflow hidden
div
position relative
padding 0 0.5rem
background var(--bgcolor, $bgColor)
color var(--accent-color, $accentColor)
cursor pointer
&::before
content ' '
position absolute
top 0
left 0
bottom 0
width 1px
background var(--border-color, $borderColor)
&:first-child
&::before
background transparent
&:hover, &.active
background var(--accent-color, $accentColor)
color var(--white, #fff)
&::before
background var(--accent-color, $accentColor)
&.active + div, &:hover + div
&::before
background var(--accent-color, $accentColor)
&.active, &.ellipsis
cursor default
.navigate-wrapper
display flex
justify-content center
align-items center
margin 0.5rem
input
width 3.5rem
margin 6px 0
border 1px solid var(--border-color, $borderColor)
border-radius 0.25em
color var(--text-color, $textColor)
background var(--bgcolor, #fff)
text-align center
line-height 2
outline none
.navigate-button
margin-left 5px
padding 0 0.75em
background var(--bgcolor, $bgColor)
color var(--accent-color, $accentColor)
border 1px solid var(--border-color, $borderColor)
border-radius 0.25em
overflow hidden
&:hover
cursor pointer
color var(--white, #fff)
background var(--accent-color, $accentColor)
border-color var(--accent-color, $accentColor)
</style>