Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #13 from AZaviruha/dev
Browse files Browse the repository at this point in the history
ES5 => ES6
  • Loading branch information
AZaviruha authored Oct 17, 2016
2 parents c28e8e5 + 03c4f60 commit 9eaa8f0
Show file tree
Hide file tree
Showing 30 changed files with 22,207 additions and 30,416 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["latest", "react"]
}
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
karma.conf.js
gulpfile.js
webpack.config.js
14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"rules": {
"indent": [1, "tab"],
"no-tabs": "off",
"no-multi-spaces": "off",
"key-spacing": "off",
"no-plusplus": "off",
"no-use-before-define": "off",
"react/jsx-indent": [2, "tab"],
"react/jsx-indent-props": [2, "tab"]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
spec/bundle.spec.js
npm-debug.log
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.7.9
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
language: node_js
node_js:
- "0.11"
- "0.10"
- "6"
109 changes: 50 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,77 @@
[![Build Status][travis-image]][travis-url]<br />
[![NPM version][npm-stats]][npm-url]

## TODO
* Move it all to ES6

## Getting started
### browserify
```sh
var Pager = require( 'react-pager' );
```

### Global scripts
dist/pager.min.js is prebuilded for using in global `<script>` tag.
(It's used in JSFiddle demo).
```javascript
import React from 'react';
import { render } from 'react-dom';
import Pager from 'react-pager';

class App extends React.Component {
constructor(props) {
super(props);

this.handlePageChanged = this.handlePageChanged.bind(this);

this.state = {
total: 11,
current: 7,
visiblePage: 3,
};
}

handlePageChanged(newPage) {
this.setState({ current : newPage });
}

render() {
return (
<Pager
total={this.state.total}
current={this.state.current}
visiblePages={this.state.visiblePage}
titles={{ first: '<|', last: '>|' }}
onPageChanged={this.handlePageChanged}
/>
);
}
}

window.onload = () => {
render(React.createElement(App), document.querySelector('#app'));
};


## Usage
```
var Pager = require( 'react-pager' );
var PagerDemo = React.createClass({
getInitialState: function () {
return {
total: 11,
current: 7,
visiblePages: 3
};
},
handlePageChanged: function ( newPage ) {
this.setState({ current : newPage });
},
render: function() {
return (<Pager total={this.state.total}
current={this.state.current}
{/* Optional */}
titles={{
first: 'First',
prev: '\u00AB',
prevSet: '...',
nextSet: '...',
next: '\u00BB',
last: 'Last'
}}
visiblePages={this.state.visiblePages}
onPageChanged={this.handlePageChanged}/>);
}
});
React.render(<PagerDemo />, document.body);
```


## How it looks like*
```
First | Prev | ... | 6 | 7 | 8 | 9 | ... | Next | Last
```

![First | Prev | ... | 6 | 7 | 8 | 9 | ... | Next | Last](./img/pager-default.png)

\* Bootstrap 3.0 is required by default, but you can replace it with your own css.


## Demo
```shell
gulp demo -p 8003
```
or
```shell
./node_modules/.bin/gulp demo -p 8003
```

[JSFiddle](http://jsfiddle.net/azaviruha/69z2wepo/4060/)
Just open `demo/index.html` in your browser.
Or see interactive demo [here](http://azaviruha.github.io/demo/react-pager/).



## Tests

```sh
npm test
```

## Changelog

### v1.2.0
* Rewrited all to ES6.
* Switched from gulp + browserify to webpack.
* Now officially supports only React >= 15.0.0

### v1.1.4
* Updated to React 15. Thanks to contributors!

Expand Down
11 changes: 0 additions & 11 deletions demo/app.js

This file was deleted.

Loading

0 comments on commit 9eaa8f0

Please sign in to comment.