1
- import { Button , Flex , Icon , IconButton } from '@invoke-ai/ui-library' ;
1
+ import { Button , Flex , IconButton , Spacer } from '@invoke-ai/ui-library' ;
2
2
import { ELLIPSIS , useGalleryPagination } from 'features/gallery/hooks/useGalleryPagination' ;
3
3
import { useCallback } from 'react' ;
4
- import { PiCaretLeftBold , PiCaretRightBold , PiDotsThreeBold } from 'react-icons/pi' ;
4
+ import { PiCaretLeftBold , PiCaretRightBold } from 'react-icons/pi' ;
5
5
6
6
import { JumpTo } from './JumpTo' ;
7
7
@@ -22,7 +22,7 @@ export const GalleryPagination = () => {
22
22
}
23
23
24
24
return (
25
- < Flex justifyContent = "center" alignItems = "center" w = "full" gap = { 1 } >
25
+ < Flex justifyContent = "center" alignItems = "center" w = "full" gap = { 1 } pt = { 2 } >
26
26
< IconButton
27
27
size = "sm"
28
28
aria-label = "prev"
@@ -31,21 +31,11 @@ export const GalleryPagination = () => {
31
31
isDisabled = { ! isPrevEnabled }
32
32
variant = "ghost"
33
33
/>
34
- { pageButtons . map ( ( page , i ) => {
35
- if ( page === ELLIPSIS ) {
36
- return < Icon as = { PiDotsThreeBold } boxSize = "4" key = { `ellipsis-${ i } ` } /> ;
37
- }
38
- return (
39
- < Button
40
- size = "sm"
41
- key = { page }
42
- onClick = { goToPage . bind ( null , page - 1 ) }
43
- variant = { currentPage === page - 1 ? 'solid' : 'outline' }
44
- >
45
- { page }
46
- </ Button >
47
- ) ;
48
- } ) }
34
+ < Spacer />
35
+ { pageButtons . map ( ( page , i ) => (
36
+ < PageButton key = { `${ page } _${ i } ` } page = { page } currentPage = { currentPage } goToPage = { goToPage } />
37
+ ) ) }
38
+ < Spacer />
49
39
< IconButton
50
40
size = "sm"
51
41
aria-label = "next"
@@ -58,3 +48,24 @@ export const GalleryPagination = () => {
58
48
</ Flex >
59
49
) ;
60
50
} ;
51
+
52
+ type PageButtonProps = {
53
+ page : number | typeof ELLIPSIS ;
54
+ currentPage : number ;
55
+ goToPage : ( page : number ) => void ;
56
+ } ;
57
+
58
+ const PageButton = ( { page, currentPage, goToPage } : PageButtonProps ) => {
59
+ if ( page === ELLIPSIS ) {
60
+ return (
61
+ < Button size = "sm" variant = "link" isDisabled >
62
+ ...
63
+ </ Button >
64
+ ) ;
65
+ }
66
+ return (
67
+ < Button size = "sm" onClick = { goToPage . bind ( null , page - 1 ) } variant = { currentPage === page - 1 ? 'solid' : 'outline' } >
68
+ { page }
69
+ </ Button >
70
+ ) ;
71
+ } ;
0 commit comments