├── .gitignore
├── README.md
├── eslintrc.js
├── package.json
└── src
├── Pagination.vue
├── index.js
└── paging.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Pagination
2 |
3 | Pagination component for Vue Bulma.
4 |
5 | ## Installation
6 |
7 | ```sh
8 | $ npm install vue-bulma-pagination --save
9 | # or
10 | $ yarn add vue-bulma-pagination --save
11 | ```
12 |
13 | ## Examples
14 |
15 | ```vue
16 |
17 |
20 |
21 |
22 |
31 | ```
32 | ## Document
33 |
34 | | props | required | default | optional | desc |
35 | | ----------- | -------- | --------------------------| --------------------------- | -------------------------------- |
36 | | urlPrefix | `false` | '/' | | urlPrefix for vue-router |
37 | | urlBuilder | `false` | [urlBuilder](#urlbuilderpagenum) | | urlBuilder result will passed to vue-router link `to` prop |
38 | | currentPage | `true` | 1 | | |
39 | | lastPage | `true` | | | the last page number |
40 | | displayPage | `false` | 4 | | page number will to be displayed |
41 | | modifiers | `false` | '' | '','is-centered','is-right' | |
42 | | prev | `false` | 'Prev' | | text of `prev` button |
43 | | next | `false` | 'Next' | | text of `next` button |
44 |
45 |
46 | ### urlBuilder(pageNum)
47 | Returned value will be passed to `router-link` as `:to` prop. See example below:
48 | ```vue
49 |
50 |
53 |
54 |
55 |
70 | ```
71 |
72 | ## Badges
73 |
74 | 
75 | 
76 |
77 | ---
78 |
--------------------------------------------------------------------------------
/eslintrc.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vue-bulma/pagination/39ed0536bf240f6d3efbe5ef0c85d6690577291c/eslintrc.js
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-bulma-pagination",
3 | "version": "1.2.0",
4 | "description": "Pagination component for Vue Bulma",
5 | "main": "src/index.js",
6 | "peerDependencies": {
7 | "bulma": ">=0.2",
8 | "vue": ">=2",
9 | "vue-router": ">=2"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/vue-bulma/vue-bulma-pagination"
14 | },
15 | "keywords": [
16 | "vue",
17 | "bulma",
18 | "vue-bulma",
19 | "vue-bulma-pagination",
20 | "pagination"
21 | ],
22 | "author": "netpi",
23 | "license": "MIT"
24 | }
25 |
--------------------------------------------------------------------------------
/src/Pagination.vue:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
88 |
89 |
97 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import Pagination from './Pagination.vue'
2 |
3 | export default Pagination
4 |
--------------------------------------------------------------------------------
/src/paging.js:
--------------------------------------------------------------------------------
1 | module.exports = function (current, length, displayLength) {
2 | if (length <= 1) return []
3 | displayLength = displayLength - 2
4 | var indexes = [1]
5 | var start = Math.round(current - displayLength / 2)
6 | var end = Math.round(current + displayLength / 2)
7 | if (start <= 1) {
8 | start = 2
9 | end = start + displayLength - 1
10 | if (end >= length - 1) end = length - 1
11 | }
12 | if (end >= length - 1) {
13 | end = length - 1
14 | start = end - displayLength + 1
15 | if (start <= 1) start = 2
16 | }
17 | if (start !== 2) indexes.push('...')
18 | for (var i = start; i <= end; i++) {
19 | indexes.push(i)
20 | }
21 | if (end !== length - 1) indexes.push('...')
22 | indexes.push(length)
23 | return indexes
24 | }
25 |
--------------------------------------------------------------------------------