Created
May 13, 2021 13:20
-
-
Save padurets/6c5f51b3022be1ec06bb4bc6a5c5f8a7 to your computer and use it in GitHub Desktop.
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
/* eslint-disable no-console */ | |
import React, { useState } from 'react'; | |
import { withKnobs, number, text } from '@storybook/addon-knobs'; | |
import { storyDecoratorCase } from '../../../../.storybook'; | |
import Pagination from '../Pagination'; | |
import PaginationView from '../PaginationView'; | |
import PaginationShowMore from '../PaginationShowMore'; | |
import { SomePage, SomePageContent } from './components'; | |
import { usePaginationApiBased } from './hooks'; | |
import styles from './components.scss'; | |
export function InternalHook() { | |
const [pageCurrent, setPageCurrent] = useState(1); | |
return ( | |
<Pagination | |
separator={text('separator', '...')} | |
itemsTotal={number('itemsTotal', 1024)} | |
itemsAtPage={number('itemsAtPage', 30)} | |
pageLinkPrefix={text('pageLinkPrefix', '?page=')} | |
pageLimit={number('pageLimit', 6)} | |
pageCurrent={pageCurrent} | |
onPageSelect={setPageCurrent} | |
/> | |
); | |
} | |
export function ShowMore() { | |
const { pageData, pagination } = usePaginationApiBased(); | |
return ( | |
<SomePage> | |
<SomePageContent list={pageData} /> | |
{!pagination.isVisibleShowMore ? null : ( | |
<PaginationShowMore | |
className={styles.buttonShowMore} | |
onClick={pagination.onShowMore} | |
> | |
Show more | |
</PaginationShowMore> | |
)} | |
</SomePage> | |
); | |
} | |
export function PaginationWithShowMore() { | |
const { pageData, pagination } = usePaginationApiBased(); | |
return ( | |
<SomePage> | |
<SomePageContent list={pageData} /> | |
{!pagination.isVisibleShowMore ? null : ( | |
<PaginationShowMore | |
className={styles.buttonShowMore} | |
onClick={pagination.onShowMore} | |
> | |
Show more | |
</PaginationShowMore> | |
)} | |
<PaginationView | |
model={pagination.model} | |
onPageSelect={pagination.onPageSelect} | |
/> | |
</SomePage> | |
); | |
} | |
export default { | |
title: 'core/Pagination', | |
decorators: [withKnobs, storyDecoratorCase], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment