refactor(handle): use weaker selectors so its easier to overwrite
This commit is contained in:
@@ -345,12 +345,12 @@ The React Flow wrapper has the className `react-flow`. If you want to change the
|
|||||||
* `.react-flow__nodesselection` - Nodes selection
|
* `.react-flow__nodesselection` - Nodes selection
|
||||||
* `.react-flow__nodesselection-rect ` - Nodes selection rect
|
* `.react-flow__nodesselection-rect ` - Nodes selection rect
|
||||||
* `.react-flow__handle` - Handle component
|
* `.react-flow__handle` - Handle component
|
||||||
* `.bottom` is added when position = 'bottom'
|
* `.react-flow__handle-bottom` is added when position = 'bottom'
|
||||||
* `.top` is added when position = 'top'
|
* `.react-flow__handle-top` is added when position = 'top'
|
||||||
* `.left` is added when position = 'left'
|
* `.react-flow__handle-left` is added when position = 'left'
|
||||||
* `.right` is added when position = 'right'
|
* `.react-flow__handle-right` is added when position = 'right'
|
||||||
* `.connecting` is added when connection line is above a handle
|
* `.react-flow__handle-connecting` is added when connection line is above a handle
|
||||||
* `.valid` is added when connection line is above a handle and the connection is valid
|
* `.react-flow__handle-valid` is added when connection line is above a handle and the connection is valid
|
||||||
* `.react-flow__background` - Background component
|
* `.react-flow__background` - Background component
|
||||||
* `.react-flow__minimap` - Mini map component
|
* `.react-flow__minimap` - Mini map component
|
||||||
* `.react-flow__controls` - Controls component
|
* `.react-flow__controls` - Controls component
|
||||||
|
|||||||
@@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.validationflow .connecting {
|
.validationflow .react-flow__handle-connecting {
|
||||||
background: #ff6060;
|
background: #ff6060;
|
||||||
}
|
}
|
||||||
|
|
||||||
.validationflow .connecting.valid {
|
.validationflow .react-flow__handle-valid {
|
||||||
background: #55dd99;
|
background: #55dd99;
|
||||||
}
|
}
|
||||||
@@ -55,8 +55,8 @@ function onMouseDown(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
recentHoveredHandle.classList.remove('valid');
|
recentHoveredHandle.classList.remove('react-flow__handle-valid');
|
||||||
recentHoveredHandle.classList.remove('connecting');
|
recentHoveredHandle.classList.remove('react-flow__handle-connecting');
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if element below mouse is a handle and returns connection in form of an object { source: 123, target: 312 }
|
// checks if element below mouse is a handle and returns connection in form of an object { source: 123, target: 312 }
|
||||||
@@ -107,8 +107,8 @@ function onMouseDown(
|
|||||||
|
|
||||||
if (!isOwnHandle && elementBelow) {
|
if (!isOwnHandle && elementBelow) {
|
||||||
recentHoveredHandle = elementBelow;
|
recentHoveredHandle = elementBelow;
|
||||||
elementBelow.classList.add('connecting');
|
elementBelow.classList.add('react-flow__handle-connecting');
|
||||||
elementBelow.classList.toggle('valid', isValid);
|
elementBelow.classList.toggle('react-flow__handle-valid', isValid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ const BaseHandle = memo(
|
|||||||
...rest
|
...rest
|
||||||
}: BaseHandleProps) => {
|
}: BaseHandleProps) => {
|
||||||
const isTarget = type === 'target';
|
const isTarget = type === 'target';
|
||||||
const handleClasses = cx('react-flow__handle', 'nodrag', className, position, {
|
const handleClasses = cx('react-flow__handle', `react-flow__handle-${position}`, 'nodrag', className, {
|
||||||
source: !isTarget,
|
source: !isTarget,
|
||||||
target: isTarget,
|
target: isTarget,
|
||||||
});
|
});
|
||||||
|
|||||||
+42
-51
@@ -5,27 +5,21 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-flow__renderer {
|
.react-flow__renderer,
|
||||||
width: 100%;
|
.react-flow__zoompane,
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.react-flow__zoompane {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.react-flow__selectionpane {
|
.react-flow__selectionpane {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-flow__zoompane {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.react-flow__selectionpane {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,12 +86,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.react-flow__nodes {
|
.react-flow__nodes {
|
||||||
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
|
||||||
z-index: 3;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transform-origin: 0 0;
|
transform-origin: 0 0;
|
||||||
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-flow__node {
|
.react-flow__node {
|
||||||
@@ -106,19 +100,6 @@
|
|||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
transform-origin: 0 0;
|
transform-origin: 0 0;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
|
|
||||||
&.selected,
|
|
||||||
&.selected:hover {
|
|
||||||
box-shadow: 0 0 0 2px #555;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: 0 1px 5px 2px rgba(0, 0, 0, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.react-flow__handle {
|
|
||||||
cursor: crosshair;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-flow__node-default,
|
.react-flow__node-default,
|
||||||
@@ -130,6 +111,15 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #222;
|
color: #222;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
&.selected,
|
||||||
|
&.selected:hover {
|
||||||
|
box-shadow: 0 0 0 2px #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
box-shadow: 0 1px 5px 2px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.react-flow__node-default {
|
.react-flow__node-default {
|
||||||
@@ -168,29 +158,30 @@
|
|||||||
width: 10px;
|
width: 10px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
background: rgba(255, 255, 255, 0.4);
|
background: rgba(255, 255, 255, 0.4);
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
&.bottom {
|
.react-flow__handle-bottom {
|
||||||
top: auto;
|
top: auto;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
transform: translate(-50%, 0);
|
transform: translate(-50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.top {
|
.react-flow__handle-top {
|
||||||
left: 50%;
|
left: 50%;
|
||||||
top: 0;
|
top: 0;
|
||||||
transform: translate(-50%, 0);
|
transform: translate(-50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.left {
|
.react-flow__handle-left {
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 0;
|
left: 0;
|
||||||
transform: translate(0, -50%);
|
transform: translate(0, -50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.right {
|
.react-flow__handle-right {
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(0, -50%);
|
transform: translate(0, -50%);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user