PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 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 All 255 releases
give / src / Views / Components / Pagination / index.js

index.js in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Views/Components/Pagination/index.js

93 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n'
2
3 const Pagination = ({currentPage = 1, totalPages = 0, disabled = false, setPage = (page) => {}}) => {
4 if (1 >= totalPages) {
5 return null;
6 }
7
8 const nextPage = parseInt(currentPage) + 1;
9 const previousPage = parseInt(currentPage) - 1;
10
11 return (
12 <div className="tablenav bottom">
13 <div className="tablenav-pages">
14 <div className="pagination-links">
15 {previousPage > 0 ? (
16 <>
17 <a
18 href="#"
19 className="tablenav-pages-navspan button"
20 onClick={(e) => {
21 e.preventDefault();
22 if (!disabled) {
23 setPage(1);
24 }
25 }}
26 >
27 «
28 </a>{' '}
29 <a
30 href="#"
31 className="tablenav-pages-navspan button"
32 onClick={(e) => {
33 e.preventDefault();
34 if (!disabled) {
35 setPage(parseInt(currentPage) - 1);
36 }
37 }}
38 >
39
40 </a>
41 </>
42 ) : (
43 <span className="tablenav-pages-navspan button disabled"></span>
44 )}
45
46 <span className="screen-reader-text">{__('Current Page', 'give')}</span>
47 <span id="table-paging" className="paging-input">
48 <span className="tablenav-paging-text">
49 {' '}
50 {currentPage} {__('of', 'give')} <span className="total-pages">{totalPages}</span>{' '}
51 </span>
52 </span>
53
54 {nextPage <= totalPages ? (
55 <>
56 <a
57 href="#"
58 className="tablenav-pages-navspan button"
59 onClick={(e) => {
60 e.preventDefault();
61 if (!disabled) {
62 setPage(parseInt(currentPage) + 1);
63 }
64 }}
65 >
66
67 </a>{' '}
68 <a
69 href="#"
70 className="tablenav-pages-navspan button"
71 onClick={(e) => {
72 e.preventDefault();
73 if (!disabled) {
74 setPage(totalPages);
75 }
76 }}
77 >
78 »
79 </a>
80 </>
81 ) : (
82 <span className="tablenav-pages-navspan button disabled"></span>
83 )}
84 </div>
85 </div>
86 </div>
87 );
88 };
89
90
91
92 export default Pagination;
93