mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): init image tweaks
This commit is contained in:
parent
deae5fbaec
commit
c8fe12cd91
@ -1,32 +1,11 @@
|
||||
import { Badge, Box, ButtonGroup, Flex } from '@chakra-ui/react';
|
||||
import { RootState } from 'app/store/store';
|
||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||
import { clearInitialImage } from 'features/parameters/store/generationSlice';
|
||||
import { useCallback } from 'react';
|
||||
import IAIIconButton from 'common/components/IAIIconButton';
|
||||
import { FaUndo, FaUpload } from 'react-icons/fa';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Badge, Box, Flex } from '@chakra-ui/react';
|
||||
import { Image } from 'app/types/invokeai';
|
||||
|
||||
type ImageToImageOverlayProps = {
|
||||
setIsLoaded: (isLoaded: boolean) => void;
|
||||
image: Image;
|
||||
};
|
||||
|
||||
const ImageToImageOverlay = ({
|
||||
setIsLoaded,
|
||||
image,
|
||||
}: ImageToImageOverlayProps) => {
|
||||
const isImageToImageEnabled = useAppSelector(
|
||||
(state: RootState) => state.generation.isImageToImageEnabled
|
||||
);
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
const handleResetInitialImage = useCallback(() => {
|
||||
dispatch(clearInitialImage());
|
||||
setIsLoaded(false);
|
||||
}, [dispatch, setIsLoaded]);
|
||||
|
||||
const ImageToImageOverlay = ({ image }: ImageToImageOverlayProps) => {
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
|
@ -1,34 +1,13 @@
|
||||
import {
|
||||
Box,
|
||||
ButtonGroup,
|
||||
Collapse,
|
||||
Flex,
|
||||
Heading,
|
||||
HStack,
|
||||
Image,
|
||||
Spacer,
|
||||
Text,
|
||||
useDisclosure,
|
||||
VStack,
|
||||
} from '@chakra-ui/react';
|
||||
import { motion } from 'framer-motion';
|
||||
|
||||
import IAIButton from 'common/components/IAIButton';
|
||||
import ImageFit from 'features/parameters/components/AdvancedParameters/ImageToImage/ImageFit';
|
||||
import ImageToImageStrength from 'features/parameters/components/AdvancedParameters/ImageToImage/ImageToImageStrength';
|
||||
import { ButtonGroup, Flex, Spacer, Text } from '@chakra-ui/react';
|
||||
import IAIIconButton from 'common/components/IAIIconButton';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FaUndo, FaUpload } from 'react-icons/fa';
|
||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||
import { RootState } from 'app/store/store';
|
||||
import { useAppDispatch } from 'app/store/storeHooks';
|
||||
import { useCallback } from 'react';
|
||||
import { clearInitialImage } from 'features/parameters/store/generationSlice';
|
||||
|
||||
const ImageToImageSettingsHeader = () => {
|
||||
const isImageToImageEnabled = useAppSelector(
|
||||
(state: RootState) => state.generation.isImageToImageEnabled
|
||||
);
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
@ -17,7 +17,7 @@ import { ImageType } from 'services/api';
|
||||
import ImageToImageOverlay from 'common/components/ImageToImageOverlay';
|
||||
import { initialImageSelector } from 'features/parameters/store/generationSelectors';
|
||||
|
||||
const initialImagePreviewSelector = createSelector(
|
||||
const selector = createSelector(
|
||||
[initialImageSelector],
|
||||
(initialImage) => {
|
||||
return {
|
||||
@ -31,7 +31,7 @@ const InitialImagePreview = () => {
|
||||
const isImageToImageEnabled = useAppSelector(
|
||||
(state: RootState) => state.generation.isImageToImageEnabled
|
||||
);
|
||||
const { initialImage } = useAppSelector(initialImagePreviewSelector);
|
||||
const { initialImage } = useAppSelector(selector);
|
||||
const { getUrl } = useGetUrl();
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
@ -113,12 +113,7 @@ const InitialImagePreview = () => {
|
||||
</Flex>
|
||||
}
|
||||
/>
|
||||
{isLoaded && (
|
||||
<ImageToImageOverlay
|
||||
setIsLoaded={setIsLoaded}
|
||||
image={initialImage}
|
||||
/>
|
||||
)}
|
||||
{isLoaded && <ImageToImageOverlay image={initialImage} />}
|
||||
</Box>
|
||||
)}
|
||||
{!initialImage?.url && <SelectImagePlaceholder />}
|
||||
|
@ -15,9 +15,9 @@ const AnimatedImageToImagePanel = () => {
|
||||
<AnimatePresence>
|
||||
{isImageToImageEnabled && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, scaleX: 0, width: 0 }}
|
||||
animate={{ opacity: 1, scaleX: 1, width: '28rem' }}
|
||||
exit={{ opacity: 0, scaleX: 0, width: 0 }}
|
||||
initial={{ opacity: 0, scale: 0, width: 0 }}
|
||||
animate={{ opacity: 1, scale: 1, width: '28rem' }}
|
||||
exit={{ opacity: 0, scale: 0, width: 0 }}
|
||||
transition={{ type: 'spring', bounce: 0, duration: 0.35 }}
|
||||
>
|
||||
<Box sx={{ h: 'full', w: 'full', pl: 4 }}>
|
||||
|
Loading…
Reference in New Issue
Block a user