From c1aae0815dfbdf69b65d3f400aa677d41aec0dce Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Fri, 12 Apr 2024 17:51:19 +1000
Subject: [PATCH] feat(ui): regional prompting layout, styling
---
.../src/common/components/ColorPreview.tsx | 19 ------------------
.../components/LayerColorPicker.tsx | 6 +++---
.../components/LayerListItem.tsx | 20 ++++++++++++-------
.../components/RegionalPromptsPrompt.tsx | 9 ++-------
.../components/RegionalPromptsStage.tsx | 3 ++-
5 files changed, 20 insertions(+), 37 deletions(-)
delete mode 100644 invokeai/frontend/web/src/common/components/ColorPreview.tsx
diff --git a/invokeai/frontend/web/src/common/components/ColorPreview.tsx b/invokeai/frontend/web/src/common/components/ColorPreview.tsx
deleted file mode 100644
index a52c98ef19..0000000000
--- a/invokeai/frontend/web/src/common/components/ColorPreview.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { FlexProps } from '@invoke-ai/ui-library';
-import { Flex, forwardRef } from '@invoke-ai/ui-library';
-import { useMemo } from 'react';
-import type { RgbaColor, RgbColor } from 'react-colorful';
-
-type Props = FlexProps & {
- previewColor: RgbColor | RgbaColor;
-};
-
-export const ColorPreview = forwardRef((props: Props, ref) => {
- const { previewColor, ...rest } = props;
- const colorString = useMemo(() => {
- if ('a' in previewColor) {
- return `rgba(${previewColor.r}, ${previewColor.g}, ${previewColor.b}, ${previewColor.a ?? 1})`;
- }
- return `rgba(${previewColor.r}, ${previewColor.g}, ${previewColor.b}, 1)`;
- }, [previewColor]);
- return ;
-});
diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/LayerColorPicker.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/LayerColorPicker.tsx
index a3bbcdb875..aabea569fd 100644
--- a/invokeai/frontend/web/src/features/regionalPrompts/components/LayerColorPicker.tsx
+++ b/invokeai/frontend/web/src/features/regionalPrompts/components/LayerColorPicker.tsx
@@ -1,11 +1,11 @@
-import { Popover, PopoverBody, PopoverContent, PopoverTrigger } from '@invoke-ai/ui-library';
+import { IconButton, Popover, PopoverBody, PopoverContent, PopoverTrigger } from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks';
-import { ColorPreview } from 'common/components/ColorPreview';
import RgbColorPicker from 'common/components/RgbColorPicker';
import { useLayer } from 'features/regionalPrompts/hooks/layerStateHooks';
import { promptRegionLayerColorChanged } from 'features/regionalPrompts/store/regionalPromptsSlice';
import { useCallback } from 'react';
import type { RgbColor } from 'react-colorful';
+import { PiEyedropperBold } from 'react-icons/pi';
type Props = {
id: string;
@@ -23,7 +23,7 @@ export const LayerColorPicker = ({ id }: Props) => {
return (
-
+ } />
diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/LayerListItem.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/LayerListItem.tsx
index ce81c64af2..6c3a9ac807 100644
--- a/invokeai/frontend/web/src/features/regionalPrompts/components/LayerListItem.tsx
+++ b/invokeai/frontend/web/src/features/regionalPrompts/components/LayerListItem.tsx
@@ -1,11 +1,12 @@
-import { Flex } from '@invoke-ai/ui-library';
+import { Flex, Spacer } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
+import { rgbColorToString } from 'features/canvas/util/colorToString';
import { LayerColorPicker } from 'features/regionalPrompts/components/LayerColorPicker';
import { LayerMenu } from 'features/regionalPrompts/components/LayerMenu';
import { LayerVisibilityToggle } from 'features/regionalPrompts/components/LayerVisibilityToggle';
import { RegionalPromptsPrompt } from 'features/regionalPrompts/components/RegionalPromptsPrompt';
import { layerSelected } from 'features/regionalPrompts/store/regionalPromptsSlice';
-import { useCallback, useMemo } from 'react';
+import { useCallback } from 'react';
type Props = {
id: string;
@@ -13,19 +14,24 @@ type Props = {
export const LayerListItem = ({ id }: Props) => {
const dispatch = useAppDispatch();
- const selectedLayer = useAppSelector((s) => s.regionalPrompts.selectedLayer);
- const bg = useMemo(() => (selectedLayer === id ? 'invokeBlue.500' : 'transparent'), [selectedLayer, id]);
+ const color = useAppSelector((s) => {
+ const color = s.regionalPrompts.layers.find((l) => l.id === id)?.color;
+ if (color) {
+ return rgbColorToString(color);
+ }
+ return 'base.700';
+ });
const onClickCapture = useCallback(() => {
// Must be capture so that the layer is selected before deleting/resetting/etc
dispatch(layerSelected(id));
}, [dispatch, id]);
return (
-
-
-
+
+
+
diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsPrompt.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsPrompt.tsx
index 53ff10fe27..54fa6df830 100644
--- a/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsPrompt.tsx
+++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsPrompt.tsx
@@ -1,13 +1,11 @@
import { Box, Textarea } from '@invoke-ai/ui-library';
-import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
-import { ShowDynamicPromptsPreviewButton } from 'features/dynamicPrompts/components/ShowDynamicPromptsPreviewButton';
+import { useAppDispatch } from 'app/store/storeHooks';
import { PromptOverlayButtonWrapper } from 'features/parameters/components/Prompts/PromptOverlayButtonWrapper';
import { AddPromptTriggerButton } from 'features/prompt/AddPromptTriggerButton';
import { PromptPopover } from 'features/prompt/PromptPopover';
import { usePrompt } from 'features/prompt/usePrompt';
import { useLayerPrompt } from 'features/regionalPrompts/hooks/layerStateHooks';
import { promptChanged } from 'features/regionalPrompts/store/regionalPromptsSlice';
-import { SDXLConcatButton } from 'features/sdxl/components/SDXLPrompts/SDXLConcatButton';
import { memo, useCallback, useRef } from 'react';
import type { HotkeyCallback } from 'react-hotkeys-hook';
import { useHotkeys } from 'react-hotkeys-hook';
@@ -20,7 +18,6 @@ type Props = {
export const RegionalPromptsPrompt = memo((props: Props) => {
const prompt = useLayerPrompt(props.layerId);
const dispatch = useAppDispatch();
- const baseModel = useAppSelector((s) => s.generation.model)?.base;
const textareaRef = useRef(null);
const { t } = useTranslation();
const _onChange = useCallback(
@@ -46,7 +43,7 @@ export const RegionalPromptsPrompt = memo((props: Props) => {
return (
-
+
diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsStage.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsStage.tsx
index b231db65a1..1936a13e17 100644
--- a/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsStage.tsx
+++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsStage.tsx
@@ -40,7 +40,8 @@ export const RegionalPromptsStage: React.FC = memo(() => {
}, []);
const sx = useMemo(
() => ({
- border: '1px solid cyan',
+ borderRadius: 'base',
+ borderWidth: 1,
cursor: tool === 'move' ? 'default' : 'none',
}),
[tool]