Skip to content
Snippets Groups Projects
Commit 6dbbb9b8 authored by Matthias Konitzny's avatar Matthias Konitzny :fire:
Browse files

Improved neighbor menu design, by including type colors.

parent 34717c16
No related branches found
No related tags found
1 merge request!3Master into new editor
...@@ -8,10 +8,15 @@ import "./neighbors.css"; ...@@ -8,10 +8,15 @@ import "./neighbors.css";
interface NeighborsProps { interface NeighborsProps {
neighbors: NodeData[]; neighbors: NodeData[];
nodeColors?: Map<string, string>;
nodeClickedCallback?: (node: NodeData) => void; nodeClickedCallback?: (node: NodeData) => void;
} }
function Neighbors({ neighbors, nodeClickedCallback }: NeighborsProps) { function Neighbors({
neighbors,
nodeClickedCallback,
nodeColors = new Map<string, string>(),
}: NeighborsProps) {
const classes = [...new Set<string>(neighbors.map((node) => node.type))]; const classes = [...new Set<string>(neighbors.map((node) => node.type))];
classes.sort(); // Sort classes to get a constant order of the node type tabs classes.sort(); // Sort classes to get a constant order of the node type tabs
const categories = new Map<string, Array<NodeData>>(); const categories = new Map<string, Array<NodeData>>();
...@@ -39,6 +44,7 @@ function Neighbors({ neighbors, nodeClickedCallback }: NeighborsProps) { ...@@ -39,6 +44,7 @@ function Neighbors({ neighbors, nodeClickedCallback }: NeighborsProps) {
header={cls} header={cls}
key={cls} key={cls}
heightTransition={false} heightTransition={false}
color={nodeColors.get(cls)}
> >
<ul> <ul>
{categories.get(cls).map((node) => ( {categories.get(cls).map((node) => (
......
...@@ -8,6 +8,7 @@ import Neighbors from "./neighbors"; ...@@ -8,6 +8,7 @@ import Neighbors from "./neighbors";
interface InfoBarProps { interface InfoBarProps {
height: number; height: number;
node: NodeData; node: NodeData;
nodeColors?: Map<string, string>;
nodeClosedCallback?: () => void; nodeClosedCallback?: () => void;
nodeClickedCallback?: (node: NodeData) => void; nodeClickedCallback?: (node: NodeData) => void;
} }
...@@ -15,6 +16,7 @@ interface InfoBarProps { ...@@ -15,6 +16,7 @@ interface InfoBarProps {
function NodeInfoBar({ function NodeInfoBar({
height, height,
node, node,
nodeColors,
nodeClosedCallback, nodeClosedCallback,
nodeClickedCallback, nodeClickedCallback,
}: InfoBarProps) { }: InfoBarProps) {
...@@ -42,6 +44,7 @@ function NodeInfoBar({ ...@@ -42,6 +44,7 @@ function NodeInfoBar({
<Neighbors <Neighbors
neighbors={node.neighbors} neighbors={node.neighbors}
nodeColors={nodeColors}
nodeClickedCallback={nodeClickedCallback} nodeClickedCallback={nodeClickedCallback}
/> />
</div> </div>
......
...@@ -116,6 +116,7 @@ class Display extends React.Component< ...@@ -116,6 +116,7 @@ class Display extends React.Component<
{this.state.currentNode && ( {this.state.currentNode && (
<NodeInfoBar <NodeInfoBar
node={this.state.currentNode} node={this.state.currentNode}
nodeColors={this.state.graph.nodeColors}
height={this.state.nodeActive ? this.state.height : 0} height={this.state.nodeActive ? this.state.height : 0}
nodeClosedCallback={this.handleNodeClose} nodeClosedCallback={this.handleNodeClose}
nodeClickedCallback={this.handleNodeChangeRequest} nodeClickedCallback={this.handleNodeChangeRequest}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment