1
- import { Handle , NodeProps , Position , useViewport } from '@xyflow/react' ;
1
+ import { Handle , NodeProps , Position , useStore , useViewport } from '@xyflow/react' ;
2
2
import styled from '@emotion/styled' ;
3
3
import { fontFamilies , spacing } from '@leafygreen-ui/tokens' ;
4
4
import { useTheme } from '@emotion/react' ;
@@ -10,7 +10,6 @@ import {
10
10
DEFAULT_FIELD_HEIGHT ,
11
11
DEFAULT_FIELD_PADDING ,
12
12
DEFAULT_NODE_HEADER_HEIGHT ,
13
- DEFAULT_NODE_WIDTH ,
14
13
ZOOM_THRESHOLD ,
15
14
} from '@/utilities/constants' ;
16
15
import { InternalNode } from '@/types/internal' ;
@@ -28,6 +27,8 @@ const NodeZoomedOut = styled.div<{ height: number }>`
28
27
const NodeZoomedOutInner = styled . div `
29
28
font-size: 20px;
30
29
text-align: center;
30
+ padding-left: ${ spacing [ 300 ] } px;
31
+ padding-right: ${ spacing [ 300 ] } px;
31
32
${ ellipsisTruncation }
32
33
` ;
33
34
@@ -36,7 +37,6 @@ const NodeWrapper = styled.div<{ accent: string; color: string }>`
36
37
font-family: ${ fontFamilies . code } ;
37
38
background: ${ props => props . theme . node . background } ;
38
39
color: ${ props => props . color } ;
39
- width: ${ DEFAULT_NODE_WIDTH } px;
40
40
overflow: hidden;
41
41
border-left: 1px solid ${ props => props . accent } ;
42
42
border: 1px solid ${ props => props . theme . node . border } ;
@@ -78,18 +78,16 @@ const NodeHeaderTitle = styled.div`
78
78
${ ellipsisTruncation }
79
79
` ;
80
80
81
- const NodeHandle = styled ( Handle ) `
81
+ const NodeHandle = styled ( Handle ) < { zIndex ?: number } > `
82
82
width: 100%;
83
83
height: 100%;
84
- background: blue;
85
84
position: absolute;
86
85
top: 0;
87
86
left: 0;
88
87
border-radius: 0;
89
88
transform: none;
90
- border: none;
91
89
opacity: 0;
92
- z-index: 1 ;
90
+ z-index: ${ props => props . zIndex } ;
93
91
` ;
94
92
95
93
export const Node = ( {
@@ -130,6 +128,8 @@ export const Node = ({
130
128
131
129
const isContextualZoom = zoom < ZOOM_THRESHOLD ;
132
130
131
+ const fromHandle = useStore ( state => state . connection . fromHandle ) ;
132
+
133
133
const onMouseEnter = ( ) => {
134
134
setHovering ( true ) ;
135
135
} ;
@@ -141,8 +141,20 @@ export const Node = ({
141
141
return (
142
142
< div onMouseEnter = { onMouseEnter } onMouseLeave = { onMouseLeave } >
143
143
< NodeBorder variant = { selected ? 'selected' : borderVariant } >
144
- < NodeHandle id = "source" isConnectable = { isConnectable } position = { Position . Right } type = "source" />
145
- < NodeHandle id = "source" isConnectable = { isConnectable } position = { Position . Left } type = "target" />
144
+ < NodeHandle
145
+ id = "source"
146
+ isConnectable = { isConnectable }
147
+ position = { Position . Right }
148
+ type = "source"
149
+ zIndex = { fromHandle ? 0 : 1 }
150
+ />
151
+ < NodeHandle
152
+ id = "target"
153
+ isConnectable = { isConnectable }
154
+ position = { Position . Left }
155
+ type = "target"
156
+ zIndex = { fromHandle ? 1 : 0 }
157
+ />
146
158
< NodeWrapper accent = { getAccent ( ) } color = { getNodeColor ( ) } >
147
159
< NodeHeader background = { getHeaderBackground ( ) } >
148
160
{ ! isContextualZoom && (
0 commit comments