Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import {
Button,
ButtonGroup,
FormControl,
FormLabel,
IconButton,
Popover,
PopoverArrow,
PopoverBody,
PopoverContent,
PopoverTrigger,
Portal,
} from '@invoke-ai/ui-library';
import { useAppDispatch } from 'app/store/storeHooks';
import { formElementContainerDataChanged } from 'features/nodes/store/nodesSlice';
import type { ContainerElement } from 'features/nodes/types/workflow';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiWrenchFill } from 'react-icons/pi';
export const ContainerElementSettings = memo(({ element }: { element: ContainerElement }) => {
const { id, data } = element;
const { layout } = data;
const { t } = useTranslation();
const dispatch = useAppDispatch();
const setLayoutToRow = useCallback(() => {
dispatch(formElementContainerDataChanged({ id, changes: { layout: 'row' } }));
}, [dispatch, id]);
const setLayoutToColumn = useCallback(() => {
dispatch(formElementContainerDataChanged({ id, changes: { layout: 'column' } }));
}, [dispatch, id]);
return (
<Popover placement="top" isLazy lazyBehavior="unmount">
<PopoverTrigger>
<IconButton
aria-label={t('common.settings')}
icon={<PiWrenchFill />}
variant="link"
size="sm"
alignSelf="stretch"
/>
</PopoverTrigger>
<Portal>
<PopoverContent>
<PopoverArrow />
<PopoverBody>
<FormControl>
<FormLabel m={0}>{t('workflows.builder.layout')}</FormLabel>
<ButtonGroup variant="outline" size="sm">
<Button onClick={setLayoutToRow} colorScheme={layout === 'row' ? 'invokeBlue' : 'base'}>
{t('workflows.builder.row')}
</Button>
<Button onClick={setLayoutToColumn} colorScheme={layout === 'column' ? 'invokeBlue' : 'base'}>
{t('workflows.builder.column')}
</Button>
</ButtonGroup>
</FormControl>
</PopoverBody>
</PopoverContent>
</Portal>
</Popover>
);
});
ContainerElementSettings.displayName = 'ContainerElementSettings';