Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
codenaz committed Aug 28, 2019
2 parents f0a8e01 + 04868eb commit 2a0dcc1
Show file tree
Hide file tree
Showing 7 changed files with 2,420 additions and 173 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function App() {

return (
<div>
<Pagination
<Paginator
totalRecords={data.length}
pageLimit={4}
pageNeighbours={1}
Expand All @@ -43,20 +43,20 @@ export default App;

## Props

| Property | Type | Default | Description |
| ------------------ | ------------------- | ------------ | -------------------------------------------------------------- |
| totalRecords | Number (required) | | The length of the data we are tabulating |
| pageLimit | Number (required) | | Minimum number of records per page |
| pageNeighbours | Number (required) | | Number of page blocks by the left and right of the middle page |
| setOffset | function (required) | | function that updates the offset state |
| setCurrentPage | function (required) | | function that updates the current page state |
| currentPage | Number (required) | | The current page state |
| pageContainerClass | String | `pagination` | Paginator container classname |
| pageActiveClass | String | `active` | Active page item classname |
| pageItemClass | String | `page-item` | Page item classname |
| pageLinkClass | String | `page-link` | Page link classname |
| pagePrevText | String or Node | `Next »` | Prev page item text |
| pageNextText | String or Node | `« Prev` | Next page item text |
| Property | Type | Default | Description |
| ------------------ | ------------------- | ----------------------- | -------------------------------------------------------------- |
| totalRecords | Number (required) | | The length of the data we are tabulating |
| pageLimit | Number (required) | | Minimum number of records per page |
| pageNeighbours | Number (required) | | Number of page blocks by the left and right of the middle page |
| setOffset | function (required) | | function that updates the offset state |
| setCurrentPage | function (required) | | function that updates the current page state |
| currentPage | Number (required) | | The current page state |
| pageContainerClass | String | `react-hooks-paginator` | Paginator container classname |
| pageActiveClass | String | `active` | Active page item classname |
| pageItemClass | String | `page-item` | Page item classname |
| pageLinkClass | String | `page-link` | Page link classname |
| pagePrevText | String or Node | `Next »` | Prev page item text |
| pageNextText | String or Node | `« Prev` | Next page item text |

## Example

Expand Down Expand Up @@ -89,7 +89,7 @@ function App() {
<li>{data}</li>
))}
</ul>
<Pagination
<Paginator
totalRecords={data.length}
pageLimit={pageLimit}
pageNeighbours={2}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

94 changes: 11 additions & 83 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"bootstrap": "^4.3.1",
"reactstrap": "^7.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "webpack",
Expand Down
3 changes: 1 addition & 2 deletions src/lib/paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ function Paginator(props) {
className={`${props.pageItemClass} ${
currentPage === page ? props.pageActiveClass : null
}`}
active={currentPage === page}
key={index}
>
<a
Expand All @@ -192,7 +191,7 @@ function Paginator(props) {
}

Paginator.defaultProps = {
pageContainerClass: 'pagination',
pageContainerClass: 'react-hooks-paginator',
pageActiveClass: 'active',
pageItemClass: 'page-item',
pageLinkClass: 'page-link',
Expand Down
48 changes: 43 additions & 5 deletions src/lib/style/main.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
@import '~bootstrap/scss/functions';
@import '~bootstrap/scss/variables';
@import '~bootstrap/scss/mixins';
@import '~bootstrap/scss/reboot';
@import '~bootstrap/scss/pagination';
.react-hooks-paginator {
align-items: center;
display: flex;
justify-content: center;
margin: 1rem 0;

.page-item {
list-style: none;
&:first-child {
.page-link {
margin-left: 0;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
}

&:last-child {
.page-link {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
}

&:hover,
&.active {
.page-link {
background-color: #3895d3;
border-color: #3895d3;
color: #fff;
}
}
}

.page-link {
border: 1px solid #dee2e6;
color: #4a4a4a;
margin-left: -1px;
outline: none;
padding: 0.5rem 0.75rem;
text-decoration: none;
transition: all 0.2s;
}
}
Loading

0 comments on commit 2a0dcc1

Please sign in to comment.