feat(ui): updated layer list component styling

This commit is contained in:
psychedelicious 2024-07-03 16:10:49 +10:00
parent 49371ddec9
commit bd16dc4479
3 changed files with 20 additions and 12 deletions

View File

@ -1679,12 +1679,17 @@
"globalIPAdapterLayer": "Global $t(common.ipAdapter) $t(unifiedCanvas.layer)",
"globalInitialImage": "Global Initial Image",
"globalInitialImageLayer": "$t(controlLayers.globalInitialImage) $t(unifiedCanvas.layer)",
"inpaintMask": "Inpaint Mask",
"layer": "Layer",
"opacityFilter": "Opacity Filter",
"clearProcessor": "Clear Processor",
"resetProcessor": "Reset Processor to Defaults",
"noLayersAdded": "No Layers Added",
"layers_one": "Layer",
"layers_other": "Layers"
"layers_other": "Layers",
"objects_zero": "empty",
"objects_one": "{{count}} object",
"objects_other": "{{count}} objects"
},
"upscaling": {
"upscale": "Upscale",

View File

@ -7,7 +7,7 @@ import { CanvasEntityTitle } from 'features/controlLayers/components/common/Canv
import { LayerActionsMenu } from 'features/controlLayers/components/Layer/LayerActionsMenu';
import { layerDeleted, layerIsEnabledToggled } from 'features/controlLayers/store/canvasV2Slice';
import { selectLayerOrThrow } from 'features/controlLayers/store/layersReducers';
import { memo, useCallback } from 'react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { LayerOpacity } from './LayerOpacity';
@ -21,17 +21,21 @@ export const LayerHeader = memo(({ id, onToggleVisibility }: Props) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const isEnabled = useAppSelector((s) => selectLayerOrThrow(s.canvasV2, id).isEnabled);
const objectCount = useAppSelector((s) => selectLayerOrThrow(s.canvasV2, id).objects.length);
const onToggleIsEnabled = useCallback(() => {
dispatch(layerIsEnabledToggled({ id }));
}, [dispatch, id]);
const onDelete = useCallback(() => {
dispatch(layerDeleted({ id }));
}, [dispatch, id]);
const title = useMemo(() => {
return `${t('controlLayers.layer')} (${t('controlLayers.objects', { count: objectCount })})`;
}, [objectCount, t]);
return (
<CanvasEntityHeader onToggle={onToggleVisibility}>
<CanvasEntityEnabledToggle isEnabled={isEnabled} onToggle={onToggleIsEnabled} />
<CanvasEntityTitle title={t('controlLayers.layer')} />
<CanvasEntityTitle title={title} />
<Spacer />
<LayerOpacity id={id} />
<LayerActionsMenu id={id} />

View File

@ -10,7 +10,7 @@ type Props = PropsWithChildren<{
}>;
export const CanvasEntityContainer = memo(({ isSelected, onSelect, selectedBorderColor, children }: Props) => {
const bg = useMemo(() => {
const borderColor = useMemo(() => {
if (isSelected) {
return selectedBorderColor ?? 'base.400';
}
@ -25,19 +25,18 @@ export const CanvasEntityContainer = memo(({ isSelected, onSelect, selectedBorde
return (
<Flex
position="relative"
gap={2}
flexDir="column"
w="full"
bg="base.850"
onClick={_onSelect}
bg={bg}
px={2}
borderInlineStartWidth={5}
borderColor={borderColor}
opacity={isSelected ? 1 : 0.6}
borderRadius="base"
py="1px"
transitionProperty="all"
transitionDuration="0.2s"
>
<Flex flexDir="column" w="full" bg="base.850" borderRadius="base">
{children}
</Flex>
{children}
</Flex>
);
});