Skip to content

Commit

Permalink
update group style when it's un selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Salam-Dalloul committed Aug 9, 2024
1 parent 2d97eff commit be16fcf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ const createEdgeLongLabel = (workspace: Workspace, synapses: Record<string, numb
};

export const createNode = (nodeId: string, selected: boolean, attributes: string[], position?: Position, isGroupNode?: boolean): ElementDefinition => {
let classes = "";
if (isGroupNode) classes += "groupNode ";
if (selected) classes += "selected";
const node: ElementDefinition = {
group: "nodes",
data: { id: nodeId, label: nodeId, ...attributes.reduce((acc, attr) => ({ ...acc, [attr]: true }), {}) },
classes: isGroupNode ? "groupNode" : selected ? "selected" : "",
classes: classes,
};
if (position) {
node.position = { x: position.x, y: position.y };
Expand Down
19 changes: 14 additions & 5 deletions applications/visualizer/frontend/src/theme/twoDStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SELECTED_NODE_STYLE = {

const GROUP_NODE_STYLE = {
shape: "roundrectangle",
"background-color": "#d0d0d0",
"background-color": "#ECECE9",
"pie-size": "100%",
"font-size": 3,
width: 20,
Expand All @@ -35,6 +35,11 @@ const GROUP_NODE_STYLE = {
"border-color": "black",
"font-weight": "semibold",
};
const UNSELECTED_GROUP_NODE_STYLE = {
...GROUP_NODE_STYLE,
"background-color": "#D3D3CF",
"border-width": 0,
};

const EDGE_STYLE = {
"line-color": "#63625F",
Expand All @@ -46,7 +51,7 @@ const EDGE_STYLE = {

const CHEMICAL_STYLE = { "line-color": "#63625F", width: 0.5 };
const ELECTRICAL_STYLE = {
"line-color": "#63625F",
"line-color": "red",
width: 0.5,
"curve-style": "segments",
"target-arrow-color": "#666666",
Expand Down Expand Up @@ -115,12 +120,16 @@ export const GRAPH_STYLES = [
style: NODE_STYLE,
},
{
selector: "node.selected",
style: SELECTED_NODE_STYLE,
selector: "node.groupNode.selected",
style: GROUP_NODE_STYLE,
},
{
selector: "node.groupNode",
style: GROUP_NODE_STYLE,
style: UNSELECTED_GROUP_NODE_STYLE,
},
{
selector: "node.selected",
style: SELECTED_NODE_STYLE,
},
{
selector: "edge",
Expand Down

0 comments on commit be16fcf

Please sign in to comment.