From 92d6f451ecd70b03738debc38d3bca7e976265fa Mon Sep 17 00:00:00 2001 From: julius Date: Tue, 23 Dec 2025 11:27:58 +0100 Subject: [PATCH] clean up sociogram controls --- frontend/src/Network.tsx | 159 ++++++++++++++++++++++++--------------- 1 file changed, 99 insertions(+), 60 deletions(-) diff --git a/frontend/src/Network.tsx b/frontend/src/Network.tsx index 316abbb..3d04327 100644 --- a/frontend/src/Network.tsx +++ b/frontend/src/Network.tsx @@ -12,6 +12,7 @@ import { import { customTheme } from "./NetworkTheme"; import { useSession } from "./Session"; import { useNavigate } from "react-router"; +import { ChevronDown, ChevronUp, Settings2 } from "lucide-react"; interface NetworkData { nodes: GraphNode[]; @@ -43,7 +44,10 @@ export const GraphComponent = () => { const [loading, setLoading] = useState(true); const [error, setError] = useState(""); const [threed, setThreed] = useState(false); + const [showControls, setShowControls] = useState(true); const [likes, setLikes] = useState(2); + const [showLikes, setShowLikes] = useState(true); + const [showDislikes, setShowDislikes] = useState(false); const [popularity, setPopularity] = useState(false); const [mutuality, setMutuality] = useState(false); const { user, teams } = useSession(); @@ -96,17 +100,6 @@ export const GraphComponent = () => { setMutuality(!mutuality); } - function showLabel() { - switch (likes) { - case 0: - return "dislike"; - case 1: - return "both"; - case 2: - return "like"; - } - } - function findMatches(edges: GraphEdge[]) { const adjacencyList = edges.map( (edge) => edge.source + edge.target + edge.data.relation @@ -157,6 +150,10 @@ export const GraphComponent = () => { setData({ nodes: newNodes, edges: data.edges }); } + useEffect(() => { + setLikes(+!showLikes + +showDislikes); + }, [showLikes, showDislikes]); + useEffect(() => { if (mutuality) colorMatches(false); colorMatches(mutuality); @@ -183,7 +180,9 @@ export const GraphComponent = () => { let content: ReactNode; if (loading) { - content = ; +
+ +
; } else if (error) { content = {error}; } else { @@ -250,58 +249,98 @@ export const GraphComponent = () => { } return ( -
-
-
-
- {}} /> - -
- mutuality -
+
+
+
setShowControls(!showControls)} + > +

+ + + + + controls + +

+ +
+ {showControls && ( +
+
+
+
+ +
+
+ +
+
-
- 2D -
- {}} /> - -
- 3D -
+
+ +
-
-
- - - - - -
- - setLikes(Number(evt.target.value))} - /> - +
+ + +
+ +
+ +
- {showLabel()}
-
- -
-
- {}} /> - -
- - popularity* - -
+ )}
{popularity && (