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

#16 apply different style to previously selected nodes #211

Merged
merged 1 commit into from
Feb 16, 2024
Merged
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
29 changes: 28 additions & 1 deletion src/components/GraphViewer/GraphViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const GRAPH_COLORS = {
textHoverRect: '#3779E1',
textHover: 'white',
textColor: '#2E3A59',
collapsedFolder : 'red'
collapsedFolder : 'red',
nodeSeen: '#E1E3E8',
textBGSeen: '#6E4795'
};
const TOP_DOWN = {
label : "Tree View",
Expand Down Expand Up @@ -211,6 +213,7 @@ const GraphViewer = (props) => {
const nodeSelected = useSelector(state => state.sdsState.instance_selected.graph_node);
const groupSelected = useSelector(state => state.sdsState.group_selected.graph_node);
const [collapsed, setCollapsed] = React.useState(true);
const [previouslySelectedNodes, setPreviouslySelectedNodes] = useState(new Set());

const handleLayoutClick = (event) => {
setLayoutAnchorEl(event.currentTarget);
Expand Down Expand Up @@ -504,6 +507,25 @@ const GraphViewer = (props) => {
);
// reset canvas fill color
ctx.fillStyle = GRAPH_COLORS.textHover;
} else if (previouslySelectedNodes.has(node.id)) {
// Apply different style previously selected nodes
roundRect(
ctx,
...hoverRectPosition,
...hoverRectDimensions,
hoverRectBorderRadius,
GRAPH_COLORS.nodeSeen,
0.3
);
roundRect(
ctx,
...textHoverPosition,
hoverRectDimensions[0],
hoverRectDimensions[1] / 4,
hoverRectBorderRadius,
GRAPH_COLORS.textBGSeen
);
ctx.fillStyle = GRAPH_COLORS.textHover;
} else {
ctx.fillStyle = GRAPH_COLORS.textColor;
}
Expand All @@ -521,6 +543,11 @@ const GraphViewer = (props) => {
},
[hoverNode]
);
useEffect(() => {
if (selectedNode) {
setPreviouslySelectedNodes(prev => new Set([...prev, selectedNode.id]));
}
}, [selectedNode]);

return (
<div className={'graph-view'}>
Expand Down
Loading