Feat: Make edges change color when hover it
This commit is contained in:
parent
e195cb5eec
commit
c33eec9c88
2 changed files with 16 additions and 1 deletions
|
|
@ -316,6 +316,19 @@ export default function Page({
|
||||||
setFilterEdge([]);
|
setFilterEdge([]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
function onMouseAction(edge: Edge, color: string): void {
|
||||||
|
const edges = useFlowStore.getState().edges
|
||||||
|
const newEdges = _.cloneDeep(edges)
|
||||||
|
const style = { stroke: color, transition: "stroke 0.25s" };
|
||||||
|
const updatedEdges = newEdges.map((obj) => {
|
||||||
|
if (obj.id === edge.id) {
|
||||||
|
return { ...obj, style }
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
setEdges(updatedEdges);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full overflow-hidden">
|
<div className="flex h-full overflow-hidden">
|
||||||
{!view && <ExtraSidebar />}
|
{!view && <ExtraSidebar />}
|
||||||
|
|
@ -358,6 +371,8 @@ export default function Page({
|
||||||
panOnDrag={!view}
|
panOnDrag={!view}
|
||||||
proOptions={{ hideAttribution: true }}
|
proOptions={{ hideAttribution: true }}
|
||||||
onPaneClick={onPaneClick}
|
onPaneClick={onPaneClick}
|
||||||
|
onEdgeMouseEnter={(event, edge) => onMouseAction(edge, "#473A5C")}
|
||||||
|
onEdgeMouseLeave={(event, edge) => onMouseAction(edge, "#555")}
|
||||||
>
|
>
|
||||||
<Background className="" />
|
<Background className="" />
|
||||||
{!view && (
|
{!view && (
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
},
|
},
|
||||||
setEdges: (change) => {
|
setEdges: (change) => {
|
||||||
let newChange = typeof change === "function" ? change(get().edges) : change;
|
let newChange = typeof change === "function" ? change(get().edges) : change;
|
||||||
|
console.log(newChange)
|
||||||
set({
|
set({
|
||||||
edges: newChange,
|
edges: newChange,
|
||||||
flowState: undefined,
|
flowState: undefined,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue