InvokeAI/invokeai/frontend/web/src/common/components/IAISimpleMenu.tsx

86 lines
1.9 KiB
TypeScript
Raw Normal View History

2023-02-19 00:17:45 +00:00
import {
Menu,
MenuButton,
MenuItem,
MenuList,
MenuProps,
MenuListProps,
MenuItemProps,
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
IconButton,
Button,
IconButtonProps,
ButtonProps,
2023-02-19 00:17:45 +00:00
} from '@chakra-ui/react';
import { MouseEventHandler, ReactNode } from 'react';
import { MdArrowDropDown, MdArrowDropUp } from 'react-icons/md';
interface IAIMenuItem {
item: ReactNode | string;
onClick: MouseEventHandler<HTMLButtonElement> | undefined;
}
interface IAIMenuProps {
menuType?: 'icon' | 'regular';
buttonText?: string;
iconTooltip?: string;
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
isLazy?: boolean;
2023-02-19 00:17:45 +00:00
menuItems: IAIMenuItem[];
menuProps?: MenuProps;
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
menuButtonProps?: IconButtonProps | ButtonProps;
2023-02-19 00:17:45 +00:00
menuListProps?: MenuListProps;
menuItemProps?: MenuItemProps;
}
export default function IAISimpleMenu(props: IAIMenuProps) {
const {
menuType = 'icon',
iconTooltip,
buttonText,
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
isLazy = true,
2023-02-19 00:17:45 +00:00
menuItems,
menuProps,
menuButtonProps,
menuListProps,
menuItemProps,
} = props;
const renderMenuItems = () => {
const menuItemsToRender: ReactNode[] = [];
2023-02-19 00:25:01 +00:00
menuItems.forEach((menuItem, index) => {
2023-02-19 00:17:45 +00:00
menuItemsToRender.push(
<MenuItem
2023-02-19 00:25:01 +00:00
key={index}
2023-02-19 00:17:45 +00:00
onClick={menuItem.onClick}
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
fontSize="sm"
2023-02-19 00:17:45 +00:00
{...menuItemProps}
>
{menuItem.item}
</MenuItem>
);
});
return menuItemsToRender;
};
return (
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
<Menu {...menuProps} isLazy={isLazy}>
2023-02-19 00:17:45 +00:00
{({ isOpen }) => (
<>
<MenuButton
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
as={menuType === 'icon' ? IconButton : Button}
2023-02-19 00:17:45 +00:00
tooltip={iconTooltip}
icon={isOpen ? <MdArrowDropUp /> : <MdArrowDropDown />}
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
paddingX={0}
paddingY={menuType === 'regular' ? 2 : 0}
2023-02-19 00:17:45 +00:00
{...menuButtonProps}
>
{menuType === 'regular' && buttonText}
</MenuButton>
feat(ui): migrated theming to chakra build(ui): fix husky path build(ui): fix hmr issue, remove emotion cache build(ui): clean up package.json build(ui): update gh action and npm scripts feat(ui): wip port lightbox to chakra theme feat(ui): wip use chakra theme tokens feat(ui): Add status text to main loading spinner feat(ui): wip chakra theme tweaking feat(ui): simply iaisimplemenu button feat(ui): wip chakra theming feat(ui): Theme Management feat(ui): Add Ocean Blue Theme feat(ui): wip lightbox fix(ui): fix lightbox mouse feat(ui): set default theme variants feat(ui): model manager chakra theme chore(ui): lint feat(ui): remove last scss feat(ui): fix switch theme feat(ui): Theme Cleanup feat(ui): Stylize Search Models Found List feat(ui): hide scrollbars feat(ui): fix floating button position feat(ui): Scrollbar Styling fix broken scripts This PR fixes the following scripts: 1) Scripts that can be executed within the repo's scripts directory. Note that these are for development testing and are not intended to be exposed to the user. configure_invokeai.py - configuration dream.py - the legacy CLI images2prompt.py - legacy "dream prompt" retriever invoke-new.py - new nodes-based CLI invoke.py - the legacy CLI under another name make_models_markdown_table.py - a utility used during the release/doc process pypi_helper.py - another utility used during the release process sd-metadata.py - retrieve JSON-formatted metadata from a PNG file 2) Scripts that are installed by pip install. They get placed into the venv's PATH and are intended to be the official entry points: invokeai-node-cli - new nodes-based CLI invokeai-node-web - new nodes-based web server invokeai - legacy CLI invokeai-configure - install time configuration script invokeai-merge - model merging script invokeai-ti - textual inversion script invokeai-model-install - model installer invokeai-update - update script invokeai-metadata" - retrieve JSON-formatted metadata from PNG files protect invocations against black autoformatting deps: upgrade to diffusers 0.14, safetensors 0.3, transformers 4.26, accelerate 0.16
2023-03-03 23:41:46 +00:00
<MenuList zIndex={15} padding={0} {...menuListProps}>
2023-02-19 00:17:45 +00:00
{renderMenuItems()}
</MenuList>
</>
)}
</Menu>
);
}