From 1878ea94f6e4a7d63bc39b671649299842f589f9 Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Tue, 13 Jun 2023 00:20:52 +1200 Subject: [PATCH] feat: Port Canvas Layer Select to IAIMantineSelect --- .../IAICanvasToolbar/IAICanvasToolbar.tsx | 23 +++++++++---------- .../src/features/canvas/store/canvasTypes.ts | 4 ++-- .../UnifiedCanvasLayerSelect.tsx | 12 +++++----- .../UnifiedCanvasToolbarBeta.tsx | 4 ++-- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx b/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx index 30ff6fff81..cc408728ab 100644 --- a/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx +++ b/invokeai/frontend/web/src/features/canvas/components/IAICanvasToolbar/IAICanvasToolbar.tsx @@ -2,7 +2,6 @@ import { Box, ButtonGroup, Flex } from '@chakra-ui/react'; import { createSelector } from '@reduxjs/toolkit'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import IAIIconButton from 'common/components/IAIIconButton'; -import IAISelect from 'common/components/IAISelect'; import useImageUploader from 'common/hooks/useImageUploader'; import { useSingleAndDoubleClick } from 'common/hooks/useSingleAndDoubleClick'; import { @@ -25,7 +24,13 @@ import { getCanvasBaseLayer } from 'features/canvas/util/konvaInstanceProvider'; import { systemSelector } from 'features/system/store/systemSelectors'; import { isEqual } from 'lodash-es'; -import { ChangeEvent } from 'react'; +import IAIMantineSelect from 'common/components/IAIMantineSelect'; +import { + canvasCopiedToClipboard, + canvasDownloadedAsImage, + canvasMerged, + canvasSavedToGallery, +} from 'features/canvas/store/actions'; import { useHotkeys } from 'react-hotkeys-hook'; import { useTranslation } from 'react-i18next'; import { @@ -43,12 +48,6 @@ import IAICanvasRedoButton from './IAICanvasRedoButton'; import IAICanvasSettingsButtonPopover from './IAICanvasSettingsButtonPopover'; import IAICanvasToolChooserOptions from './IAICanvasToolChooserOptions'; import IAICanvasUndoButton from './IAICanvasUndoButton'; -import { - canvasCopiedToClipboard, - canvasDownloadedAsImage, - canvasMerged, - canvasSavedToGallery, -} from 'features/canvas/store/actions'; export const selector = createSelector( [systemSelector, canvasSelector, isStagingSelector], @@ -197,8 +196,8 @@ const IAICanvasToolbar = () => { dispatch(canvasDownloadedAsImage()); }; - const handleChangeLayer = (e: ChangeEvent) => { - const newLayer = e.target.value as CanvasLayer; + const handleChangeLayer = (v: string) => { + const newLayer = v as CanvasLayer; dispatch(setLayer(newLayer)); if (newLayer === 'mask' && !isMaskEnabled) { dispatch(setIsMaskEnabled(true)); @@ -214,11 +213,11 @@ const IAICanvasToolbar = () => { }} > - diff --git a/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts b/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts index 9143b69d55..ae78287a7b 100644 --- a/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts +++ b/invokeai/frontend/web/src/features/canvas/store/canvasTypes.ts @@ -4,8 +4,8 @@ import { RgbaColor } from 'react-colorful'; import { ImageDTO } from 'services/api'; export const LAYER_NAMES_DICT = [ - { key: 'Base', value: 'base' }, - { key: 'Mask', value: 'mask' }, + { label: 'Base', value: 'base' }, + { label: 'Mask', value: 'mask' }, ]; export const LAYER_NAMES = ['base', 'mask'] as const; diff --git a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbar/UnifiedCanvasLayerSelect.tsx b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbar/UnifiedCanvasLayerSelect.tsx index 780744b045..5b35042fa5 100644 --- a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbar/UnifiedCanvasLayerSelect.tsx +++ b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbar/UnifiedCanvasLayerSelect.tsx @@ -1,6 +1,6 @@ import { createSelector } from '@reduxjs/toolkit'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; -import IAISelect from 'common/components/IAISelect'; +import IAIMantineSelect from 'common/components/IAIMantineSelect'; import { canvasSelector, isStagingSelector, @@ -12,7 +12,6 @@ import { } from 'features/canvas/store/canvasTypes'; import { isEqual } from 'lodash-es'; -import { ChangeEvent } from 'react'; import { useHotkeys } from 'react-hotkeys-hook'; import { useTranslation } from 'react-i18next'; @@ -51,22 +50,23 @@ export default function UnifiedCanvasLayerSelect() { [layer] ); - const handleChangeLayer = (e: ChangeEvent) => { - const newLayer = e.target.value as CanvasLayer; + const handleChangeLayer = (v: string) => { + const newLayer = v as CanvasLayer; dispatch(setLayer(newLayer)); if (newLayer === 'mask' && !isMaskEnabled) { dispatch(setIsMaskEnabled(true)); } }; return ( - ); } diff --git a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbarBeta.tsx b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbarBeta.tsx index ece4386d45..b5eec3bec3 100644 --- a/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbarBeta.tsx +++ b/invokeai/frontend/web/src/features/ui/components/tabs/UnifiedCanvas/UnifiedCanvasBeta/UnifiedCanvasToolbarBeta.tsx @@ -2,6 +2,7 @@ import { Flex } from '@chakra-ui/react'; import IAICanvasRedoButton from 'features/canvas/components/IAICanvasToolbar/IAICanvasRedoButton'; import IAICanvasUndoButton from 'features/canvas/components/IAICanvasToolbar/IAICanvasUndoButton'; +import UnifiedCanvasSettings from './UnifiedCanvasToolSettings/UnifiedCanvasSettings'; import UnifiedCanvasCopyToClipboard from './UnifiedCanvasToolbar/UnifiedCanvasCopyToClipboard'; import UnifiedCanvasDownloadImage from './UnifiedCanvasToolbar/UnifiedCanvasDownloadImage'; import UnifiedCanvasFileUploader from './UnifiedCanvasToolbar/UnifiedCanvasFileUploader'; @@ -13,11 +14,10 @@ import UnifiedCanvasResetCanvas from './UnifiedCanvasToolbar/UnifiedCanvasResetC import UnifiedCanvasResetView from './UnifiedCanvasToolbar/UnifiedCanvasResetView'; import UnifiedCanvasSaveToGallery from './UnifiedCanvasToolbar/UnifiedCanvasSaveToGallery'; import UnifiedCanvasToolSelect from './UnifiedCanvasToolbar/UnifiedCanvasToolSelect'; -import UnifiedCanvasSettings from './UnifiedCanvasToolSettings/UnifiedCanvasSettings'; const UnifiedCanvasToolbarBeta = () => { return ( - +