Skip to content

Commit 24609da

Browse files
feat(ui): tweak pagination styles
1 parent 524647b commit 24609da

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

invokeai/frontend/web/src/features/gallery/components/ImageGrid/GalleryPagination.tsx

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Button, Flex, Icon, IconButton } from '@invoke-ai/ui-library';
1+
import { Button, Flex, IconButton, Spacer } from '@invoke-ai/ui-library';
22
import { ELLIPSIS, useGalleryPagination } from 'features/gallery/hooks/useGalleryPagination';
33
import { useCallback } from 'react';
4-
import { PiCaretLeftBold, PiCaretRightBold, PiDotsThreeBold } from 'react-icons/pi';
4+
import { PiCaretLeftBold, PiCaretRightBold } from 'react-icons/pi';
55

66
import { JumpTo } from './JumpTo';
77

@@ -22,7 +22,7 @@ export const GalleryPagination = () => {
2222
}
2323

2424
return (
25-
<Flex justifyContent="center" alignItems="center" w="full" gap={1}>
25+
<Flex justifyContent="center" alignItems="center" w="full" gap={1} pt={2}>
2626
<IconButton
2727
size="sm"
2828
aria-label="prev"
@@ -31,21 +31,11 @@ export const GalleryPagination = () => {
3131
isDisabled={!isPrevEnabled}
3232
variant="ghost"
3333
/>
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 />
4939
<IconButton
5040
size="sm"
5141
aria-label="next"
@@ -58,3 +48,24 @@ export const GalleryPagination = () => {
5848
</Flex>
5949
);
6050
};
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

Comments
 (0)