feat(ui): fix control adapters styling

This commit is contained in:
psychedelicious 2023-12-29 12:06:01 +11:00 committed by Kent Keirsey
parent 37786a26a5
commit ccbbb417f9
6 changed files with 35 additions and 26 deletions

View File

@ -14,8 +14,7 @@ const formBaseStyle = definePartsStyle((props) => {
display: 'flex', display: 'flex',
flexDirection: props.orientation === 'vertical' ? 'column' : 'row', flexDirection: props.orientation === 'vertical' ? 'column' : 'row',
alignItems: props.orientation === 'vertical' ? 'flex-start' : 'center', alignItems: props.orientation === 'vertical' ? 'flex-start' : 'center',
gap: 4, gap: props.orientation === 'vertical' ? 2 : 4,
// h: props.orientation === 'vertical' ? 'unset' : 8,
}, },
}; };
}); });

View File

@ -2,6 +2,7 @@ import { ChevronUpIcon } from '@chakra-ui/icons';
import { Box, Flex } from '@chakra-ui/react'; import { Box, Flex } from '@chakra-ui/react';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl'; import { InvControl } from 'common/components/InvControl/InvControl';
import type { InvLabelProps } from 'common/components/InvControl/types';
import { InvIconButton } from 'common/components/InvIconButton/InvIconButton'; import { InvIconButton } from 'common/components/InvIconButton/InvIconButton';
import { InvSwitch } from 'common/components/InvSwitch/wrapper'; import { InvSwitch } from 'common/components/InvSwitch/wrapper';
import { useControlAdapterIsEnabled } from 'features/controlAdapters/hooks/useControlAdapterIsEnabled'; import { useControlAdapterIsEnabled } from 'features/controlAdapters/hooks/useControlAdapterIsEnabled';
@ -29,6 +30,10 @@ import ParamControlAdapterProcessorSelect from './parameters/ParamControlAdapter
import ParamControlAdapterResizeMode from './parameters/ParamControlAdapterResizeMode'; import ParamControlAdapterResizeMode from './parameters/ParamControlAdapterResizeMode';
import ParamControlAdapterWeight from './parameters/ParamControlAdapterWeight'; import ParamControlAdapterWeight from './parameters/ParamControlAdapterWeight';
const labelProps: InvLabelProps = {
flexGrow: 1,
};
const ControlAdapterConfig = (props: { id: string; number: number }) => { const ControlAdapterConfig = (props: { id: string; number: number }) => {
const { id, number } = props; const { id, number } = props;
const controlAdapterType = useControlAdapterType(id); const controlAdapterType = useControlAdapterType(id);
@ -66,14 +71,17 @@ const ControlAdapterConfig = (props: { id: string; number: number }) => {
return ( return (
<Flex <Flex
flexDir="column" flexDir="column"
gap={3} gap={4}
p={2} p={4}
borderRadius="base" borderRadius="base"
position="relative" position="relative"
bg="base.750" bg="base.750"
> >
<Flex gap={2} alignItems="center" justifyContent="space-between"> <Flex gap={2} alignItems="center" justifyContent="space-between">
<InvControl label={t(`controlnet.${controlAdapterType}`, { number })}> <InvControl
label={t(`controlnet.${controlAdapterType}`, { number })}
labelProps={labelProps}
>
<InvSwitch <InvSwitch
aria-label={t('controlnet.toggleControlNet')} aria-label={t('controlnet.toggleControlNet')}
isChecked={isEnabled} isChecked={isEnabled}
@ -81,7 +89,7 @@ const ControlAdapterConfig = (props: { id: string; number: number }) => {
/> />
</InvControl> </InvControl>
</Flex> </Flex>
<Flex gap={2} alignItems="center"> <Flex gap={4} alignItems="center">
<Box <Box
minW={0} minW={0}
w="full" w="full"
@ -134,18 +142,9 @@ const ControlAdapterConfig = (props: { id: string; number: number }) => {
/> />
</Flex> </Flex>
<Flex w="full" flexDir="column" gap={3}> <Flex w="full" flexDir="column" gap={4}>
<Flex gap={4} w="full" alignItems="center"> <Flex gap={4} w="full" alignItems="center">
<Flex <Flex flexDir="column" gap={4} h={32} w="full">
flexDir="column"
gap={3}
h={28}
w="full"
paddingInlineStart={1}
paddingInlineEnd={isExpanded ? 1 : 0}
pb={2}
justifyContent="space-between"
>
<ParamControlAdapterWeight id={id} /> <ParamControlAdapterWeight id={id} />
<ParamControlAdapterBeginEnd id={id} /> <ParamControlAdapterBeginEnd id={id} />
</Flex> </Flex>
@ -153,23 +152,23 @@ const ControlAdapterConfig = (props: { id: string; number: number }) => {
<Flex <Flex
alignItems="center" alignItems="center"
justifyContent="center" justifyContent="center"
h={28} h={32}
w={28} w={32}
aspectRatio="1/1" aspectRatio="1/1"
> >
<ControlAdapterImagePreview id={id} isSmall /> <ControlAdapterImagePreview id={id} isSmall />
</Flex> </Flex>
)} )}
</Flex> </Flex>
</Flex>
{isExpanded && (
<>
<Flex gap={2}> <Flex gap={2}>
<ParamControlAdapterControlMode id={id} /> <ParamControlAdapterControlMode id={id} />
<ParamControlAdapterResizeMode id={id} /> <ParamControlAdapterResizeMode id={id} />
</Flex> </Flex>
<ParamControlAdapterProcessorSelect id={id} /> <ParamControlAdapterProcessorSelect id={id} />
</Flex>
{isExpanded && (
<>
<ControlAdapterImagePreview id={id} /> <ControlAdapterImagePreview id={id} />
<ControlAdapterShouldAutoConfig id={id} /> <ControlAdapterShouldAutoConfig id={id} />
<ControlAdapterProcessorComponent id={id} /> <ControlAdapterProcessorComponent id={id} />

View File

@ -1,5 +1,6 @@
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl'; import { InvControl } from 'common/components/InvControl/InvControl';
import type { InvLabelProps } from 'common/components/InvControl/types';
import { InvSwitch } from 'common/components/InvSwitch/wrapper'; import { InvSwitch } from 'common/components/InvSwitch/wrapper';
import { useControlAdapterIsEnabled } from 'features/controlAdapters/hooks/useControlAdapterIsEnabled'; import { useControlAdapterIsEnabled } from 'features/controlAdapters/hooks/useControlAdapterIsEnabled';
import { useControlAdapterShouldAutoConfig } from 'features/controlAdapters/hooks/useControlAdapterShouldAutoConfig'; import { useControlAdapterShouldAutoConfig } from 'features/controlAdapters/hooks/useControlAdapterShouldAutoConfig';
@ -12,6 +13,10 @@ type Props = {
id: string; id: string;
}; };
const labelProps: InvLabelProps = {
flexGrow: 1,
};
const ControlAdapterShouldAutoConfig = ({ id }: Props) => { const ControlAdapterShouldAutoConfig = ({ id }: Props) => {
const isEnabled = useControlAdapterIsEnabled(id); const isEnabled = useControlAdapterIsEnabled(id);
const shouldAutoConfig = useControlAdapterShouldAutoConfig(id); const shouldAutoConfig = useControlAdapterShouldAutoConfig(id);
@ -27,7 +32,11 @@ const ControlAdapterShouldAutoConfig = ({ id }: Props) => {
} }
return ( return (
<InvControl label={t('controlnet.autoConfigure')} isDisabled={!isEnabled}> <InvControl
label={t('controlnet.autoConfigure')}
isDisabled={!isEnabled}
labelProps={labelProps}
>
<InvSwitch <InvSwitch
isChecked={shouldAutoConfig} isChecked={shouldAutoConfig}
onChange={handleShouldAutoConfigChanged} onChange={handleShouldAutoConfigChanged}

View File

@ -64,6 +64,7 @@ export const ParamControlAdapterBeginEnd = memo(({ id }: Props) => {
isDisabled={!isEnabled} isDisabled={!isEnabled}
label={t('controlnet.beginEndStepPercent')} label={t('controlnet.beginEndStepPercent')}
feature="controlNetBeginEnd" feature="controlNetBeginEnd"
orientation="vertical"
> >
<InvRangeSlider <InvRangeSlider
aria-label={['Begin Step %', 'End Step %']} aria-label={['Begin Step %', 'End Step %']}

View File

@ -34,6 +34,7 @@ const ParamControlAdapterWeight = ({ id }: ParamControlAdapterWeightProps) => {
label={t('controlnet.weight')} label={t('controlnet.weight')}
isDisabled={!isEnabled} isDisabled={!isEnabled}
feature="controlNetWeight" feature="controlNetWeight"
orientation="vertical"
> >
<InvSlider <InvSlider
value={weight} value={weight}

View File

@ -5,7 +5,7 @@ type Props = PropsWithChildren;
export default function ProcessorWrapper(props: Props) { export default function ProcessorWrapper(props: Props) {
return ( return (
<Flex flexDir="column" gap={2} pb={2}> <Flex flexDir="column" gap={4}>
{props.children} {props.children}
</Flex> </Flex>
); );