Skip to content

Commit

Permalink
Merge pull request #211 from MetaCell/feature/SDSV-16
Browse files Browse the repository at this point in the history
#16 apply different style to previously selected nodes
  • Loading branch information
jrmartin authored Feb 16, 2024
2 parents ba86663 + 960e823 commit 9371c80
Showing 1 changed file with 28 additions and 1 deletion.
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 @@ -253,6 +255,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 @@ -548,6 +551,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 @@ -565,6 +587,11 @@ const GraphViewer = (props) => {
},
[hoverNode]
);
useEffect(() => {
if (selectedNode) {
setPreviouslySelectedNodes(prev => new Set([...prev, selectedNode.id]));
}
}, [selectedNode]);

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

0 comments on commit 9371c80

Please sign in to comment.