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

Partially implemented neighbor menu

parent a72ed063
Branches
Tags
1 merge request!3Master into new editor
Pipeline #56794 passed
...@@ -4,8 +4,12 @@ ...@@ -4,8 +4,12 @@
border-bottom: 1px solid #dee2e6 !important; border-bottom: 1px solid #dee2e6 !important;
} }
.collapsible-content-padding > ul {
margin: 0 0 0 2em;
}
.collapsible-content-padding { .collapsible-content-padding {
padding: 20px 20px 20px 30px; padding: 10px 0 10px 10px;
} }
.collapsible-rotate-center { .collapsible-rotate-center {
...@@ -59,18 +63,17 @@ ...@@ -59,18 +63,17 @@
content: "\276E"; content: "\276E";
margin-left: auto; margin-left: auto;
transition: all 0.2s linear; transition: all 0.2s linear;
transform: rotate(90deg); transform: rotate(-90deg);
} }
.collapsible-button:not(.collapsed)::after { .collapsible-button:not(.collapsed)::after {
transform: rotate(-90deg); transform: rotate(90deg);
} }
.collapsible-card { .collapsible-card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
transition: 0.3s; transition: 0.3s;
} }
.collapsible-card:hover { .collapsible-card:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2); box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
} }
...@@ -5,10 +5,16 @@ interface CollapsibleProps { ...@@ -5,10 +5,16 @@ interface CollapsibleProps {
open?: boolean; open?: boolean;
header: string | React.ReactNode; header: string | React.ReactNode;
children?: React.ReactNode | React.ReactNode[]; children?: React.ReactNode | React.ReactNode[];
color?: string;
} }
// Implementation details at nhttps://medium.com/edonec/build-a-react-collapsible-component-from-scratch-using-react-hooks-typescript-73dfd02c9208 // Implementation details at https://medium.com/edonec/build-a-react-collapsible-component-from-scratch-using-react-hooks-typescript-73dfd02c9208
function Collapsible({ open, header, children }: CollapsibleProps) { function Collapsible({
open,
header,
children,
color = "gray",
}: CollapsibleProps) {
const [isOpen, setIsOpen] = useState(open); const [isOpen, setIsOpen] = useState(open);
const [height, setHeight] = useState<number | undefined>( const [height, setHeight] = useState<number | undefined>(
open ? undefined : 0 open ? undefined : 0
...@@ -36,6 +42,8 @@ function Collapsible({ open, header, children }: CollapsibleProps) { ...@@ -36,6 +42,8 @@ function Collapsible({ open, header, children }: CollapsibleProps) {
else setHeight(0); else setHeight(0);
}, [isOpen]); }, [isOpen]);
const borderBottom = "1px solid " + color;
return ( return (
<> <>
<div className={"collapsible-card"}> <div className={"collapsible-card"}>
...@@ -46,6 +54,7 @@ function Collapsible({ open, header, children }: CollapsibleProps) { ...@@ -46,6 +54,7 @@ function Collapsible({ open, header, children }: CollapsibleProps) {
isOpen ? "" : "collapsed" isOpen ? "" : "collapsed"
}`} }`}
onClick={toggleOpen} onClick={toggleOpen}
style={{ borderBottom }}
> >
{header} {header}
</button> </button>
......
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;
...@@ -3,6 +3,7 @@ import { NodeData } from "../../graph"; ...@@ -3,6 +3,7 @@ import { NodeData } from "../../graph";
import TitleArea from "./titlearea"; import TitleArea from "./titlearea";
import FancyScrollbar from "../fancyscrollbar"; import FancyScrollbar from "../fancyscrollbar";
import MediaArea from "./mediaarea"; import MediaArea from "./mediaarea";
import Neighbors from "./neighbors";
interface InfoBarProps { interface InfoBarProps {
height: number; height: number;
...@@ -11,22 +12,6 @@ interface InfoBarProps { ...@@ -11,22 +12,6 @@ interface InfoBarProps {
} }
function NodeInfoBar({ height, node, nodeClosedCallback }: InfoBarProps) { function NodeInfoBar({ height, node, nodeClosedCallback }: InfoBarProps) {
// const [isOpen, setIsOpen] = useState(open);
// const [height, setHeight] = useState<number | undefined>(
// open ? undefined : 0
// );
//
// const toggleOpen = () => {
// setIsOpen((prev) => !prev);
// };
//
// const ref = useRef<HTMLDivElement>(null);
//
// useEffect(() => {
// if (isOpen) setHeight(targetHeight);
// else setHeight(0);
// }, [isOpen]);
return ( return (
<div id={"infoOverlay"} className={"detail-view"} style={{ height }}> <div id={"infoOverlay"} className={"detail-view"} style={{ height }}>
<div <div
...@@ -48,6 +33,8 @@ function NodeInfoBar({ height, node, nodeClosedCallback }: InfoBarProps) { ...@@ -48,6 +33,8 @@ function NodeInfoBar({ height, node, nodeClosedCallback }: InfoBarProps) {
/> />
</FancyScrollbar> </FancyScrollbar>
</div> </div>
<Neighbors neighbors={node.neighbors} />
</div> </div>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment