|
| 1 | +import React from 'react'; |
| 2 | +import { Component } from 'react'; |
| 3 | + |
| 4 | +class Paginator extends Component { |
| 5 | + |
| 6 | + render() { |
| 7 | + var pages = Math.ceil(this.props.total/this.props.pageSize); |
| 8 | + return ( |
| 9 | + <div className="container"> |
| 10 | + <div className="row padding"> |
| 11 | + <div className="col-xs-4 nopadding"> |
| 12 | + <button type="button" className="btn btn-default" onClick={this.props.previous}> |
| 13 | + <span className="glyphicon glyphicon-chevron-left" >"Previous"</span> |
| 14 | + </button> |
| 15 | + </div> |
| 16 | + <div className="col-xs-4 text-center"> |
| 17 | + <div className="legend">{this.props.total}, "page", {this.props.page}, "/", {pages}> |
| 18 | + </div> |
| 19 | + </div> |
| 20 | + <div className="col-xs-4 nopadding"> |
| 21 | + <button type="button" className="btn btn-default pull-right" onClick={this.props.next}>"Next" |
| 22 | + <span className="glyphicon glyphicon-chevron-right" >"Previous"</span> |
| 23 | + </button> |
| 24 | + </div> |
| 25 | + </div> |
| 26 | + </div> |
| 27 | + |
| 28 | + ); |
| 29 | + |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +var Paginator = React.createClass({displayName: "Paginator", |
| 34 | + |
| 35 | + render: function () { |
| 36 | + var pages = Math.ceil(this.props.total/this.props.pageSize); |
| 37 | + return ( |
| 38 | + React.createElement("div", {className: "container"}, |
| 39 | + React.createElement("div", {className: "row padding", style: {height: "40px"}}, |
| 40 | + React.createElement("div", {className: "col-xs-4 nopadding"}, |
| 41 | + React.createElement("button", {type: "button", className: "btn btn-default" + (this.props.page <= 1 ? " hidden" : ""), onClick: this.props.previous}, |
| 42 | + React.createElement("span", {className: "glyphicon glyphicon-chevron-left", "aria-hidden": "true"}), " Previous" |
| 43 | + ) |
| 44 | + ), |
| 45 | + React.createElement("div", {className: "col-xs-4 text-center"}, |
| 46 | + React.createElement("div", {className: "legend"}, this.props.total, " beers • page ", this.props.page, "/", pages) |
| 47 | + ), |
| 48 | + React.createElement("div", {className: "col-xs-4 nopadding"}, |
| 49 | + React.createElement("button", {type: "button", className: "btn btn-default pull-right" + (this.props.page >= pages ? " hidden" : ""), onClick: this.props.next}, |
| 50 | + "Next ", React.createElement("span", {className: "glyphicon glyphicon-chevron-right", "aria-hidden": "true"}) |
| 51 | + ) |
| 52 | + ) |
| 53 | + ) |
| 54 | + ) |
| 55 | + ); |
| 56 | + } |
| 57 | +}); |
0 commit comments