PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.17.2
GiveWP – Donation Plugin and Fundraising Platform v3.17.2
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Views / Components / Pagination / index.js
index.js
104 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import PropTypes from 'prop-types';
2
3 import { __ } from '@wordpress/i18n'
4
5 const Pagination = ({currentPage = 1, totalPages = 0, disabled = false, setPage = () => {}}) => {
6 if (1 >= totalPages) {
7 return false;
8 }
9
10 const nextPage = parseInt(currentPage) + 1;
11 const previousPage = parseInt(currentPage) - 1;
12
13 return (
14 <div className="tablenav bottom">
15 <div className="tablenav-pages">
16 <div className="pagination-links">
17 {previousPage > 0 ? (
18 <>
19 <a
20 href="#"
21 className="tablenav-pages-navspan button"
22 onClick={(e) => {
23 e.preventDefault();
24 if (!disabled) {
25 setPage(1);
26 }
27 }}
28 >
29 «
30 </a>{' '}
31 <a
32 href="#"
33 className="tablenav-pages-navspan button"
34 onClick={(e) => {
35 e.preventDefault();
36 if (!disabled) {
37 setPage(parseInt(currentPage) - 1);
38 }
39 }}
40 >
41
42 </a>
43 </>
44 ) : (
45 <span className="tablenav-pages-navspan button disabled"></span>
46 )}
47
48 <span className="screen-reader-text">{__('Current Page', 'give')}</span>
49 <span id="table-paging" className="paging-input">
50 <span className="tablenav-paging-text">
51 {' '}
52 {currentPage} {__('of', 'give')} <span className="total-pages">{totalPages}</span>{' '}
53 </span>
54 </span>
55
56 {nextPage <= totalPages ? (
57 <>
58 <a
59 href="#"
60 className="tablenav-pages-navspan button"
61 onClick={(e) => {
62 e.preventDefault();
63 if (!disabled) {
64 setPage(parseInt(currentPage) + 1);
65 }
66 }}
67 >
68
69 </a>{' '}
70 <a
71 href="#"
72 className="tablenav-pages-navspan button"
73 onClick={(e) => {
74 e.preventDefault();
75 if (!disabled) {
76 setPage(totalPages);
77 }
78 }}
79 >
80 »
81 </a>
82 </>
83 ) : (
84 <span className="tablenav-pages-navspan button disabled"></span>
85 )}
86 </div>
87 </div>
88 </div>
89 );
90 };
91
92 Pagination.propTypes = {
93 // Current page
94 currentPage: PropTypes.number.isRequired,
95 // Total number of pages
96 totalPages: PropTypes.number.isRequired,
97 // Function to set the next/previous page
98 setPage: PropTypes.func.isRequired,
99 // Is pagination disabled
100 disabled: PropTypes.bool.isRequired,
101 };
102
103 export default Pagination;
104