Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fill property to edge and set the arrow and the line color by it #275

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading