Skip to content

Commit 58315f8

Browse files
committed
refactor: pagination styles
1 parent 3525d0b commit 58315f8

File tree

2 files changed

+54
-12
lines changed

2 files changed

+54
-12
lines changed

app/globals.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,49 @@
693693
}
694694
}
695695

696+
/* CoinsPagination Component Utilities */
697+
#coins-pagination {
698+
.pagination-content {
699+
@apply flex w-full;
700+
}
701+
702+
.pagination-control {
703+
@apply bg-dark-400 rounded-sm py-1;
704+
705+
&.prev {
706+
@apply pr-2;
707+
}
708+
709+
&.next {
710+
@apply pl-2;
711+
}
712+
}
713+
714+
.control-button {
715+
@apply cursor-pointer;
716+
}
717+
718+
.control-disabled {
719+
@apply pointer-events-none opacity-50;
720+
}
721+
722+
.pagination-pages {
723+
@apply flex flex-1 justify-center gap-2;
724+
725+
.ellipsis {
726+
@apply px-3 py-2 text-base;
727+
}
728+
729+
.page-link {
730+
@apply hover:bg-dark-400! rounded-sm text-base cursor-pointer;
731+
}
732+
733+
.page-link-active {
734+
@apply bg-green-500! text-dark-900 font-semibold;
735+
}
736+
}
737+
}
738+
696739
.skeleton {
697740
@apply bg-dark-400/60;
698741
}

components/CoinsPagination.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,31 @@ export default function CoinsPagination({
2626
const isLastPage = !hasMorePages || currentPage === totalPages;
2727

2828
return (
29-
<Pagination>
30-
<PaginationContent className='flex w-full'>
31-
<PaginationItem className='bg-dark-400 rounded-sm pr-2 py-1'>
29+
<Pagination id='coins-pagination'>
30+
<PaginationContent className='pagination-content'>
31+
<PaginationItem className='pagination-control prev'>
3232
<PaginationPrevious
3333
onClick={() => currentPage > 1 && handlePageChange(currentPage - 1)}
3434
className={
3535
currentPage === 1
36-
? 'pointer-events-none opacity-50'
37-
: 'cursor-pointer'
36+
? 'control-disabled'
37+
: 'control-button'
3838
}
3939
/>
4040
</PaginationItem>
4141

42-
<div className='flex flex-1 justify-center gap-2'>
42+
<div className='pagination-pages'>
4343
{pageNumbers.map((page, index) => (
4444
<PaginationItem key={index}>
4545
{page === ELLIPSIS ? (
46-
<span className='px-3 py-2 text-base'>...</span>
46+
<span className='ellipsis'>...</span>
4747
) : (
4848
<PaginationLink
4949
onClick={() => handlePageChange(page)}
5050
className={cn(
51-
'hover:bg-dark-400! rounded-sm text-base cursor-pointer',
51+
'page-link',
5252
{
53-
'bg-green-500! text-dark-900 font-semibold':
54-
currentPage === page,
53+
'page-link-active': currentPage === page,
5554
}
5655
)}
5756
isActive={currentPage === page}
@@ -63,11 +62,11 @@ export default function CoinsPagination({
6362
))}
6463
</div>
6564

66-
<PaginationItem className='bg-dark-400 rounded-sm pl-2 py-1'>
65+
<PaginationItem className='pagination-control next'>
6766
<PaginationNext
6867
onClick={() => !isLastPage && handlePageChange(currentPage + 1)}
6968
className={
70-
isLastPage ? 'pointer-events-none opacity-50' : 'cursor-pointer'
69+
isLastPage ? 'control-disabled' : 'control-button'
7170
}
7271
/>
7372
</PaginationItem>

0 commit comments

Comments
 (0)