Skip to content

Commit

Permalink
Merge pull request #275 from Anchel123/add-fill-property-to-edge
Browse files Browse the repository at this point in the history
add fill property to edge and set the arrow and the line color by it
  • Loading branch information
amcdnl authored Sep 3, 2024
2 parents bd23e1a + 119822e commit dcdc83c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/symbols/Edge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const Edge: FC<EdgeProps> = ({
// Edge data
const edges = useStore(state => state.edges);
const edge = edges.find(e => e.id === id);
const { target, source, label, labelVisible = false, size = 1 } = edge;
const { target, source, label, labelVisible = false, size = 1, fill } = edge;
const from = useStore(store => store.nodes.find(node => node.id === source));
const to = useStore(store => store.nodes.find(node => node.id === target));

Expand Down Expand Up @@ -278,7 +278,7 @@ export const Edge: FC<EdgeProps> = ({
color={
isSelected || active || isActive
? theme.arrow.activeFill
: theme.arrow.fill
: fill || theme.arrow.fill
}
length={arrowLength}
opacity={selectionOpacity}
Expand All @@ -295,6 +295,7 @@ export const Edge: FC<EdgeProps> = ({
/>
),
[
fill,
active,
animated,
arrowLength,
Expand Down Expand Up @@ -385,7 +386,7 @@ export const Edge: FC<EdgeProps> = ({
color={
isSelected || active || isActive
? theme.edge.activeFill
: theme.edge.fill
: fill || theme.edge.fill
}
curve={curve}
curved={curved}
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export interface GraphEdge extends GraphElementBaseAttributes {
*/
source: string;

/**
* Fill color for the edge.
*/
fill?: string;

/**
* Target ID of the node.
*/
Expand Down

0 comments on commit dcdc83c

Please sign in to comment.