-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
2f45370
commit 135940a
Showing
1 changed file
with
36 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
function Pagination() { | ||
return <p>Pagination Area</p>; | ||
import styled from 'styled-components'; | ||
|
||
const { Fragment } = wp.element; | ||
|
||
const Button = styled.button.attrs(() => ({ | ||
type: "button", | ||
}))``; | ||
|
||
function Pagination(props) { | ||
let nextIndex = null; | ||
let prevIndex = null; | ||
|
||
// Finding Next Page Start Index | ||
if (props.results !== null && typeof props.results.queries.nextPage !== 'undefined') { | ||
nextIndex = props.results.queries.nextPage[0].startIndex; | ||
console.log(nextIndex); | ||
} | ||
|
||
// Finding Prev Page Start Index | ||
if (props.results !== null && typeof props.results.queries.previousPage !== 'undefined') { | ||
prevIndex = props.results.queries.previousPage[0].startIndex; | ||
console.log(prevIndex); | ||
} | ||
|
||
return ( | ||
<Fragment> | ||
{ prevIndex !== null | ||
? <Button><</Button> | ||
: null | ||
} | ||
{ nextIndex !== null | ||
? <Button>></Button> | ||
: null | ||
} | ||
</Fragment> | ||
); | ||
} | ||
|
||
export default Pagination; |