diff --git a/.changeset/fix-pagination-mobile-layout.md b/.changeset/fix-pagination-mobile-layout.md new file mode 100644 index 000000000..42f3fa6a1 --- /dev/null +++ b/.changeset/fix-pagination-mobile-layout.md @@ -0,0 +1,5 @@ +--- +"@clickhouse/click-ui": patch +--- + +Fix Pagination layout on small screens so it preserves the desktop horizontal structure without stacking labels or controls into columns. diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx index 4705e5549..4a86d9c77 100644 --- a/src/components/Pagination/Pagination.tsx +++ b/src/components/Pagination/Pagination.tsx @@ -47,6 +47,18 @@ const CustomSelect = styled.div` width: 150px; `; +const NoWrapText = styled(Text)` + white-space: nowrap; + word-break: normal; + overflow-wrap: normal; + flex-shrink: 0; +`; + +const PageInputWrapper = styled.div<{ $digitCount: number }>` + flex: 0 0 auto; + width: ${({ $digitCount }) => `clamp(44px, calc(${$digitCount}ch + 2.5rem), 72px)`}; +`; + export const Pagination = ({ totalPages, currentPage, @@ -68,6 +80,11 @@ export const Pagination = ({ }: PaginationProps): ReactElement => { const hasRowCount = ['number', 'string'].includes(typeof rowCount); const inputRef = useRef(null); + const pageDigits = Math.max( + 2, + currentPage.toString().length, + (totalPages ?? 0).toString().length + ); const formatNumber = (value: number) => { return new Intl.NumberFormat('en').format(value); }; @@ -130,6 +147,7 @@ export const Pagination = ({ return ( 0 ? 'space-between' : 'center') @@ -138,16 +156,17 @@ export const Pagination = ({ {...props} > {hasRowCount && ( - {typeof rowCount === 'number' ? formatNumber(rowCount) : rowCount} rows - + )} - + - + {!!totalPages && ( - of {formatNumber(totalPages)} - + )}