From 5a6b3f8f895056ac937036794d78751e8d854601 Mon Sep 17 00:00:00 2001 From: Viktor Mozharovskyi Date: Tue, 28 Jan 2025 17:29:22 +0100 Subject: [PATCH] Pagination: navigation button disabled state - added / Pagination: styles - improved --- .../src/components/Pagination/Pagination.tsx | 72 ++++++++++--------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/packages/web-app/src/components/Pagination/Pagination.tsx b/packages/web-app/src/components/Pagination/Pagination.tsx index a1e63ec55..24492d553 100644 --- a/packages/web-app/src/components/Pagination/Pagination.tsx +++ b/packages/web-app/src/components/Pagination/Pagination.tsx @@ -11,11 +11,12 @@ const styles: (theme: SaladTheme) => Record = (theme: Sa width: '100%', color: theme.lightGreen, display: 'flex', - justifyContent: 'center', + justifyContent: 'flex-start', alignItems: 'center', flexDirection: 'row', gap: '16px', padding: '16px', + paddingLeft: '12px', }, navigationButtonWrapper: { width: '100px', @@ -27,6 +28,8 @@ const styles: (theme: SaladTheme) => Record = (theme: Sa flexDirection: 'row', gap: '6px', width: '250px', + paddingLeft: '12px', + paddingRight: '12px', }, centralPagesWrapper: { display: 'flex', @@ -40,8 +43,10 @@ const styles: (theme: SaladTheme) => Record = (theme: Sa justifyContent: 'center', alignItems: 'center', flexDirection: 'row', - gap: '6px', - width: '60px', + gap: '10px', + width: '65px', + paddingLeft: '4px', + paddingRight: '4px', }, currentPageText: { color: theme.darkBlue, @@ -67,6 +72,9 @@ const styles: (theme: SaladTheme) => Record = (theme: Sa color: theme.darkBlue, fontWeight: 500, }, + disabled: { + opacity: 0.5, + }, }) interface Props extends WithStyles { @@ -84,8 +92,8 @@ const _Pagination: FunctionComponent = ({ onPageChange, }) => { const totalPagesAmount = Math.ceil(itemsTotalAmount / itemsPerPageAmount) - const withPreviousPage = currentPageNumber !== 1 - const withNextPage = totalPagesAmount - currentPageNumber > 0 + const isPreviousPageEnabled = currentPageNumber !== 1 + const isNextPageEnabled = totalPagesAmount - currentPageNumber > 0 const firstPageNumber = 1 const lastPageNumber = totalPagesAmount const nextPageNumber = currentPageNumber + 1 @@ -97,33 +105,32 @@ const _Pagination: FunctionComponent = ({ return (
-
- {withPreviousPage && ( -
- {withPreviousPage && !isPreviousPageFirst && ( + {isPreviousPageEnabled && !isPreviousPageFirst && ( )} - {withPreviousDots && withPreviousPage && ( + {withPreviousDots && isPreviousPageEnabled && (
...
)}
- {withPreviousPage && ( + {isPreviousPageEnabled && ( @@ -133,36 +140,35 @@ const _Pagination: FunctionComponent = ({ {currentPageNumber} - {withNextPage && ( + {isNextPageEnabled && ( )}
- {withNextDots && withNextPage && ( + {withNextDots && isNextPageEnabled && (
...
)} - {!isNextPageLast && withNextPage && ( + {!isNextPageLast && isNextPageEnabled && ( )}
-
- {withNextPage && ( -
)