11import type { SystemStyleObject } from '@invoke-ai/ui-library' ;
2- import { Flex , Icon , IconButton , Image , Skeleton , Text } from '@invoke-ai/ui-library' ;
2+ import { Flex , Icon , IconButton , Image , Skeleton , Text , Tooltip } from '@invoke-ai/ui-library' ;
33import { skipToken } from '@reduxjs/toolkit/query' ;
44import { useAppDispatch , useAppSelector } from 'app/store/storeHooks' ;
55import { round } from 'es-toolkit/compat' ;
@@ -17,6 +17,8 @@ import { memo, useCallback, useEffect, useMemo, useState } from 'react';
1717import { PiExclamationMarkBold , PiEyeSlashBold , PiImageBold } from 'react-icons/pi' ;
1818import { useGetImageDTOQuery } from 'services/api/endpoints/images' ;
1919
20+ import { RefImageWarningTooltipContent } from './RefImageWarningTooltipContent' ;
21+
2022const baseSx : SystemStyleObject = {
2123 '&[data-is-open="true"]' : {
2224 borderColor : 'invokeBlue.300' ,
@@ -51,9 +53,6 @@ const getImageSxWithWeight = (weight: number): SystemStyleObject => {
5153
5254 return {
5355 ...baseSx ,
54- '&[data-is-disabled="true"]' : {
55- opacity : 0.4 ,
56- } ,
5756 _after : {
5857 content : '""' ,
5958 position : 'absolute' ,
@@ -95,8 +94,8 @@ export const RefImagePreview = memo(() => {
9594 } ;
9695 } , [ entity . config ] ) ;
9796
98- const isInvalid = useMemo ( ( ) => {
99- return getGlobalReferenceImageWarnings ( entity , mainModelConfig ) . length > 0 ;
97+ const warnings = useMemo ( ( ) => {
98+ return getGlobalReferenceImageWarnings ( entity , mainModelConfig ) ;
10099 } , [ entity , mainModelConfig ] ) ;
101100
102101 const onClick = useCallback ( ( ) => {
@@ -126,74 +125,76 @@ export const RefImagePreview = memo(() => {
126125 ) ;
127126 }
128127 return (
129- < Flex
130- position = "relative"
131- borderWidth = { 1 }
132- borderStyle = "solid"
133- borderRadius = "base"
134- aspectRatio = "1/1"
135- maxW = "full"
136- maxH = "full"
137- flexShrink = { 0 }
138- sx = { sx }
139- data-is-open = { selectedEntityId === id && isPanelOpen }
140- data-is-error = { isInvalid }
141- data-is-disabled = { ! entity . isEnabled }
142- role = "button"
143- onClick = { onClick }
144- cursor = "pointer"
145- >
146- < Image
147- src = { imageDTO ?. thumbnail_url }
148- objectFit = "contain"
128+ < Tooltip label = { warnings . length > 0 ? < RefImageWarningTooltipContent warnings = { warnings } /> : undefined } >
129+ < Flex
130+ position = "relative"
131+ borderWidth = { 1 }
132+ borderStyle = "solid"
133+ borderRadius = "base"
149134 aspectRatio = "1/1"
150- height = { imageDTO ?. height }
151- fallback = { < Skeleton h = "full" aspectRatio = "1/1" /> }
152135 maxW = "full"
153136 maxH = "full"
154- borderRadius = "base"
155- />
156- { isIPAdapterConfig ( entity . config ) && (
157- < Flex
158- position = "absolute"
159- inset = { 0 }
160- fontWeight = "semibold"
161- alignItems = "center"
162- justifyContent = "center"
163- zIndex = { 1 }
164- data-visible = { showWeightDisplay }
165- sx = { weightDisplaySx }
166- >
167- < Text filter = "drop-shadow(0px 0px 4px rgb(0, 0, 0)) drop-shadow(0px 0px 2px rgba(0, 0, 0, 1))" >
168- { `${ round ( entity . config . weight * 100 , 2 ) } %` }
169- </ Text >
170- </ Flex >
171- ) }
172- { ! entity . isEnabled && (
173- < Icon
174- position = "absolute"
175- top = "50%"
176- left = "50%"
177- transform = "translateX(-50%) translateY(-50%)"
178- filter = "drop-shadow(0px 0px 4px rgb(0, 0, 0)) drop-shadow(0px 0px 2px rgba(0, 0, 0, 1))"
179- color = "base.300"
180- boxSize = { 8 }
181- as = { PiEyeSlashBold }
182- />
183- ) }
184- { entity . isEnabled && isInvalid && (
185- < Icon
186- position = "absolute"
187- top = "50%"
188- left = "50%"
189- transform = "translateX(-50%) translateY(-50%)"
190- filter = "drop-shadow(0px 0px 4px rgb(0, 0, 0)) drop-shadow(0px 0px 2px rgba(0, 0, 0, 1))"
191- color = "error.500"
192- boxSize = { 12 }
193- as = { PiExclamationMarkBold }
137+ flexShrink = { 0 }
138+ sx = { sx }
139+ data-is-open = { selectedEntityId === id && isPanelOpen }
140+ data-is-error = { warnings . length > 0 }
141+ data-is-disabled = { ! entity . isEnabled }
142+ role = "button"
143+ onClick = { onClick }
144+ cursor = "pointer"
145+ >
146+ < Image
147+ src = { imageDTO ?. thumbnail_url }
148+ objectFit = "contain"
149+ aspectRatio = "1/1"
150+ height = { imageDTO ?. height }
151+ fallback = { < Skeleton h = "full" aspectRatio = "1/1" /> }
152+ maxW = "full"
153+ maxH = "full"
154+ borderRadius = "base"
194155 />
195- ) }
196- </ Flex >
156+ { isIPAdapterConfig ( entity . config ) && (
157+ < Flex
158+ position = "absolute"
159+ inset = { 0 }
160+ fontWeight = "semibold"
161+ alignItems = "center"
162+ justifyContent = "center"
163+ zIndex = { 1 }
164+ data-visible = { showWeightDisplay }
165+ sx = { weightDisplaySx }
166+ >
167+ < Text filter = "drop-shadow(0px 0px 4px rgb(0, 0, 0)) drop-shadow(0px 0px 2px rgba(0, 0, 0, 1))" >
168+ { `${ round ( entity . config . weight * 100 , 2 ) } %` }
169+ </ Text >
170+ </ Flex >
171+ ) }
172+ { ! entity . isEnabled && (
173+ < Icon
174+ position = "absolute"
175+ top = "50%"
176+ left = "50%"
177+ transform = "translateX(-50%) translateY(-50%)"
178+ filter = "drop-shadow(0px 0px 4px rgb(0, 0, 0)) drop-shadow(0px 0px 2px rgba(0, 0, 0, 1))"
179+ color = "base.300"
180+ boxSize = { 8 }
181+ as = { PiEyeSlashBold }
182+ />
183+ ) }
184+ { entity . isEnabled && warnings . length > 0 && (
185+ < Icon
186+ position = "absolute"
187+ top = "50%"
188+ left = "50%"
189+ transform = "translateX(-50%) translateY(-50%)"
190+ filter = "drop-shadow(0px 0px 4px rgb(0, 0, 0)) drop-shadow(0px 0px 2px rgba(0, 0, 0, 1))"
191+ color = "error.500"
192+ boxSize = { 12 }
193+ as = { PiExclamationMarkBold }
194+ />
195+ ) }
196+ </ Flex >
197+ </ Tooltip >
197198 ) ;
198199} ) ;
199200RefImagePreview . displayName = 'RefImagePreview' ;
0 commit comments