-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,4 +92,8 @@ | |
} | ||
} | ||
} | ||
|
||
&__pagination { | ||
margin-top: 16px; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/Campaigns/Blocks/shared/components/Pagination/index.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import {__} from '@wordpress/i18n'; | ||
|
||
import './styles.scss'; | ||
|
||
export default ({currentPage, totalPages, setPage, disabled = false}: PaginationProps) => { | ||
if (1 >= totalPages) { | ||
return null; | ||
} | ||
|
||
const nextPage = currentPage + 1; | ||
const previousPage = currentPage - 1; | ||
|
||
return ( | ||
<div className="give-campaign-components-pagination"> | ||
<div className="give-campaign-components-pagination__pages"> | ||
<div className="give-campaign-components-pagination__pages-links"> | ||
{previousPage > 0 ? ( | ||
<> | ||
<a | ||
href="#" | ||
title={__('Previous page', 'give')} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
setPage(previousPage); | ||
}} | ||
> | ||
‹ | ||
</a> | ||
</> | ||
) : ( | ||
<span className="give-campaign-components-pagination__pages-links-disabled">‹</span> | ||
)} | ||
|
||
<span className="give-campaign-components-pagination__pages-links-info"> | ||
<span>{currentPage}</span> | ||
{__('of', 'give')} | ||
<span>{totalPages}</span> | ||
</span> | ||
|
||
{nextPage <= totalPages ? ( | ||
<> | ||
<a | ||
href="#" | ||
title={__('Next page', 'give')} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
setPage(nextPage); | ||
}} | ||
> | ||
› | ||
</a> | ||
</> | ||
) : ( | ||
<span className="give-campaign-components-pagination__pages-links-disabled">›</span> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
interface PaginationProps { | ||
currentPage: number, | ||
totalPages: number, | ||
setPage: (page: number) => void, | ||
disabled?: boolean | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Campaigns/Blocks/shared/components/Pagination/styles.scss
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.give-campaign-components-pagination { | ||
display: flex; | ||
padding: 8px 0; | ||
flex-direction: row; | ||
|
||
&__pages { | ||
display: flex; | ||
|
||
&-links { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 4px; | ||
|
||
a, | ||
span, | ||
&-info { | ||
padding: 6px 12px; | ||
text-decoration: none !important; | ||
background-color: #f6f6f6; | ||
color: #363636; | ||
border-radius: 4px; | ||
|
||
span { | ||
padding: 0 4px; | ||
} | ||
} | ||
|
||
&-disabled { | ||
opacity: 0.7; | ||
cursor: not-allowed; | ||
} | ||
} | ||
} | ||
} |
This file contains 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