fix: hides label when no content to display

This commit is contained in:
Mark Mankarious
2023-08-20 12:05:14 +01:00
parent a061f57304
commit e2e2866a1c
3 changed files with 22 additions and 14 deletions

View File

@@ -71,7 +71,8 @@ export const LabelContainer = ({
left: -contentSize.width * 0.5,
top: -(contentSize.height + labelHeight + yOffset),
py: 1,
px: 1.5
px: 1.5,
overflow: 'hidden'
}}
>
{children}

View File

@@ -31,6 +31,12 @@ export const Node = ({ node, icon, order }: Props) => {
});
}, [node.position, getTilePosition]);
const label = useMemo(() => {
if (node.label === undefined || node.label === '<p><br></p>') return null;
return node.label;
}, [node.label]);
return (
<Box
sx={{
@@ -47,21 +53,23 @@ export const Node = ({ node, icon, order }: Props) => {
top: position.y
}}
>
<Box
sx={{
position: 'absolute'
}}
>
{label && (
<Box
sx={{
position: 'absolute',
top: -projectedTileSize.height
position: 'absolute'
}}
/>
<LabelContainer labelHeight={node.labelHeight} connectorDotSize={5}>
{node.label && <MarkdownLabel label={node.label} />}
</LabelContainer>
</Box>
>
<Box
sx={{
position: 'absolute',
top: -projectedTileSize.height
}}
/>
<LabelContainer labelHeight={node.labelHeight} connectorDotSize={5}>
<MarkdownLabel label={label} />
</LabelContainer>
</Box>
)}
{icon && (
<Box
sx={{

View File

@@ -29,7 +29,6 @@ export const PlaceElement: ModeActions = {
scene.actions.createNode({
id: generateId(),
iconId: uiState.mode.icon.id,
label: 'New Node',
position: uiState.mouse.position.tile
});