Skip to content

Commit

Permalink
fix(pagination): add & back button
Browse files Browse the repository at this point in the history
  • Loading branch information
BQXBQX committed Nov 12, 2024
1 parent 2dde7fe commit 7db19ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions packages/ui-react/lib/Pagination/Pagination.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ export const DefaultPagination: Story = {
export const ExamplePagination: Story = {
args: {
...defaultProps,
total: 431,
},
};
33 changes: 18 additions & 15 deletions packages/ui-react/lib/Pagination/PaginationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,25 @@ export const PaginationItemImpl = ({

const paginationStoreContext = useContext(PaginationStoreContext);

const handleClick = useCallback((type: 'select' | 'add' | 'delete' | 'none', index?: number) => {
const activePage = paginationStoreContext?.activePage ?? 0;
const handleClick = useCallback(
(type: 'select' | 'add' | 'delete' | 'none', index?: number) => {
const activePage = paginationStoreContext?.activePage ?? 0;

if (type === 'select' && index !== undefined) {
!activePage && changeCurrentPage(index + 1);
paginationStoreContext && paginationStoreContext.onChange?.(index + 1);
} else if (type === 'add') {
!activePage && increaseCurrentPage();
paginationStoreContext &&
paginationStoreContext.onChange?.(activePage ? activePage + 1 : currentPage + 1);
} else if (type === 'delete') {
!activePage && decreaseCurrentPage();
paginationStoreContext &&
paginationStoreContext.onChange?.(activePage ? activePage + 1 : currentPage - 1);
}
}, []);
if (type === 'select' && index !== undefined) {
!activePage && changeCurrentPage(index + 1);
paginationStoreContext && paginationStoreContext.onChange?.(index + 1);
} else if (type === 'add') {
!activePage && increaseCurrentPage();
paginationStoreContext &&
paginationStoreContext.onChange?.(activePage ? activePage + 1 : currentPage + 1);
} else if (type === 'delete') {
!activePage && decreaseCurrentPage();
paginationStoreContext &&
paginationStoreContext.onChange?.(activePage ? activePage + 1 : currentPage - 1);
}
},
[currentPage],
);

return (
<Button
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ui-aurora/react",
"version": "0.0.31",
"version": "0.0.32",
"description": "A React UI library built for SASTOJ",
"author": "sast",
"license": "MIT",
Expand Down

1 comment on commit 7db19ef

@vercel
Copy link

@vercel vercel bot commented on 7db19ef Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sast-ui – ./

sast-ui-sast.vercel.app
sast-ui-git-main-sast.vercel.app

Please sign in to comment.