content.js
1 year ago
filters.js
1 year ago
header.js
1 year ago
import-modal.js
1 year ago
list-item.js
1 year ago
notices.js
5 years ago
pagination.js
5 years ago
preview.js
1 year ago
publish-button.js
2 years ago
template-predefine.js
2 years ago
templates-content.js
1 year ago
tpc-templates-button.js
2 years ago
pagination.js
29 lines
| 1 | import { Button, ButtonGroup } from '@wordpress/components'; |
| 2 | |
| 3 | const Pagination = ( { total, current, onChange } ) => { |
| 4 | if ( total < 2 ) { |
| 5 | return null; |
| 6 | } |
| 7 | |
| 8 | const pages = []; |
| 9 | |
| 10 | for ( let i = 0; i < total; i++ ) { |
| 11 | const isCurrent = i === current; |
| 12 | |
| 13 | pages.push( |
| 14 | <Button |
| 15 | key={ `page-${ i }` } |
| 16 | isPrimary={ isCurrent } |
| 17 | disabled={ isCurrent } |
| 18 | onClick={ () => onChange( i ) } |
| 19 | > |
| 20 | { i + 1 } |
| 21 | </Button> |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | return <ButtonGroup className="pagination">{ pages }</ButtonGroup>; |
| 26 | }; |
| 27 | |
| 28 | export default Pagination; |
| 29 |