can drop component on root

This commit is contained in:
Bowen Tan 2021-10-18 15:46:48 +08:00
parent e7e479f32d
commit be279c0079
2 changed files with 20 additions and 12 deletions

View File

@ -6,7 +6,7 @@ type Props = {
title: string;
isSelected: boolean;
onClick: () => void;
onClickRemove: () => void;
onClickRemove?: () => void;
noChevron: boolean;
isExpanded?: boolean;
onToggleExpanded?: () => void;
@ -60,13 +60,15 @@ export const ComponentItemView: React.FC<Props> = props => {
<Text color={isSelected ? 'red.500' : 'black'} onClick={onClick} cursor="pointer">
{title}
</Text>
<IconButton
variant="ghost"
size="smx"
aria-label="remove"
icon={<DeleteIcon />}
onClick={onClickRemove}
/>
{onClickRemove ? (
<IconButton
variant="ghost"
size="smx"
aria-label="remove"
icon={<DeleteIcon />}
onClick={onClickRemove}
/>
) : null}
</HStack>
</Box>
);

View File

@ -7,7 +7,7 @@ import {
} from '../../operations/Operations';
import { ComponentItemView } from './ComponentItemView';
import { ComponentTree } from './ComponentTree';
import { Text, VStack } from '@chakra-ui/react';
import { Box, Text, VStack } from '@chakra-ui/react';
export type ChildrenMap = Map<string, SlotsMap>;
type SlotsMap = Map<string, ApplicationComponent[]>;
@ -93,8 +93,14 @@ function RootItem() {
eventBus.send('operation', new CreateComponentOperation(creatingComponent));
};
return (
<Text onDrop={onDrop} width="full">
Root
</Text>
<Box onDrop={onDrop} width="full">
<ComponentItemView
title="Root"
isSelected={false}
onClick={() => undefined}
isDroppable={true}
noChevron={true}
/>
</Box>
);
}