mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat: improve the switch states of the control layers / viewer area
This commit is contained in:
parent
be7eeb576b
commit
f4dde883ca
@ -143,6 +143,7 @@
|
||||
"alpha": "Alpha",
|
||||
"selected": "Selected",
|
||||
"viewer": "Viewer",
|
||||
"controlLayers": "Control Layers",
|
||||
"tab": "Tab"
|
||||
},
|
||||
"controlnet": {
|
||||
|
@ -1,19 +1,21 @@
|
||||
import { IconButton } from '@chakra-ui/react';
|
||||
import { Button } from '@invoke-ai/ui-library';
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import type { InvokeTabName } from 'features/ui/store/tabMap';
|
||||
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PiArrowsDownUpBold } from 'react-icons/pi';
|
||||
|
||||
import { useImageViewer } from './useImageViewer';
|
||||
|
||||
const TAB_NAME_TO_TKEY: Record<InvokeTabName, string> = {
|
||||
generation: 'ui.tabs.generationTab',
|
||||
canvas: 'ui.tabs.canvasTab',
|
||||
workflows: 'ui.tabs.workflowsTab',
|
||||
models: 'ui.tabs.modelsTab',
|
||||
queue: 'ui.tabs.queueTab',
|
||||
};
|
||||
// const TAB_NAME_TO_TKEY: Record<InvokeTabName, string> = {
|
||||
// generation: 'ui.tabs.generationTab',
|
||||
// canvas: 'ui.tabs.canvasTab',
|
||||
// workflows: 'ui.tabs.workflowsTab',
|
||||
// models: 'ui.tabs.modelsTab',
|
||||
// queue: 'ui.tabs.queueTab',
|
||||
// };
|
||||
|
||||
const TAB_NAME_TO_TKEY_SHORT: Record<InvokeTabName, string> = {
|
||||
generation: 'ui.tabs.generation',
|
||||
@ -27,11 +29,19 @@ export const EditorButton = () => {
|
||||
const { t } = useTranslation();
|
||||
const { onClose } = useImageViewer();
|
||||
const activeTabName = useAppSelector(activeTabNameSelector);
|
||||
const tooltip = useMemo(() => t('gallery.switchTo', { tab: t(TAB_NAME_TO_TKEY[activeTabName]) }), [t, activeTabName]);
|
||||
|
||||
const tooltip = useMemo(
|
||||
() =>
|
||||
t('gallery.switchTo', {
|
||||
tab: activeTabName === 'generation' ? t('common.controlLayers') : t(TAB_NAME_TO_TKEY_SHORT[activeTabName]),
|
||||
}),
|
||||
[t, activeTabName]
|
||||
);
|
||||
|
||||
return (
|
||||
<Button aria-label={tooltip} tooltip={tooltip} onClick={onClose} variant="ghost">
|
||||
{t(TAB_NAME_TO_TKEY_SHORT[activeTabName])}
|
||||
<Button aria-label={tooltip} tooltip={tooltip} onClick={onClose} variant="outline" sx={{ display: 'flex', gap: 2 }}>
|
||||
<IconButton aria-label={tooltip} variant="ghost" size="sm" icon={<PiArrowsDownUpBold />} />
|
||||
{activeTabName === 'generation' ? t('common.controlLayers') : t(TAB_NAME_TO_TKEY_SHORT[activeTabName])}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
@ -1,16 +1,33 @@
|
||||
import { IconButton } from '@chakra-ui/react';
|
||||
import { Button } from '@invoke-ai/ui-library';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PiArrowsDownUpBold } from 'react-icons/pi';
|
||||
|
||||
import { useImageViewer } from './useImageViewer';
|
||||
|
||||
export const ViewerButton = () => {
|
||||
const { t } = useTranslation();
|
||||
const { onOpen } = useImageViewer();
|
||||
const tooltip = useMemo(() => t('gallery.switchTo', { tab: t('common.viewer') }), [t]);
|
||||
|
||||
const tooltip = useMemo(
|
||||
() =>
|
||||
t('gallery.switchTo', {
|
||||
tab: t('common.viewer'),
|
||||
}),
|
||||
[t]
|
||||
);
|
||||
|
||||
return (
|
||||
<Button aria-label={tooltip} tooltip={tooltip} onClick={onOpen} variant="ghost" pointerEvents="auto">
|
||||
<Button
|
||||
aria-label={tooltip}
|
||||
tooltip={tooltip}
|
||||
onClick={onOpen}
|
||||
variant="outline"
|
||||
pointerEvents="auto"
|
||||
sx={{ display: 'flex', gap: 2 }}
|
||||
>
|
||||
<IconButton aria-label={tooltip} variant="ghost" size="sm" icon={<PiArrowsDownUpBold />} />
|
||||
{t('common.viewer')}
|
||||
</Button>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user