Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
chore: Improve examples to show currentPage usage
Browse files Browse the repository at this point in the history
  • Loading branch information
niconiahi committed Feb 24, 2021
1 parent d2154aa commit 05834af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {

const Demo: FC = () => {
// react hooks
const [currentPage, setCurrentPage] = useState<number>(3);
const [isPaginatorDisabled, setIsPaginatorDisabled] = useState<boolean>(
false
);
Expand Down Expand Up @@ -76,7 +77,8 @@ const Demo: FC = () => {
// handlers
const handlePageChange = (nextPage: number) => {
// -> request new data using the page number
console.log(nextPage);
setCurrentPage(nextPage);
console.log("request new data with ->", nextPage);
};

const handleDisableClick = () =>
Expand All @@ -89,6 +91,7 @@ const Demo: FC = () => {
activeStyles={activeStyles}
innerLimit={innerLimit}
outerLimit={outerLimit}
currentPage={currentPage}
normalStyles={normalStyles}
separatorStyles={separatorStyles}
pagesQuantity={pagesQuantity}
Expand Down
15 changes: 10 additions & 5 deletions examples/Demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Container } from "../src/components/Container";

const Demo: FC = () => {
// react hooks
const [currentPage, setCurrentPage] = useState<number>(3);
const [isPaginatorDisabled, setIsPaginatorDisabled] = useState<boolean>(
false
);
Expand Down Expand Up @@ -39,9 +40,10 @@ const Demo: FC = () => {
};

// handlers
const handlePageChange = (page: number) => {
const handlePageChange = (nextPage: number) => {
// -> request new data using the page number
console.log(page);
setCurrentPage(nextPage);
console.log("request new data with ->", nextPage);
};

const handleDisableClick = () =>
Expand All @@ -51,6 +53,7 @@ const Demo: FC = () => {
<ChakraProvider>
<Paginator
activeStyles={activeStyles}
currentPage={currentPage}
innerLimit={innerLimit}
isDisabled={isPaginatorDisabled}
normalStyles={normalStyles}
Expand All @@ -60,19 +63,21 @@ const Demo: FC = () => {
separatorStyles={separatorStyles}
>
<Container align="center" justify="space-between" p={4} w="full">
<Previous>
<Previous bg="green.300">
Previous
{/* Or an icon from `react-icons` */}
</Previous>
<PageGroup isInline align="center" />
<Next>
<Next bg="green.300">
Next
{/* Or an icon from `react-icons` */}
</Next>
</Container>
</Paginator>
<Flex align="center" justify="center" w="full">
<Button onClick={handleDisableClick}>Disable ON / OFF</Button>
<Button ml={4} onClick={handleDisableClick}>
Disable ON / OFF
</Button>
</Flex>
</ChakraProvider>
);
Expand Down

0 comments on commit 05834af

Please sign in to comment.