From 5aefa49d7d80ce3cd7e79a1f70cb3c5aec66dd7d Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 21 Sep 2023 20:01:00 +1000 Subject: [PATCH] fix(ui): popover ref & wrapping of children (wip) --- invokeai/frontend/web/public/locales/en.json | 18 ++-- .../components/IAIInformationalPopover.tsx | 86 +++++++++++-------- .../components/IAIMantineMultiSelect.tsx | 10 ++- .../components/IAIMantineSearchableSelect.tsx | 10 ++- .../common/components/IAIMantineSelect.tsx | 10 ++- .../src/common/components/IAINumberInput.tsx | 8 +- .../web/src/common/components/IAISlider.tsx | 8 +- .../web/src/common/components/IAISwitch.tsx | 2 + .../Parameters/Core/ParamIterations.tsx | 4 +- .../Core/ParamNegativeConditioning.tsx | 47 +++++----- .../Core/ParamPositiveConditioning.tsx | 23 ++--- .../MainModel/ParamMainModelSelect.tsx | 18 ++-- .../web/src/theme/components/popover.ts | 2 +- 13 files changed, 140 insertions(+), 106 deletions(-) diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index c309e4de50..f48df3368f 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -1213,14 +1213,14 @@ }, "dynamicPromptsCombinatorial": { "heading": "Combinatorial Generation", - "paragraph": "Generate an image for every possible combination of Dynamic Prompt until the Max Prompts is reached." + "paragraph": "Generate an image for every possible combination of Dynamic Prompts until the Max Prompts is reached." }, "infillMethod": { "heading": "Infill Method", "paragraph": "Method to infill the selected area." }, "lora": { - "heading": "LoRA", + "heading": "LoRA Weight", "paragraph": "Weight of the LoRA. Higher weight will lead to larger impacts on the final image." }, "noiseEnable": { @@ -1239,21 +1239,21 @@ "heading": "Denoising Strength", "paragraph": "How much noise is added to the input image. 0 will result in an identical image, while 1 will result in a completely new image." }, - "paramImages": { - "heading": "Images", - "paragraph": "Number of images that will be generated." + "paramIterations": { + "heading": "Iterations", + "paragraph": "The number of images to generate. If Dynamic Prompts is enabled, each of the prompts will be generated this many times." }, "paramModel": { "heading": "Model", "paragraph": "Model used for the denoising steps. Different models are trained to specialize in producing different aesthetic results and content." }, "paramNegativeConditioning": { - "heading": "Negative Prompts", - "paragraph": "This is where you enter your negative prompts." + "heading": "Negative Prompt", + "paragraph": "The generation process avoids the concepts in the negative prompt. Use this to exclude qualities or objects from the output. Supports Compel syntax and embeddings." }, "paramPositiveConditioning": { - "heading": "Positive Prompts", - "paragraph": "This is where you enter your positive prompts." + "heading": "Positive Prompt", + "paragraph": "Guides the generation process. You may use any words or phrases. Supports Compel and Dynamic Prompts syntaxes and embeddings." }, "paramRatio": { "heading": "Ratio", diff --git a/invokeai/frontend/web/src/common/components/IAIInformationalPopover.tsx b/invokeai/frontend/web/src/common/components/IAIInformationalPopover.tsx index 876ce6488a..4a9dd82665 100644 --- a/invokeai/frontend/web/src/common/components/IAIInformationalPopover.tsx +++ b/invokeai/frontend/web/src/common/components/IAIInformationalPopover.tsx @@ -1,37 +1,43 @@ import { + Box, Button, - Popover, - PopoverTrigger, - PopoverContent, - PopoverArrow, - PopoverCloseButton, - PopoverHeader, - PopoverBody, - PopoverProps, + Divider, Flex, - Text, + Heading, Image, + Popover, + PopoverArrow, + PopoverBody, + PopoverCloseButton, + PopoverContent, + PopoverProps, + PopoverTrigger, + Portal, + Text, } from '@chakra-ui/react'; -import { useAppSelector } from '../../app/store/storeHooks'; +import { ReactNode, memo } from 'react'; import { useTranslation } from 'react-i18next'; +import { useAppSelector } from '../../app/store/storeHooks'; -interface Props extends PopoverProps { +const OPEN_DELAY = 1500; + +type Props = Omit & { details: string; - children: JSX.Element; + children: ReactNode; image?: string; buttonLabel?: string; buttonHref?: string; placement?: PopoverProps['placement']; -} +}; -function IAIInformationalPopover({ +const IAIInformationalPopover = ({ details, image, buttonLabel, buttonHref, children, placement, -}: Props): JSX.Element { +}: Props) => { const shouldEnableInformationalPopovers = useAppSelector( (state) => state.system.shouldEnableInformationalPopovers ); @@ -41,18 +47,21 @@ function IAIInformationalPopover({ const paragraph = t(`popovers.${details}.paragraph`); if (!shouldEnableInformationalPopovers) { - return children; - } else { - return ( - - -
{children}
-
+ return <>{children}; + } + + return ( + + + {children} + + @@ -83,14 +92,17 @@ function IAIInformationalPopover({ gap: 3, flexDirection: 'column', width: '100%', - p: 3, - pt: heading ? 0 : 3, }} > - {heading && {heading}} - {paragraph} + {heading && ( + <> + {heading} + + + )} + {paragraph} {buttonLabel && ( - +