Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";
import { NodeData } from "../../graph";
import FancyScrollbar from "../fancyscrollbar";
import Collapsible from "../collapsible";
interface NeighborsProps {
neighbors: NodeData[];
nodeClickedCallback?: (node: NodeData) => void;
}
function Neighbors({ neighbors, nodeClickedCallback }: NeighborsProps) {
const classes = [...new Set<string>(neighbors.map((node) => node.type))];
const categories = new Map<string, Array<NodeData>>();
for (const cls of classes) {
categories.set(cls, []);
}
for (const neighbor of neighbors) {
categories.get(neighbor.type).push(neighbor);
}
return (
<div className={"neighbor-container"}>
<FancyScrollbar>
<Collapsible header={"Verwandte Inhalte"}>
{classes.map((cls) => (
<Collapsible header={cls} key={cls}>
<ul>
{categories.get(cls).map((node) => (
<li key={node.name}>{node.name}</li>
))}
</ul>
</Collapsible>
))}
</Collapsible>
</FancyScrollbar>
</div>
);
}
export default Neighbors;