Skip to content

Commit 4c873b0

Browse files
author
Javier Diaz
committed
feat: updated component
1 parent 8be8b84 commit 4c873b0

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

Diff for: packages/TinyPagination/src/main.vue

+52-52
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
<div class="vue-tiny-pagination">
33
<ul class="tiny-pagination" :class="customClass">
44
<li class="page-item" :class="classFirstPage">
5-
<a class="btn-prev-page" href="#" @click.prevent="lastPage">{{translation.prev}}</a>
5+
<a class="btn-prev-page" href="#" @click.prevent="lastPage">{{ translation.prev }}</a>
66
</li>
77
<li class="page-item">
8-
<span>{{titlePage}}</span>
8+
<span>{{ titlePage }}</span>
99
</li>
1010
<li class="page-item" :class="classLastPage">
11-
<a class="btn-next-page" href="#" @click.prevent="nextPage">{{translation.next}}</a>
11+
<a class="btn-next-page" href="#" @click.prevent="nextPage">{{ translation.next }}</a>
1212
</li>
1313
<li v-if="showLimit" class="page-item">
14-
<select class="tiny-form-select" v-model="currentLimit" @change="onLimitChange">
14+
<select v-model="currentLimit" class="tiny-form-select" @change="onLimitChange">
1515
<option
1616
v-for="(limit, index) in limits"
17-
:value="limit"
18-
:key="index">{{limit}}/{{translation.title}}</option>
17+
:key="index"
18+
:value="limit">{{ limit }}/{{ translation.title }}</option>
1919
</select>
2020
</li>
2121
</ul>
2222
</div>
2323
</template>
24-
2524
<script>
2625
export default {
2726
name: 'TinyPagination',
@@ -40,19 +39,20 @@ export default {
4039
},
4140
customClass: {
4241
type: String,
42+
default: '',
4343
},
4444
limits: {
4545
type: Array,
46-
default () {
46+
default() {
4747
return [10, 15, 20, 50, 100];
4848
},
4949
},
5050
showLimit: {
5151
type: Boolean,
5252
default: true,
53-
}
53+
},
5454
},
55-
data () {
55+
data() {
5656
return {
5757
version: '0.3.1',
5858
currentPage: 1,
@@ -67,73 +67,73 @@ export default {
6767
prev: 'Anterior',
6868
title: 'Página',
6969
next: 'Siguiente',
70-
}
70+
},
7171
},
7272
availableLanguages: ['en', 'es'],
7373
};
7474
},
75-
created () {
76-
this.currentPage = this.page
77-
},
7875
computed: {
79-
translation () {
80-
return (this.availableLanguages.includes(this.lang)) ?
81-
this.translations[this.lang]
82-
: this.translations['en']
76+
translation() {
77+
return (this.availableLanguages.includes(this.lang))
78+
? this.translations[this.lang]
79+
: this.translations.en;
8380
},
84-
totalPages () {
85-
return Math.ceil(this.total/this.currentLimit)
81+
totalPages() {
82+
return Math.ceil(this.total / this.currentLimit);
8683
},
87-
titlePage () {
88-
return `${this.translation.title} ${this.currentPage}`
84+
titlePage() {
85+
return `${this.translation.title} ${this.currentPage}`;
8986
},
90-
classFirstPage () {
87+
classFirstPage() {
9188
return {
9289
disabled: (this.currentPage === 1),
93-
'c-not-allowed': true
94-
}
90+
'c-not-allowed': true,
91+
};
9592
},
96-
classLastPage () {
93+
classLastPage() {
9794
return {
9895
disabled: (this.currentPage === this.totalPages),
99-
'c-not-allowed': true
100-
}
101-
}
96+
'c-not-allowed': true,
97+
};
98+
},
99+
},
100+
watch: {
101+
currentPage(value) {
102+
this.$emit('tiny:change-page', {
103+
page: value,
104+
});
105+
},
106+
currentLimit(value) {
107+
this.$emit('tiny:change-limit', {
108+
limit: value,
109+
});
110+
},
111+
},
112+
created() {
113+
this.currentPage = this.page;
102114
},
103115
methods: {
104-
nextPage () {
116+
nextPage() {
105117
if (this.currentPage !== this.totalPages) {
106-
this.currentPage += 1
118+
this.currentPage += 1;
107119
}
108120
},
109-
lastPage () {
121+
lastPage() {
110122
if (this.currentPage > 1) {
111-
this.currentPage -= 1
123+
this.currentPage -= 1;
112124
}
113125
},
114-
onLimitChange () {
115-
this.currentPage = 1
116-
}
117-
},
118-
watch: {
119-
currentPage (value) {
120-
this.$emit('tiny:change-page', {
121-
page: value
122-
})
126+
onLimitChange() {
127+
this.currentPage = 1;
123128
},
124-
currentLimit (value) {
125-
this.$emit('tiny:change-limit', {
126-
limit: value
127-
})
128-
}
129-
}
130-
}
129+
},
130+
};
131131
</script>
132-
133132
<style lang="scss">
134133
// Pagination
134+
$apple-fonts: -apple-system, system-ui, BlinkMacSystemFont;
135135
.tiny-pagination {
136-
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
136+
font-family: $apple-fonts, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
137137
display: flex;
138138
list-style: none;
139139
margin: .2rem 0;
@@ -218,4 +218,4 @@ export default {
218218
padding-right: 1.2rem;
219219
}
220220
}
221-
</style>
221+
</style>

0 commit comments

Comments
 (0)