-
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.
pagination logic is updated, and better READ.me
- Loading branch information
1 parent
b209997
commit cccebd1
Showing
5 changed files
with
255 additions
and
152 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,40 +1,65 @@ | ||
## pagination-with-react | ||
# Project Title | ||
|
||
React Pagination | ||
|
||
## Installation | ||
Run the following command: | ||
`npm install pagination-with-react` | ||
### Documentation | ||
Props | ||
|
||
## Usage | ||
import { ReactPagination } from 'pagination-with-react'; | ||
# Props: | ||
``` | ||
totalItems [required] | ||
numberOfItemsPerPage [required] | ||
numberOfPagesPerScreen [required] | ||
totalNumberOfPages = round(totalItems / numberOfItemsPerPage); [required] | ||
totalScreensNumber = round(totalNumberOfPages / numberOfPagesPerScreen); [required] | ||
onPageButtonClick [required] | ||
currentActiveIndex [required] | ||
Prop | Type | ||
---------|--------- | ||
currentActiveIndex | Number | ||
children | children app | ||
numberOfPagesPerScreen| Number, How many pages numbers should user see per screen? | ||
totalNumberOfPages | Number, Total number of pages | ||
onPageButtonClick| Function, callback function for onClick pagination button to get the current page number | ||
prefix | String or React Component, if you want to add anything before pagination buttons | ||
suffix| String or React Component, if you want to add anything after pagination buttons | ||
icons | Object with keys `left, leftMost, right, rightMost ` if you want to change the icons of a arrow | ||
|
||
``` | ||
Icons Default Values | ||
icons: { | ||
left: <span>←</span>, | ||
leftMost: <span>⇇</span>, | ||
right: <span>→</span>, | ||
rightMost: <span>⇉</span>, | ||
} | ||
``` | ||
|
||
|
||
# Basic Example | ||
### Installing | ||
|
||
npm install pagination-with-react | ||
|
||
``` | ||
import { ReactPagination } from 'pagination-with-react'; | ||
<ReactPagination | ||
totalScreensNumber={totalScreensNumber} | ||
totalNumberOfPages={totalNumberOfPages} | ||
numberOfPagesPerScreen={numberOfPagesPerScreen} | ||
onPageButtonClick={(data) => { | ||
this.setState({ | ||
data, | ||
}) | ||
}} | ||
currentActiveIndex={this.state.id} | ||
> | ||
{this.state.data} | ||
</ReactPagination> | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { ReactPagination } from 'pagination-with-react'; | ||
class App extends React.Component{ | ||
constructor(){ | ||
super() | ||
this.state={ | ||
id: 1, | ||
} | ||
} | ||
render() { | ||
return ( | ||
<ReactPagination | ||
totalNumberOfPages={50} | ||
numberOfPagesPerScreen={10} | ||
onPageButtonClick={(id) => { | ||
this.setState({ | ||
id, | ||
}) | ||
console.log(this.state) | ||
}} | ||
currentActiveIndex={this.state.id} | ||
> | ||
<h1>Children {this.state.id}</h1> | ||
</ReactPagination> | ||
) | ||
} | ||
} | ||
``` |
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
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
Oops, something went wrong.