Created
August 20, 2015 22:05
-
-
Save laserpants/9f3a77c1d24c0ca23cd3 to your computer and use it in GitHub Desktop.
React-bootstrap paging component for Griddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BootstrapPager = React.createClass({ | |
getDefaultProps() { | |
return { | |
currentPage : 0, | |
maxPage : 0, | |
maxButtons : 10 | |
} | |
}, | |
handleSelect(event, selectedEvent) { | |
let page = selectedEvent.eventKey | |
if (page > this.props.maxPage || !page) | |
return | |
this.props.setPage(page-1) | |
}, | |
render() { | |
let maxPage = this.props.maxPage | |
if (maxPage < 2) { | |
return <span /> | |
} | |
return ( | |
<Pagination | |
bsSize = 'small' | |
items = {maxPage} | |
prev = {true} | |
next = {true} | |
ellipsis = {true} | |
maxButtons = {Math.min(this.props.maxButtons, maxPage)} | |
activePage = {this.props.currentPage+1} | |
onSelect = {this.handleSelect} /> | |
) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment