Skip to content

Commit

Permalink
Readme, css classes improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
onca-vega committed Dec 28, 2018
1 parent 2f90c7e commit 93e3dcd
Show file tree
Hide file tree
Showing 19 changed files with 585 additions and 8,997 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typings/

# Optional npm cache directory
.npm
package-lock.json

# Optional eslint cache
.eslintcache
Expand Down
243 changes: 242 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,246 @@
# Eina Page for Vue
[![NPM](https://nodei.co/npm/einapage-vue.png?mini=true)](https://www.npmjs.com/package/einapage-vue)
[![Node version](https://img.shields.io/badge/package-v0.1.0-orange.svg)](https://www.npmjs.com/package/einapage-vue)
[![Node version](https://img.shields.io/badge/package-v0.1.1-orange.svg)](https://www.npmjs.com/package/einapage-vue)
[![Build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://travis-ci.org/onca-vega/EinaPage-Vue)
[![Coverage Status](https://coveralls.io/repos/github/onca-vega/EinaPage-Vue/badge.svg?branch=master)](https://coveralls.io/github/onca-vega/EinaPage-Vue?branch=master)

Customizable VueJS component oriented to data pagination.
![EinaPage][EinaPage]

## Translations
- [Spanish]

## Installation
```bash
$ npm install --save einapage-vue
```

## Usage
### Register the component
```bash
...
<script>
import einaPage from "einapage-vue";

export default {
name: "Index",
components: {
einaPage
},
mixins: [],
directives: {},
props: {},
...
```
### Props defined for Eina Page
name | description | type | default
------------ | ------------- | ------------- | -------------
currentrows | Number of rows that are in the current page | number | 0
rowcount | Number related to the total of rows that exists | number | 1
currentpage | Current page showed | number | 1
pagecount | Number related to the total of pages that exists | number | 0
overlayclass | CSS class at the root of the component | string | undefined
dataclass | CSS class inside every data text | string | undefined
detailsclass | CSS class at the node of the details | string | undefined
itemclass | CSS class at the node of every list element | string | undefined
Let´s see them step by step, following the next example:
```bash
...
<template>
<eina-page
:currentrows="17"
:currentpage="4"
:rowcount="25100"
:pagecount="1255"
overlayclass="my-overlay-class"
detailsclass="my-details-class"
itemclass="my-item-class"
dataclass="my-data-class">
</eina-page>
</template>
...
```
#### Prop: currentrows
In the example we are telling Eina Page that "currentrows" is equal to 17, resulting:
![EinaPage-currentrows][EinaPage-currentrows]
#### Prop: currentpage
In the example we are telling Eina Page that "currentpage" is equal to 4, resulting:
![EinaPage-currentpage][EinaPage-currentpage]
#### Prop: rowcount
In the example we are telling Eina Page that "rowcount" is equal to 25100, resulting:
![EinaPage-rowcount][EinaPage-rowcount]
#### Prop: pagecount
In the example we are telling Eina Page that "pagecount" is equal to 1255, resulting:
![EinaPage-pagecount][EinaPage-pagecount]
#### Prop: overlayclass
In the example we are telling Eina Page that "overlayclass" is equal to "my-overlay-class". This class is positioned at the root of the component:
![EinaPage-overlayclass][EinaPage-overlayclass]
#### Prop: detailsclass
In the example we are telling Eina Page that "detailsclass" is equal to "my-details-class". This class is positioned at the details item of the list:
![EinaPage-detailsclass][EinaPage-detailsclass]
#### Prop: itemclass
In the example we are telling Eina Page that "itemclass" is equal to "my-item-class". This class is positioned at all the others items inside the list:
![EinaPage-itemclass][EinaPage-itemclass]
#### Prop: dataclass
In the example we are telling Eina Page that "dataclass" is equal to "my-data-class". This class is positioned at the deepest child of every list item, on the span tags:
![EinaPage-dataclass][EinaPage-dataclass]
### Emitters defined for Eina Page
Eina Page has only one emitter "setPage" that is related to the page change, and return the number of the page clicked:
```bash
...
<template>
<eina-page
v-on:setPage="setPage">
</eina-page>
</template>
...
methods: {
setPage(p){
this.currentpage = p;
}
},
...
```

### Slots defined for Eina Page
Let's describe them a little bit:
name | description | scope
------------ | ------------- | -------------
details | Allows you to customize the details text | currentrows, currentpage, rowcount, pagecount
firstArrow | Allows you to customize the content of the button for the first page | none
lastArrow | Allows you to customize the content of the button for the last page | none

Then, let´s see them step by step, following the next example:
```bash
...
<template>
<eina-page>
<template slot="details" slot-scope="data">
Current row: {{ data.currentrows }}, Current page: {{ data.currentpage }}, Rows: {{ data.rowcount }}, Pages: {{ data.pagecount }}
</template>
<template slot="firstArrow">
First
</template>
<template slot="lastArrow">
Last
</template>
</eina-page>
</template>
...
```

#### Slot: details
According to the previous example, the result will be:
![EinaPage-details][EinaPage-details]

#### Slot: firstArrow
According to the previous example, the result will be:
![EinaPage-firstArrow][EinaPage-firstArrow]

#### Slot: lastArrow
According to the previous example, the result will be:
![EinaPage-lastArrow][EinaPage-lastArrow]

###Full example
```bash
<template>
<eina-page
v-on:setPage="setPage"
:currentrows="currentrows"
:currentpage="currentpage"
:rowcount="rowcount"
:pagecount="pagecount"
overlayclass="my-overlay-class"
detailsclass="my-details-class"
itemclass="my-item-class"
dataclass="my-data-class">
<template slot="details" slot-scope="data">
Current row: {{ data.currentrows }}, Current page: {{ data.currentpage }}, Rows: {{ data.rowcount }}, Pages: {{ data.pagecount }}
</template>
<template slot="firstArrow">
First
</template>
<template slot="lastArrow">
Last
</template>
</eina-page>
</template>
<script>
import einaPage from "./EinaPage.vue";

export default {
name: "Index",
components: {
einaPage
},
mixins: [],
directives: {},
props: {},
data: function(){
return {
currentrows: 17,
rowcount: 25100,
currentpage: 4,
pagecount: 1255
};
},
computed: {},
watch: {},
filters: {},
methods: {
setPage(p){
this.currentpage = p;
}
},
beforeCreate: function(){},
created: function(){},
beforeMount: function(){},
mounted: function(){},
beforeUpdate: function(){},
updated: function(){},
activated: function(){},
deactivated: function(){},
beforeDestroy: function(){},
destroyed: function(){}
}
</script>
<style scoped>
</style>
```

## Versioning
For further information, read [semver].

## Authors
* **Marcos Jesús Chávez V** - [onca-vega]

## License
MIT license.

[Spanish]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/README.md
[semver]: https://semver.org/spec/v2.0.0.html
[EinaPage]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage.png
[EinaPage-currentrows]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-currentrows.png
[EinaPage-currentpage]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-currentpage.png
[EinaPage-rowcount]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-rowcount.png
[EinaPage-pagecount]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-pagecount.png
[EinaPage-overlayclass]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-overlayclass.png
[EinaPage-detailsclass]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-detailsclass.png
[EinaPage-itemclass]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-itemclass.png
[EinaPage-dataclass]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-dataclass.png
[EinaPage-details]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-details.png
[EinaPage-firstArrow]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-firstArrow.png
[EinaPage-lastArrow]: https://github.com/onca-vega/EinaPage-Vue/blob/master/docs/image/EinaPage-lastArrow.png
[onca-vega]: https://github.com/onca-vega
89 changes: 75 additions & 14 deletions app/EinaPage.vue
Original file line number Diff line number Diff line change
@@ -1,55 +1,116 @@
<template>
<ul :class="overlayclass ? overlayclass : '_einapage__container'" class="_einapage__container-main">
<li :class="detailsclass ? detailsclass : '_einapage__details'">
<ul
:class="{
'_einapage__container-main _einapage__container' : true,
[overlayclass]: overlayclass
}">
<li
:class="{
'_einapage__details': true,
[detailsclass]: detailsclass
}">
<slot
name="details"
:currentrows="$props.currentrows"
:rowcount="$props.rowcount"
:currentpage="$props.currentpage"
:pagecount="$props.pagecount">
<span :class="dataclass ? dataclass : '_einapage__data'">
:pagecount="$props.pagecount"
name="details">
<span
:class="{
'_einapage__data': true,
[dataclass]: dataclass
}">
{{ details }}
</span>
</slot>
</li>
<li :class="itemclass ? itemclass : '_einapage__item _einapage__first'">
<li
:class="{
'_einapage__item _einapage__first': true,
[itemclass]: itemclass
}">
<a href="#" v-on:click.prevent="doPagination(1)">
<slot name="firstArrow">
<span :class="dataclass ? dataclass : '_einapage__data'" aria-hidden="true">&laquo;</span>
<span
:class="{
'_einapage__data': true,
[dataclass]: dataclass
}"
aria-hidden="true">&laquo;</span>
</slot>
</a>
</li>
<li v-show="shouldSeeMore[0]" :class="itemclass ? itemclass : '_einapage__item'">
<li
v-show="shouldSeeMore[0]"
:class="{
'_einapage__item': true,
[itemclass]: itemclass
}">
<a href="#" v-on:click.prevent>
<span :class="dataclass ? dataclass : '_einapage__data'" aria-hidden="true">...</span>
<span
:class="{
'_einapage__data': true,
[dataclass]: dataclass
}"
aria-hidden="true">...</span>
</a>
</li>
<li
v-for="page in pageCount"
:class="{
'active': activePage(page),
'_einapage__item': !itemclass,
'_einapage__item': true,
[itemclass]: itemclass
}">
<a href="#" v-on:click.prevent="doPagination(newPage(page))">
{{ newPage(page) }}
</a>
</li>
<li v-show="shouldSeeMore[1]" :class="itemclass ? itemclass : '_einapage__item'">
<li
v-show="shouldSeeMore[1]"
:class="{
'_einapage__item': true,
[itemclass]: itemclass
}">
<a href="#" v-on:click.prevent>
<span :class="dataclass ? dataclass : '_einapage__data'" aria-hidden="true">...</span>
<span
:class="{
'_einapage__data': true,
[dataclass]: dataclass
}"
aria-hidden="true">...</span>
</a>
</li>
<li :class="itemclass ? itemclass : '_einapage__item'">
<li
:class="{
'_einapage__item': true,
[itemclass]: itemclass
}">
<a href="#" v-on:click.prevent="doPagination(pagecount)">
<slot name="lastArrow">
<span :class="dataclass ? dataclass : '_einapage__data'" aria-hidden="true">&raquo;</span>
<span
:class="{
'_einapage__data': true,
[dataclass]: dataclass
}"
aria-hidden="true">&raquo;</span>
</slot>
</a>
</li>
</ul>
</template>
<script>
// _____________________________________________________________________________
// Eina Page for Vue
//
// Customizable VueJS component oriented to data pagination under MIT license.
//
// Author: Marcos Jesús Chávez Vega (onca-vega)
// github: https://github.com/onca-vega
// npm: https://www.npmjs.com/~onca-vega
// linkedin: https://linkedin.com/in/marcos-jesus-chavez-vega-onca
// _____________________________________________________________________________
export default {
name: "ovPagination",
components: {},
Expand Down
Loading

0 comments on commit 93e3dcd

Please sign in to comment.