Skip to content

Commit 4be7eed

Browse files
author
Vinayak Kulkarni
committed
Updated README
1 parent bdb632d commit 4be7eed

File tree

1 file changed

+22
-38
lines changed

1 file changed

+22
-38
lines changed

README.md

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,37 @@
1-
[![Build Status](https://travis-ci.org/vinayakkulkarni/laravel-vue-semantic-ui-pagination.svg?branch=master)](https://travis-ci.org/vinayakkulkarni/laravel-vue-semantic-ui-pagination)
1+
[![Build Status](https://travis-ci.org/vinayakkulkarni/vuejs-sort.svg?branch=master)](https://travis-ci.org/vinayakkulkarni/vuejs-sort)
22

33
# Laravel Vue Semantic-UI Pagination :zap:
4-
+ A Vue.js pagination component for Laravel paginators that works with Semantic-UI.
4+
+ A simple Vue.js sorting wrapper.
55

6-
+ This is [on GitHub](https://github.com/vinayakkulkarni/laravel-vue-semantic-ui-pagination) so let me know if I've b0rked it somewhere, give me a star :star: if you like it :beers:
7-
8-
+ You can checkout the [Demo](https://goo.gl/xtZGF9)
6+
+ This is [on GitHub](https://github.com/vinayakkulkarni/vuejs-sort) so let me know if I've b0rked it somewhere, give me a star :star: if you like it :beers:
97

108
## Requirements
119

1210
* [Vue.js](https://vuejs.org/) 2.x
13-
* [Laravel](https://laravel.com/docs/) 5.x
14-
* [Semantic-UI](https://semantic-ui.com/) 2.x
1511

1612
## :white_check_mark: Install :ok_hand:
1713

1814
```bash
19-
npm install laravel-vue-semantic-ui-pagination
15+
npm install vuejs-sort
2016
// or
21-
yarn add laravel-vue-semantic-ui-pagination
17+
yarn add vuejs-sort
2218
```
2319

2420
## :white_check_mark: Usage :mortar_board:
2521

2622
Register the component globally:
2723
```javascript
28-
Vue.component('pagination', require('laravel-vue-pagination'));
24+
Vue.component('sort', require('vuejs-sort'));
2925
```
3026
Or use locally
3127
```javascript
32-
import pagination from 'laravel-vue-semantic-ui-pagination';
28+
import sort from 'vuejs-sort';
3329
```
3430

3531
## :white_check_mark: Example :four_leaf_clover:
3632

3733
```html
38-
<ul>
39-
<li v-for="post in laravelData.data" v-text="post.title"></li>
40-
</ul>
41-
<pagination :data="laravelData" v-bind:showDisabled="true" icon="chevron" v-on:change-page="getResults"></pagination>
34+
<sort :data="sortingData" label="Name" icon="chevron" v-on:sort-data="sortData"></pagination>
4235
```
4336

4437
```javascript
@@ -47,28 +40,28 @@ Vue.component('example-component', {
4740
data() {
4841
return {
4942
// Our data object that holds the Laravel paginator data
50-
laravelData: {},
43+
sortingData: {},
5144
}
5245
},
5346

5447
created() {
5548
// Fetch initial results
56-
this.getResults();
49+
this.sortData();
5750
},
5851

5952
methods: {
6053
// Our method to GET results from a Laravel endpoint
61-
getResults(page) {
62-
if (typeof page === 'undefined') {
63-
page = 1;
54+
sortData(sort, direction) {
55+
if (typeof sort === 'undefined') {
56+
sort = 1;
6457
}
6558

6659
// Using vue-resource as an example
67-
this.$http.get('example/results?page=' + page)
60+
this.$http.get('example/results?sort=' + page + '&direction=' + direction)
6861
.then(response => {
6962
return response.json();
7063
}).then(data => {
71-
this.laravelData = data;
64+
this.sortingData = data;
7265
});
7366
}
7467
}
@@ -80,33 +73,24 @@ Vue.component('example-component', {
8073

8174
| Name | Type | Description |
8275
| --- | --- | --- |
83-
| `data` | Object | An object containing the structure of a [Laravel paginator](https://laravel.com/docs/5.4/pagination) response. See below for default value. |
84-
| `limit` | Number | (optional) Limit of pages to be rendered. Default `0` (unlimited links) `-1` will hide numeric pages and leave only arrow navigation. `3` will show 3 previous and 3 next numeric pages from current page. |
85-
| `showDisabled` | Boolean | (optional) If set to true, will display left and right icons always. |
86-
| `icon` | String | (optional) Default is `angle double`; Refer [Semantic-UI Icons](https://semantic-ui.com/elements/icon.html) for specifying which icons you want. |
87-
| `size` | String | (optional) Default is `small`; Refer [Semantic-UI Menu Pagination](https://semantic-ui.com/collections/menu.html#pagination) for specifying the size of paginator. |
76+
| `data` | Object | An object containing `sort` (you can set this at your backend) & `sorttype` (viz. Direction eg. `'asc'`, `'desc'`) |
77+
| `icon` | String | (optional) Default is `chevron`; Refer [Semantic-UI Icons](https://semantic-ui.com/elements/icon.html) for specifying which icons you want. |
78+
| `label` | String | (optional) Is responsible for the label that'll be displayed which will be clickable. |
8879

8980
```javascript
9081
{
91-
current_page: 1,
92-
data: [],
93-
from: 1,
94-
last_page: 1,
95-
next_page_url: null,
96-
per_page: 10,
97-
prev_page_url: null,
98-
to: 1,
99-
total: 0,
82+
sort: 1,
83+
sorttype: 'asc',
10084
}
10185
```
10286

10387
### :white_check_mark: :ear: Events
10488

10589
| Name | Description |
10690
| --- | --- |
107-
| `change-page` | Triggered when a user changes page. Passes the new `page` index as a parameter. |
91+
| `sort-data` | Triggered when a user changes `sort` & `sorttype`.|
10892

10993

11094
## NPM :octocat:
11195

112-
[![NPM](https://nodei.co/npm/laravel-vue-semantic-ui-pagination.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/laravel-vue-semantic-ui-pagination/)
96+
[![NPM](https://nodei.co/npm/vuejs-sort.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/vuejs-sort/)

0 commit comments

Comments
 (0)