mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import Router from 'react-router';
|
|
|
|
let Link = Router.Link;
|
|
|
|
let PaginationButton = React.createClass({
|
|
propTypes: {
|
|
direction: React.PropTypes.oneOf(['previous', 'next']),
|
|
goToPage: React.PropTypes.func.isRequired,
|
|
currentPage: React.PropTypes.number.isRequired
|
|
},
|
|
|
|
render() {
|
|
let page = parseInt(this.props.currentPage, 10);
|
|
let directionDisplay;
|
|
|
|
let isDisabled = '';
|
|
|
|
if(this.props.direction === 'previous') {
|
|
page -= 1;
|
|
directionDisplay = (
|
|
<span>
|
|
<span aria-hidden="true">←</span> Previous
|
|
</span>
|
|
);
|
|
} else {
|
|
page += 1;
|
|
directionDisplay = (
|
|
<span>
|
|
Next <span aria-hidden="true">→</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
if(page === 0) {
|
|
isDisabled += ' disabled';
|
|
}
|
|
|
|
return (
|
|
<li className={this.props.direction + isDisabled }>
|
|
<Link to="pieces"
|
|
query={{page}}
|
|
onClick={this.props.goToPage(page)}>
|
|
{directionDisplay}
|
|
</Link>
|
|
</li>
|
|
);
|
|
}
|
|
});
|
|
|
|
export default PaginationButton; |