Skip to content

Commit 2dd172c

Browse files
feat(ui): gallery bulk select styling
1 parent 280ec9d commit 2dd172c

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
import { Flex, IconButton, Spacer, Tag, TagCloseButton, TagLabel, Tooltip } from '@invoke-ai/ui-library';
1+
import { Tag, TagCloseButton, TagLabel } from '@invoke-ai/ui-library';
22
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
33
import { useGalleryImages } from 'features/gallery/hooks/useGalleryImages';
44
import { selectionChanged } from 'features/gallery/store/gallerySlice';
55
import { useCallback } from 'react';
6+
import { useHotkeys } from 'react-hotkeys-hook';
67
import { useTranslation } from 'react-i18next';
7-
import { BiSelectMultiple } from 'react-icons/bi';
88

99
export const GalleryBulkSelect = () => {
1010
const dispatch = useAppDispatch();
1111
const { selection } = useAppSelector((s) => s.gallery);
1212
const { t } = useTranslation();
1313
const { imageDTOs } = useGalleryImages();
1414

15-
const onClickClearSelection = useCallback(() => {
15+
const onClearSelection = useCallback(() => {
1616
dispatch(selectionChanged([]));
1717
}, [dispatch]);
1818

19-
const onClickSelectAllPage = useCallback(() => {
20-
dispatch(selectionChanged(selection.concat(imageDTOs)));
21-
}, [dispatch, imageDTOs, selection]);
19+
const onSelectPage = useCallback(() => {
20+
dispatch(selectionChanged(imageDTOs));
21+
}, [dispatch, imageDTOs]);
2222

23-
return (
24-
<Flex alignItems="center" justifyContent="space-between">
25-
{selection.length > 0 ? (
26-
<Tag>
27-
<TagLabel>
28-
{selection.length} {t('common.selected')}
29-
</TagLabel>
30-
<Tooltip label="Clear selection">
31-
<TagCloseButton onClick={onClickClearSelection} />
32-
</Tooltip>
33-
</Tag>
34-
) : (
35-
<Spacer />
36-
)}
23+
useHotkeys(['ctrl+a', 'meta+a'], onSelectPage, { preventDefault: true }, [onSelectPage]);
24+
25+
if (selection.length <= 1) {
26+
return null;
27+
}
3728

38-
<Tooltip label={t('gallery.selectAllOnPage')}>
39-
<IconButton
40-
variant="outline"
41-
size="sm"
42-
icon={<BiSelectMultiple />}
43-
aria-label="Bulk select"
44-
onClick={onClickSelectAllPage}
45-
/>
46-
</Tooltip>
47-
</Flex>
29+
return (
30+
<Tag
31+
position="absolute"
32+
bg="invokeBlue.800"
33+
color="base.50"
34+
py={1}
35+
px={3}
36+
userSelect="none"
37+
shadow="dark-lg"
38+
fontWeight="semibold"
39+
border={1}
40+
borderStyle="solid"
41+
borderColor="whiteAlpha.300"
42+
>
43+
<TagLabel>
44+
{selection.length} {t('common.selected')}
45+
</TagLabel>
46+
<TagCloseButton onClick={onClearSelection} />
47+
</Tag>
4848
);
4949
};

invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { RiServerLine } from 'react-icons/ri';
1010

1111
import BoardsList from './Boards/BoardsList/BoardsList';
1212
import GalleryBoardName from './GalleryBoardName';
13-
import { GalleryBulkSelect } from './GalleryBulkSelect';
1413
import GallerySettingsPopover from './GallerySettingsPopover';
1514
import GalleryImageGrid from './ImageGrid/GalleryImageGrid';
1615
import { GalleryPagination } from './ImageGrid/GalleryPagination';
@@ -31,7 +30,16 @@ const ImageGalleryContent = () => {
3130
}, [dispatch]);
3231

3332
return (
34-
<Flex layerStyle="first" flexDirection="column" h="full" w="full" borderRadius="base" p={2} gap={2}>
33+
<Flex
34+
layerStyle="first"
35+
position="relative"
36+
flexDirection="column"
37+
h="full"
38+
w="full"
39+
borderRadius="base"
40+
p={2}
41+
gap={2}
42+
>
3543
{galleryHeader}
3644
<Box>
3745
<Flex alignItems="center" justifyContent="space-between" gap={2}>
@@ -72,7 +80,6 @@ const ImageGalleryContent = () => {
7280
</TabList>
7381
</Tabs>
7482
</Flex>
75-
<GalleryBulkSelect />
7683

7784
<GalleryImageGrid />
7885
<GalleryPagination />

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Box, Flex, Grid } from '@invoke-ai/ui-library';
22
import { EMPTY_ARRAY } from 'app/store/constants';
33
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
44
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
5+
import { GalleryBulkSelect } from 'features/gallery/components/GalleryBulkSelect';
56
import { useGalleryHotkeys } from 'features/gallery/hooks/useGalleryHotkeys';
67
import { selectListImagesQueryArgs } from 'features/gallery/store/gallerySelectors';
78
import { limitChanged } from 'features/gallery/store/gallerySlice';
@@ -144,6 +145,7 @@ const Content = () => {
144145
))}
145146
</Grid>
146147
</Box>
148+
<GalleryBulkSelect />
147149
</Box>
148150
);
149151
};

0 commit comments

Comments
 (0)