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

Commit 9eaa8f0

Browse files
authored
Merge pull request #13 from AZaviruha/dev
ES5 => ES6
2 parents c28e8e5 + 03c4f60 commit 9eaa8f0

30 files changed

+22207
-30416
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["latest", "react"]
3+
}

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
karma.conf.js
2+
gulpfile.js
3+
webpack.config.js

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "airbnb",
4+
"rules": {
5+
"indent": [1, "tab"],
6+
"no-tabs": "off",
7+
"no-multi-spaces": "off",
8+
"key-spacing": "off",
9+
"no-plusplus": "off",
10+
"no-use-before-define": "off",
11+
"react/jsx-indent": [2, "tab"],
12+
"react/jsx-indent-props": [2, "tab"]
13+
}
14+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
spec/bundle.spec.js
3+
npm-debug.log

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.7.9

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
language: node_js
22
node_js:
3-
- "0.11"
4-
- "0.10"
3+
- "6"

README.md

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,86 +3,77 @@
33
[![Build Status][travis-image]][travis-url]<br />
44
[![NPM version][npm-stats]][npm-url]
55

6-
## TODO
7-
* Move it all to ES6
86

97
## Getting started
10-
### browserify
11-
```sh
12-
var Pager = require( 'react-pager' );
13-
```
148

15-
### Global scripts
16-
dist/pager.min.js is prebuilded for using in global `<script>` tag.
17-
(It's used in JSFiddle demo).
9+
```javascript
10+
import React from 'react';
11+
import { render } from 'react-dom';
12+
import Pager from 'react-pager';
13+
14+
class App extends React.Component {
15+
constructor(props) {
16+
super(props);
17+
18+
this.handlePageChanged = this.handlePageChanged.bind(this);
19+
20+
this.state = {
21+
total: 11,
22+
current: 7,
23+
visiblePage: 3,
24+
};
25+
}
26+
27+
handlePageChanged(newPage) {
28+
this.setState({ current : newPage });
29+
}
30+
31+
render() {
32+
return (
33+
<Pager
34+
total={this.state.total}
35+
current={this.state.current}
36+
visiblePages={this.state.visiblePage}
37+
titles={{ first: '<|', last: '>|' }}
38+
onPageChanged={this.handlePageChanged}
39+
/>
40+
);
41+
}
42+
}
43+
44+
window.onload = () => {
45+
render(React.createElement(App), document.querySelector('#app'));
46+
};
1847

19-
20-
## Usage
21-
```
22-
var Pager = require( 'react-pager' );
23-
24-
var PagerDemo = React.createClass({
25-
getInitialState: function () {
26-
return {
27-
total: 11,
28-
current: 7,
29-
visiblePages: 3
30-
};
31-
},
32-
33-
handlePageChanged: function ( newPage ) {
34-
this.setState({ current : newPage });
35-
},
36-
37-
render: function() {
38-
return (<Pager total={this.state.total}
39-
current={this.state.current}
40-
41-
{/* Optional */}
42-
titles={{
43-
first: 'First',
44-
prev: '\u00AB',
45-
prevSet: '...',
46-
nextSet: '...',
47-
next: '\u00BB',
48-
last: 'Last'
49-
}}
50-
51-
visiblePages={this.state.visiblePages}
52-
onPageChanged={this.handlePageChanged}/>);
53-
}
54-
});
55-
56-
React.render(<PagerDemo />, document.body);
5748
```
5849

59-
6050
## How it looks like*
61-
```
62-
First | Prev | ... | 6 | 7 | 8 | 9 | ... | Next | Last
63-
```
51+
52+
![First | Prev | ... | 6 | 7 | 8 | 9 | ... | Next | Last](./img/pager-default.png)
6453

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

6756

6857
## Demo
69-
```shell
70-
gulp demo -p 8003
71-
```
72-
or
73-
```shell
74-
./node_modules/.bin/gulp demo -p 8003
75-
```
7658

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

7963

8064
## Tests
65+
8166
```sh
8267
npm test
8368
```
8469

8570
## Changelog
71+
72+
### v1.2.0
73+
* Rewrited all to ES6.
74+
* Switched from gulp + browserify to webpack.
75+
* Now officially supports only React >= 15.0.0
76+
8677
### v1.1.4
8778
* Updated to React 15. Thanks to contributors!
8879

demo/app.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)