-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Pagination): Avoir une valeur props pour la page courante. #206
Conversation
onPageChange={(page: number) => setCurrentPage(page)} | ||
activePage={currentPage} | ||
/> | ||
<Pagination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi la pagination est présente deux fois?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est un use case dans les maquettes actuelle sur le projet Centralize, on veux avoir 2 paginations synchro en haut et en bas d'une Table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bref j'ai enlevé le deuxième et changer le nom pour ControlledInput
@@ -16,6 +16,27 @@ export const Normal: Story = () => ( | |||
<Pagination totalPages={50} numberOfResults={1530} /> | |||
</> | |||
); | |||
|
|||
export const LinkedPagination: Story = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je mettrais ControlledPagination
, pour faire référence aux controlled inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça fais du sens je ferais la modification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est fait !
setCurrentPage(activePage); | ||
} | ||
}, [activePage]); | ||
|
||
function changePage(page: number): void { | ||
setCurrentPage(page); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sinon, peut-être juste appeler setCurrentPage
ici quand activePage
n'est pas défini
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est fait !
const [currentPage, setCurrentPage] = useState(1); | ||
|
||
return ( | ||
<> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas besoin du fragment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est fait
@@ -116,6 +121,7 @@ export function Pagination({ | |||
defaultActivePage = 1, | |||
pagesShown = 3, | |||
onPageChange = () => undefined, | |||
activePage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Petit dernier détail, il faudrait changer la ligne 129 pour changer
const [currentPage, setCurrentPage] = useState(clamp(defaultActivePage, 1, totalPages));
pour
const [currentPage, setCurrentPage] = useState(clamp(activePage || defaultActivePage, 1, totalPages));
pour prendre en compte le activePage
au premier render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C'est fait
…vePage is present
Cette PR ajoute la props "activePage" sur la pagination pour avoir plus de contrôle sur le state de celle-ci. J'ai ajouté un example dans le Storybook qui s'appelle LinkedPagination avec deux paginations qui partage le même state "activePage".
https://jira.equisoft.com/secure/RapidBoard.jspa?rapidView=786&projectKey=DS&view=detail&selectedIssue=DS-173&quickFilter=4537