Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add previewImage to combobox. #6756

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Pfannkuchensack
Copy link
Contributor

this works only with the pull request invoke-ai/ui-library#20

Summary

Look at #6726
previewimage_lora

Related Issues / Discussions

invoke-ai/ui-library#20

QA Instructions

Only if the combobox options have the new params the change will have a effect. so any combobox option without previewImage and withPreviewImage field behaves normal/unchanged

Merge Plan

No concerns

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)

@psychedelicious
Copy link
Collaborator

psychedelicious commented Aug 18, 2024

Actually the component already supports this with the icon prop. I can be any ReactNode:

diff --git a/invokeai/frontend/web/src/common/hooks/useGroupedModelCombobox.ts b/invokeai/frontend/web/src/common/hooks/useGroupedModelCombobox.ts
index 5b57fcd2b..4e3cb29d9 100644
--- a/invokeai/frontend/web/src/common/hooks/useGroupedModelCombobox.ts
+++ b/invokeai/frontend/web/src/common/hooks/useGroupedModelCombobox.ts
@@ -1,8 +1,10 @@
 import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library';
+import { Image } from '@invoke-ai/ui-library';
 import { useAppSelector } from 'app/store/storeHooks';
 import type { GroupBase } from 'chakra-react-select';
 import type { ModelIdentifierField } from 'features/nodes/types/common';
 import { groupBy, reduce } from 'lodash-es';
+import InvokeLogoWhite from 'public/assets/images/invoke-symbol-wht-lrg.svg';
 import { useCallback, useMemo } from 'react';
 import { useTranslation } from 'react-i18next';
 import type { AnyModelConfig } from 'services/api/types';
@@ -48,6 +50,7 @@ export const useGroupedModelCombobox = <T extends AnyModelConfig>(
             label: model.name,
             value: model.key,
             isDisabled: getIsDisabled ? getIsDisabled(model) : false,
+            icon: <Image src={model.cover_image ?? InvokeLogoWhite} w={8} h={8} minW={8} minH={8} flexShrink={0} />,
           })),
         });
         return acc;

(you'll need to change the file extension to end with .tsx to include JSX)

Maybe ui-library needs some changes to better style components passed as icon - maybe some vertically alignment - but we probably don't need to add any props to it.

Suggest making a component in this repo to show the model image or fallback icon, styled similarly to what is pictured in this PR. Then iterate on any styling in ui-library, using icon only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants