Skip to content

Commit

Permalink
feat: hide next/previous page buttons when all rows can fit on one page
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stoyanov committed Mar 6, 2021
1 parent 4c1f2c9 commit 9f3b882
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions ui/components/src/Table/TablePagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,33 @@ export const TablePagination: FC<UsePaginationInstanceProps<{

return (
<Box variant="table.pagination.container">
<Box variant="table.pagination.navigation">
<Box variant="table.pagination.navigation.button">
<Button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{'<<'}
</Button>
{(canPreviousPage || canNextPage) && (
<Box variant="table.pagination.navigation">
<Box variant="table.pagination.navigation.button">
<Button onClick={() => gotoPage(0)} disabled={!canPreviousPage}>
{'<<'}
</Button>
</Box>
<Box variant="table.pagination.navigation.button">
<Button onClick={() => previousPage()} disabled={!canPreviousPage}>
{'<'}
</Button>
</Box>
<Box variant="table.pagination.navigation.button">
<Button onClick={() => nextPage()} disabled={!canNextPage}>
{'>'}
</Button>
</Box>
<Box variant="table.pagination.navigation.button">
<Button
onClick={() => gotoPage(pageCount - 1)}
disabled={!canNextPage}
>
{'>>'}
</Button>
</Box>
</Box>
<Box variant="table.pagination.navigation.button">
<Button onClick={() => previousPage()} disabled={!canPreviousPage}>
{'<'}
</Button>
</Box>
<Box variant="table.pagination.navigation.button">
<Button onClick={() => nextPage()} disabled={!canNextPage}>
{'>'}
</Button>
</Box>
<Box variant="table.pagination.navigation.button">
<Button
onClick={() => gotoPage(pageCount - 1)}
disabled={!canNextPage}
>
{'>>'}
</Button>
</Box>
</Box>
)}
{pageVisible && (
<Box variant="table.pagination.page">{pageResolvedTemplate}</Box>
)}
Expand Down

0 comments on commit 9f3b882

Please sign in to comment.