forked from EnterpriseDB/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree-node.js
More file actions
61 lines (55 loc) · 1.65 KB
/
tree-node.js
File metadata and controls
61 lines (55 loc) · 1.65 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from "react";
import { Link } from "./";
const Title = ({ node }) =>
node.navTitle ? node.navTitle : node.title ? node.title : "TITLE NEEDED";
const SubList = ({ children, collapsed }) => {
if (collapsed) {
return null;
} else {
return (
<ul className="ms-4 list-unstyled align-items-center">{children}</ul>
);
}
};
const KatacodaBadge = () => <span className="new-thing">Demo</span>;
const TreeNode = ({ node, path, hideIfEmpty }) => {
if (!node.path) {
if (hideIfEmpty) {
return null;
} else {
return (
<li className="mt-3 mb-2 fw-bold text-muted text-uppercase small">
<Title node={node} />
{/* {node.interactive && <KatacodaBadge />} */}
</li>
);
}
}
return (
<li className="ms-0 align-items-center list-parent" key={node.path}>
<div className="d-flex align-items-center">
<Link
to={node.path}
className={`d-inline-block py-1 align-middle lh-12 ${node.childCount && !node.rootedTo ? "section-title" : ""} ${node.rootedTo ? "transplanted-child" : ""} ${
path === node.path ? "active fw-bold text-dark" : ""
}`}
>
<Title node={node} />
{node.interactive && <KatacodaBadge />}
</Link>
</div>
{node.items.length > 0 && (
<SubList collapsed={!path.includes(node.path)}>
{node.items.map((subNode) => (
<TreeNode
node={subNode}
path={path}
key={subNode.path || subNode.navTitle || subNode.title}
/>
))}
</SubList>
)}
</li>
);
};
export default TreeNode;