feat(ui): tweak layer ui component

This commit is contained in:
psychedelicious 2024-07-03 16:18:06 +10:00
parent eef9278ee6
commit 918354cd9d
3 changed files with 11 additions and 15 deletions

View File

@ -1,10 +1,12 @@
import { useDisclosure } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import IAIDroppable from 'common/components/IAIDroppable';
import { CanvasEntityContainer } from 'features/controlLayers/components/common/CanvasEntityContainer';
import { LayerHeader } from 'features/controlLayers/components/Layer/LayerHeader';
import { LayerSettings } from 'features/controlLayers/components/Layer/LayerSettings';
import { entitySelected } from 'features/controlLayers/store/canvasV2Slice';
import { memo, useCallback } from 'react';
import type { LayerImageDropData } from 'features/dnd/types';
import { memo, useCallback, useMemo } from 'react';
type Props = {
id: string;
@ -17,11 +19,16 @@ export const Layer = memo(({ id }: Props) => {
const onSelect = useCallback(() => {
dispatch(entitySelected({ id, type: 'layer' }));
}, [dispatch, id]);
const droppableData = useMemo<LayerImageDropData>(
() => ({ id, actionType: 'ADD_LAYER_IMAGE', context: { id } }),
[id]
);
return (
<CanvasEntityContainer isSelected={isSelected} onSelect={onSelect}>
<LayerHeader id={id} onToggleVisibility={onToggle} />
{isOpen && <LayerSettings id={id} />}
<IAIDroppable data={droppableData} />
</CanvasEntityContainer>
);
});

View File

@ -1,24 +1,12 @@
import IAIDroppable from 'common/components/IAIDroppable';
import { CanvasEntitySettings } from 'features/controlLayers/components/common/CanvasEntitySettings';
import type { LayerImageDropData } from 'features/dnd/types';
import { memo, useMemo } from 'react';
import { memo } from 'react';
type Props = {
id: string;
};
export const LayerSettings = memo(({ id }: Props) => {
const droppableData = useMemo<LayerImageDropData>(
() => ({ id, actionType: 'ADD_LAYER_IMAGE', context: { id } }),
[id]
);
return (
<CanvasEntitySettings>
PLACEHOLDER
<IAIDroppable data={droppableData} />
</CanvasEntitySettings>
);
return <CanvasEntitySettings>PLACEHOLDER</CanvasEntitySettings>;
});
LayerSettings.displayName = 'LayerSettings';

View File

@ -25,6 +25,7 @@ export const CanvasEntityContainer = memo(({ isSelected, onSelect, selectedBorde
return (
<Flex
position="relative" // necessary for drop overlay
flexDir="column"
w="full"
bg="base.850"