Skip to content

Commit

Permalink
fix(Pagination): Stop clipping two digit page sizes with fixed width (#…
Browse files Browse the repository at this point in the history
…462)

* fix(pagination): stop clipping two digit page size with fixed width

* fix(pagination): set min width to 5rem

* fix(pagination): optimise wrapping of pagination elements for mobile

---------

Co-authored-by: Ján Hamara <[email protected]>
  • Loading branch information
JanHamara and Ján Hamara authored Jan 8, 2025
1 parent fcb8a2c commit 4db46dc
Showing 1 changed file with 41 additions and 36 deletions.
77 changes: 41 additions & 36 deletions src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const Container = styled.div`

const ButtonsContainer = styled(Box)`
display: flex;
justify-content: center;
position: relative;
align-items: center;
gap: ${Spaces[1]};
`;

const IconButton = styled.button`
Expand Down Expand Up @@ -134,49 +134,54 @@ const Pagination: React.FC<PaginationProps> = ({
return (
<Container>
<ButtonsContainer>
{hasMultiplePageSizes && (
<Box aria-label={ariaLabelSelectPageSizeContainer} position="absolute" left="0" width="4.5em">
<SelectList
options={pageSizes}
onChange={onSelectPageSize}
value={pageSizes.find(sizeOption => sizeOption.value === pageSize.toString())}
/>
</Box>
)}
{size !== 'small' && (
<IconButton aria-label={ariaLabelFirst} disabled={isFirstPage} onClick={onSkipBackward}>
<BackwardLastIcon
<Box flex={1}>
{hasMultiplePageSizes && (
<Box aria-label={ariaLabelSelectPageSizeContainer} width="fit-content" minWidth="5rem">
<SelectList
options={pageSizes}
onChange={onSelectPageSize}
value={pageSizes.find(sizeOption => sizeOption.value === pageSize.toString())}
/>
</Box>
)}
</Box>

<Box>
{size !== 'small' && (
<IconButton aria-label={ariaLabelFirst} disabled={isFirstPage} onClick={onSkipBackward}>
<BackwardLastIcon
size="small"
color={isFirstPage ? Colors.AUTHENTIC_BLUE_200 : Colors.AUTHENTIC_BLUE_900}
/>
</IconButton>
)}

<IconButton aria-label={ariaLabelPrevious} disabled={isFirstPage} onClick={onPrevPage}>
<BackwardIcon
size="small"
color={isFirstPage ? Colors.AUTHENTIC_BLUE_200 : Colors.AUTHENTIC_BLUE_900}
/>
</IconButton>
)}

<IconButton aria-label={ariaLabelPrevious} disabled={isFirstPage} onClick={onPrevPage}>
<BackwardIcon
size="small"
color={isFirstPage ? Colors.AUTHENTIC_BLUE_200 : Colors.AUTHENTIC_BLUE_900}
/>
</IconButton>

<IconButton aria-label={ariaLabelNext} disabled={isLastPage} onClick={onNextPage}>
<ForwardIcon
size="small"
color={isLastPage ? Colors.AUTHENTIC_BLUE_200 : Colors.AUTHENTIC_BLUE_900}
/>
</IconButton>

{size !== 'small' && (
<IconButton aria-label={ariaLabelLast} disabled={isLastPage} onClick={onSkipForward}>
<ForwardLastIcon

<IconButton aria-label={ariaLabelNext} disabled={isLastPage} onClick={onNextPage}>
<ForwardIcon
size="small"
color={isLastPage ? Colors.AUTHENTIC_BLUE_200 : Colors.AUTHENTIC_BLUE_900}
/>
</IconButton>
)}
</ButtonsContainer>

{label && <LabelContainer>{label}</LabelContainer>}
{size !== 'small' && (
<IconButton aria-label={ariaLabelLast} disabled={isLastPage} onClick={onSkipForward}>
<ForwardLastIcon
size="small"
color={isLastPage ? Colors.AUTHENTIC_BLUE_200 : Colors.AUTHENTIC_BLUE_900}
/>
</IconButton>
)}
</Box>

<Box flex={1}>{label && <LabelContainer>{label}</LabelContainer>}</Box>
</ButtonsContainer>
</Container>
);
};
Expand Down

0 comments on commit 4db46dc

Please sign in to comment.