Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import { IconButton } from '@invoke-ai/ui-library';
import { useStore } from '@nanostores/react';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { selectShouldShowItemDetails, selectShouldShowProgressInViewer } from 'features/ui/store/uiSelectors';
import { setShouldShowItemDetails } from 'features/ui/store/uiSlice';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiInfoBold } from 'react-icons/pi';
import { useImageViewerContext } from './context';
export const ToggleMetadataViewerButton = memo(() => {
const dispatch = useAppDispatch();
const ctx = useImageViewerContext();
const hasProgressImage = useStore(ctx.$hasProgressImage);
const isTemporarilyShowingSelectedImage = useStore(ctx.$isTemporarilyShowingSelectedImage);
const shouldShowProgressInViewer = useAppSelector(selectShouldShowProgressInViewer);
const isDisabledOverride = hasProgressImage && shouldShowProgressInViewer && !isTemporarilyShowingSelectedImage;
const shouldShowItemDetails = useAppSelector(selectShouldShowItemDetails);
const { t } = useTranslation();
const toggleMetadataViewer = useCallback(() => {
dispatch(setShouldShowItemDetails(!shouldShowItemDetails));
}, [dispatch, shouldShowItemDetails]);
return (
<IconButton
icon={<PiInfoBold />}
tooltip={`${t('parameters.info')} (I)`}
aria-label={`${t('parameters.info')} (I)`}
onClick={toggleMetadataViewer}
variant="link"
alignSelf="stretch"
colorScheme={shouldShowItemDetails ? 'invokeBlue' : 'base'}
data-testid="toggle-show-metadata-button"
isDisabled={isDisabledOverride}
/>
);
});
ToggleMetadataViewerButton.displayName = 'ToggleMetadataViewerButton';