diff --git a/packages/ui/src/components/Pagination/PaginationButtons.tsx b/packages/ui/src/components/Pagination/PaginationButtons.tsx index 0de62e520a..624c10f07b 100644 --- a/packages/ui/src/components/Pagination/PaginationButtons.tsx +++ b/packages/ui/src/components/Pagination/PaginationButtons.tsx @@ -1,32 +1,27 @@ import styled from '@emotion/styled' import { useCallback, useMemo } from 'react' import { Button } from '../Button' +import { Stack } from '../Stack' import { Text } from '../Text' import { getPageNumbers } from './getPageNumbers' -const PageNumbersContainer = styled.div` - display: flex; - gap: ${({ theme }) => theme.space['1']}; +const PageNumbersContainer = styled(Stack)` margin: 0 ${({ theme }) => theme.space['1']}; ` -const PageSwitchContainer = styled.div` - display: flex; - gap: ${({ theme }) => theme.space['1']}; +const PageButton = styled(Button, { + shouldForwardProp: prop => !['width'].includes(prop), +})<{ width: string }>` + width: ${({ theme, width }) => (width === 'small' ? theme.sizing[400] : theme.sizing[500])}; ` -const StyledContainer = styled.div` - display: flex; -` -const PageButton = styled(Button)` - width: ${({ theme }) => theme.sizing[600]}; -` - -const Ellipsis = styled(Text)` +const Ellipsis = styled(Text, { + shouldForwardProp: prop => !['width'].includes(prop), +})<{ size: string }>` align-content: center; padding: ${({ theme }) => theme.space[1]}; - height: ${({ theme }) => theme.sizing[600]}; - width: ${({ theme }) => theme.sizing[600]}; + height: ${({ theme, size }) => (size === 'small' ? theme.sizing[400] : theme.sizing[500])}; + width: ${({ theme, size }) => (size === 'small' ? theme.sizing[400] : theme.sizing[500])}; ` type PaginationButtonsProps = { @@ -37,6 +32,7 @@ type PaginationButtonsProps = { pageTabCount?: number className?: string 'data-testid'?: string + perPage: boolean } type MakeButtonProps = { @@ -45,6 +41,7 @@ type MakeButtonProps = { disabled?: boolean page: number handlePageClick: (pageNumber: number) => () => void + perPage: boolean } const MakeButton = ({ hasEllipsisBefore, @@ -52,6 +49,7 @@ const MakeButton = ({ disabled, page, handlePageClick, + perPage, }: MakeButtonProps) => ( <> {hasEllipsisBefore ? ( @@ -63,6 +61,7 @@ const MakeButton = ({ prominence="default" as="span" placement="center" + size={perPage ? 'small' : 'medium'} > ... @@ -74,6 +73,8 @@ const MakeButton = ({ sentiment={pageNumber === page ? 'primary' : 'neutral'} onClick={handlePageClick(pageNumber)} type="button" + size={perPage ? 'small' : 'medium'} + width={perPage ? 'small' : 'medium'} > {pageNumber} @@ -88,6 +89,7 @@ export const PaginationButtons = ({ pageTabCount, 'data-testid': dataTestId, className, + perPage, }: PaginationButtonsProps) => { const goToNextPage = useCallback(() => { onChange(page + 1) @@ -110,8 +112,8 @@ export const PaginationButtons = ({ ) return ( - - + +
+ + + + 11-20 items + + +
+
+ +
+
+ + + + + + + ... + + +
+
+ +
+
+ + + +`; + +exports[`Pagination > should work correctly with perPage 1`] = ` + + .emotion-0 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + justify-content: space-between; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; +} + +.emotion-2 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 1rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: normal; + -ms-flex-pack: normal; + -webkit-justify-content: normal; + justify-content: normal; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; +} + +.emotion-4 { + color: #727683; + font-size: 1rem; + font-family: Inter,Asap,sans-serif; + font-weight: 400; + letter-spacing: 0; + line-height: 1.5rem; + text-transform: none; + -webkit-text-decoration: none; + text-decoration: none; +} + +.emotion-7 { + width: 100%; + width: -webkit-fit-content; + width: -moz-fit-content; + width: fit-content; + min-width: none; +} + +.emotion-9 { + display: inherit; +} + +.emotion-9[data-container-full-width="true"] { + width: 100%; +} + +.emotion-11 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0.25rem; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-box-pack: normal; + -ms-flex-pack: normal; + -webkit-justify-content: normal; + justify-content: normal; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; +} + +.emotion-13 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + justify-content: space-between; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + padding: 0.5rem; + padding-right: 0; + padding-left: 1rem; + cursor: pointer; + box-shadow: none; + background: #ffffff; + border-radius: 0.25rem; + width: 100%; + overflow: hidden; +} + +.emotion-13[data-size='small'] { + height: 2rem; + padding-left: 0.5rem; +} + +.emotion-13[data-size='medium'] { + height: 2.5rem; +} + +.emotion-13[data-size='large'] { + height: 3rem; +} + +.emotion-13[data-state='neutral'] { + border: 1px solid #d9dadd; +} + +.emotion-13[data-state='neutral']:not([data-disabled="true"]):not([data-readonly="true"]):active { + border-color: #792dd4; + box-shadow: 0px 0px 0px 3px #8c40ef40; +} + +.emotion-13[data-state='neutral']:not([data-disabled='true']):hover, +.emotion-13[data-state='neutral']:not([data-disabled='true']):focus { + border-color: #792dd4; + outline: none; +} + +.emotion-13[data-state='neutral'][data-dropdownvisible='true'] { + border-color: #792dd4; +} + +.emotion-13[data-state='success'] { + border: 1px solid #22674e; +} + +.emotion-13[data-state='success']:not([data-disabled="true"]):not([data-readonly="true"]):active { + border-color: #1b533f; + box-shadow: 0px 0px 0px 3px #45d19f40; +} + +.emotion-13[data-state='success'][data-dropdownvisible='true'] { + border-color: #1b533f; +} + +.emotion-13[data-state='danger'] { + border: 1px solid #b3144d; +} + +.emotion-13[data-state='danger']:not([data-disabled="true"]):not([data-readonly="true"]):active { + border-color: #92103f; + box-shadow: 0px 0px 0px 3px #f91b6c40; +} + +.emotion-13[data-state='danger'][data-dropdownvisible='true'] { + border-color: #92103f; +} + +.emotion-13:not([data-disabled='true']):not([data-readonly]):hover { + border-color: #8c40ef; +} + +.emotion-13[data-readonly='true'] { + background: #f9f9fa; + border-color: #d9dadd; + cursor: default; +} + +.emotion-13[data-disabled='true'] { + background: #f3f3f4; + border-color: #e9eaeb; + cursor: not-allowed; +} + +.emotion-16 { + color: #3f4250; + font-size: 0.875rem; + font-family: Inter,Asap,sans-serif; + font-weight: 400; + letter-spacing: 0; + line-height: 1.25rem; + text-transform: none; + -webkit-text-decoration: none; + text-decoration: none; + text-overflow: ellipsis; + overflow: hidden; +} + +.emotion-18 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: normal; + -ms-flex-pack: normal; + -webkit-justify-content: normal; + justify-content: normal; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; + padding-right: 1rem; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} + +.emotion-20 { + vertical-align: middle; + fill: #3f4250; + height: 16px; + width: 16px; + min-width: 16px; + min-height: 16px; +} + +.emotion-20 .fillStroke { + stroke: #3f4250; + fill: none; +} + +.emotion-24 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-box-pack: normal; + -ms-flex-pack: normal; + -webkit-justify-content: normal; + justify-content: normal; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; +} + +.emotion-26 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0.5rem; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-box-pack: normal; + -ms-flex-pack: normal; + -webkit-justify-content: normal; + justify-content: normal; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; +} + +.emotion-28 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + height: 2rem; + padding: 0 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + gap: 0.5rem; + border-radius: 0.25rem; + box-sizing: border-box; + width: 2rem; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + cursor: pointer; + -webkit-box-pack: center; + -ms-flex-pack: center; + -webkit-justify-content: center; + justify-content: center; + outline-offset: 2px; + white-space: nowrap; + -webkit-text-decoration: none; + text-decoration: none; + font-size: 0.875rem; + font-family: Inter,Asap,sans-serif; + font-weight: 500; + letter-spacing: 0; + line-height: 1.25rem; + paragraph-spacing: 0; + text-case: none; + background: none; + border: 1px solid #8c40ef; + color: #641cb3; +} + +.emotion-28:hover { + -webkit-text-decoration: none; + text-decoration: none; +} + +.emotion-28:active { + box-shadow: 0px 0px 0px 3px #8c40ef40; +} + +.emotion-28:hover, +.emotion-28:active { + background: #e5dbfd; + color: #521094; + border: 1px solid #792dd4; +} + +.emotion-30 { + vertical-align: middle; + fill: currentColor; + height: 16px; + width: 16px; + min-width: 16px; + min-height: 16px; +} + +.emotion-30 .fillStroke { + stroke: currentColor; + fill: none; +} + +.emotion-32 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + gap: 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: normal; + -webkit-box-align: normal; + -ms-flex-align: normal; + align-items: normal; + -webkit-box-pack: normal; + -ms-flex-pack: normal; + -webkit-justify-content: normal; + justify-content: normal; + -webkit-box-flex-wrap: nowrap; + -webkit-flex-wrap: nowrap; + -ms-flex-wrap: nowrap; + flex-wrap: nowrap; + margin: 0 0.5rem; +} + +.emotion-35 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + height: 2rem; + padding: 0 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + gap: 0.5rem; + border-radius: 0.25rem; + box-sizing: border-box; + width: auto; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + cursor: pointer; + -webkit-box-pack: center; + -ms-flex-pack: center; + -webkit-justify-content: center; + justify-content: center; + outline-offset: 2px; + white-space: nowrap; + -webkit-text-decoration: none; + text-decoration: none; + font-size: 0.875rem; + font-family: Inter,Asap,sans-serif; + font-weight: 500; + letter-spacing: 0; + line-height: 1.25rem; + paragraph-spacing: 0; + text-case: none; + background: none; + border: 1px solid #b5b7bd; + color: #3f4250; + width: 2rem; +} + +.emotion-35:hover { + -webkit-text-decoration: none; + text-decoration: none; +} + +.emotion-35:active { + box-shadow: 0px 0px 0px 3px #151a2d5c; +} + +.emotion-35:hover, +.emotion-35:active { + background: #e9eaeb; + color: #222638; + border: 1px solid #92959d; +} + +.emotion-38 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + height: 2rem; + padding: 0 0.5rem; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + gap: 0.5rem; + border-radius: 0.25rem; + box-sizing: border-box; + width: auto; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + cursor: pointer; + -webkit-box-pack: center; + -ms-flex-pack: center; + -webkit-justify-content: center; + justify-content: center; + outline-offset: 2px; + white-space: nowrap; + -webkit-text-decoration: none; + text-decoration: none; + font-size: 0.875rem; + font-family: Inter,Asap,sans-serif; + font-weight: 500; + letter-spacing: 0; + line-height: 1.25rem; + paragraph-spacing: 0; + text-case: none; + background: none; + border: 1px solid #8c40ef; + color: #641cb3; + width: 2rem; +} + +.emotion-38:hover { + -webkit-text-decoration: none; + text-decoration: none; +} + +.emotion-38:active { + box-shadow: 0px 0px 0px 3px #8c40ef40; +} + +.emotion-38:hover, +.emotion-38:active { + background: #e5dbfd; + color: #521094; + border: 1px solid #792dd4; +} + +.emotion-50 { + color: #3f4250; + font-size: 1rem; + font-family: Inter,Asap,sans-serif; + font-weight: 400; + letter-spacing: 0; + line-height: 1.5rem; + text-transform: none; + -webkit-text-decoration: none; + text-decoration: none; + text-align: center; + -webkit-align-content: center; + -ms-flex-line-pack: center; + align-content: center; + padding: 0.5rem; + height: 2rem; + width: 2rem; +} + +
+
+
+ + test + +
+
+
+