Skip to content

Commit 100be2c

Browse files
feat(ui): related embedding styling/tidy
1 parent cdd5917 commit 100be2c

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

invokeai/frontend/web/src/features/prompt/PromptTriggerSelect.tsx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ChakraProps, ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library';
2-
import { Combobox, FormControl, Icon } from '@invoke-ai/ui-library';
2+
import { Combobox, Flex, FormControl, Icon } from '@invoke-ai/ui-library';
33
import { skipToken } from '@reduxjs/toolkit/query';
44
import { useAppSelector } from 'app/store/storeHooks';
55
import type { GroupBase } from 'chakra-react-select';
@@ -18,7 +18,7 @@ import { isNonRefinerMainModelConfig } from 'services/api/types';
1818

1919
const noOptionsMessage = () => t('prompt.noMatchingTriggers');
2020

21-
type RelatedEmbedding = ComboboxOption & { starred?: boolean };
21+
type ComboboxOptionWithStarred = ComboboxOption & { starred?: boolean };
2222

2323
export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSelectProps) => {
2424
const { t } = useTranslation();
@@ -65,7 +65,7 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
6565
);
6666

6767
const options = useMemo(() => {
68-
const _options: GroupBase<ComboboxOption>[] = [];
68+
const _options: GroupBase<ComboboxOptionWithStarred>[] = [];
6969

7070
if (loraModels) {
7171
const triggerPhraseOptions = loraModels
@@ -88,7 +88,7 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
8888

8989
if (tiModels) {
9090
// Create embedding options with starred property for related models
91-
const embeddingOptions: RelatedEmbedding[] = tiModels
91+
const embeddingOptions: ComboboxOptionWithStarred[] = tiModels
9292
.filter((ti) => ti.base === mainModelConfig?.base)
9393
.map((model) => ({
9494
label: model.name,
@@ -128,27 +128,26 @@ export const PromptTriggerSelect = memo(({ onSelect, onClose }: PromptTriggerSel
128128
return _options;
129129
}, [tiModels, loraModels, mainModelConfig, t, addedLoRAs, relatedModelKeys]);
130130

131-
const formatOptionLabel = useCallback((option: ComboboxOption) => {
132-
const embeddingOption = option as RelatedEmbedding;
133-
if (embeddingOption.starred) {
134-
return (
135-
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
136-
<Icon as={PiLinkSimple} color="invokeYellow.500" boxSize={3} />
137-
{option.label}
138-
</div>
139-
);
140-
}
141-
return option.label;
131+
const formatOptionLabel = useCallback((option: ComboboxOptionWithStarred) => {
132+
return (
133+
<Flex alignItems="center" gap={2}>
134+
{option.starred && <Icon as={PiLinkSimple} color="invokeYellow.500" boxSize={4} />}
135+
{option.label}
136+
</Flex>
137+
);
142138
}, []);
143139

140+
const placeholder = useMemo(() => {
141+
if (isLoadingLoRAs || isLoadingTIs || isLoadingMainModelConfig) {
142+
return t('common.loading');
143+
}
144+
return t('prompt.addPromptTrigger');
145+
}, [t, isLoadingLoRAs, isLoadingTIs, isLoadingMainModelConfig]);
146+
144147
return (
145148
<FormControl>
146149
<Combobox
147-
placeholder={
148-
isLoadingLoRAs || isLoadingTIs || isLoadingMainModelConfig
149-
? t('common.loading')
150-
: t('prompt.addPromptTrigger')
151-
}
150+
placeholder={placeholder}
152151
defaultMenuIsOpen
153152
autoFocus
154153
value={null}

0 commit comments

Comments
 (0)