feat(ui): add help icon to compare toolbar

This commit is contained in:
psychedelicious 2024-06-02 15:20:47 +10:00
parent 7153d846a9
commit 6b24424727
2 changed files with 43 additions and 5 deletions

View File

@ -389,7 +389,11 @@
"swapImages": "Swap Images", "swapImages": "Swap Images",
"compareOptions": "Comparison Options", "compareOptions": "Comparison Options",
"stretchToFit": "Stretch to Fit", "stretchToFit": "Stretch to Fit",
"exitCompare": "Exit Compare" "exitCompare": "Exit Compare",
"compareHelp1": "Hold <Kbd>Alt</Kbd> while clicking a gallery image or using the arrow keys to change the compare image.",
"compareHelp2": "Press <Kbd>M</Kbd> to cycle through comparison modes.",
"compareHelp3": "Press <Kbd>C</Kbd> to swap the compared images.",
"compareHelp4": "Press <Kbd>Z</Kbd> or <Kbd>Esc</Kbd> to exit."
}, },
"hotkeys": { "hotkeys": {
"searchHotkeys": "Search Hotkeys", "searchHotkeys": "Search Hotkeys",

View File

@ -1,4 +1,14 @@
import { Button, ButtonGroup, Flex, IconButton } from '@invoke-ai/ui-library'; import {
Button,
ButtonGroup,
Flex,
Icon,
IconButton,
Kbd,
ListItem,
Tooltip,
UnorderedList,
} from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { import {
comparedImagesSwapped, comparedImagesSwapped,
@ -9,8 +19,8 @@ import {
} from 'features/gallery/store/gallerySlice'; } from 'features/gallery/store/gallerySlice';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
import { PiArrowsOutBold, PiSwapBold, PiXBold } from 'react-icons/pi'; import { PiArrowsOutBold, PiQuestion, PiSwapBold, PiXBold } from 'react-icons/pi';
export const CompareToolbar = memo(() => { export const CompareToolbar = memo(() => {
const { t } = useTranslation(); const { t } = useTranslation();
@ -90,7 +100,12 @@ export const CompareToolbar = memo(() => {
</ButtonGroup> </ButtonGroup>
</Flex> </Flex>
<Flex flex={1} justifyContent="center"> <Flex flex={1} justifyContent="center">
<Flex gap={2} marginInlineStart="auto"> <Flex gap={2} marginInlineStart="auto" alignItems="center">
<Tooltip label={<CompareHelp />}>
<Flex alignItems="center">
<Icon boxSize={8} color="base.500" as={PiQuestion} lineHeight={0} />
</Flex>
</Tooltip>
<IconButton <IconButton
icon={<PiXBold />} icon={<PiXBold />}
aria-label={`${t('gallery.exitCompare')} (Esc)`} aria-label={`${t('gallery.exitCompare')} (Esc)`}
@ -104,3 +119,22 @@ export const CompareToolbar = memo(() => {
}); });
CompareToolbar.displayName = 'CompareToolbar'; CompareToolbar.displayName = 'CompareToolbar';
const CompareHelp = () => {
return (
<UnorderedList>
<ListItem>
<Trans i18nKey="gallery.compareHelp1" components={{ Kbd: <Kbd /> }}></Trans>
</ListItem>
<ListItem>
<Trans i18nKey="gallery.compareHelp2" components={{ Kbd: <Kbd /> }}></Trans>
</ListItem>
<ListItem>
<Trans i18nKey="gallery.compareHelp3" components={{ Kbd: <Kbd /> }}></Trans>
</ListItem>
<ListItem>
<Trans i18nKey="gallery.compareHelp4" components={{ Kbd: <Kbd /> }}></Trans>
</ListItem>
</UnorderedList>
);
};