Skip to content

Commit b80f9bf

Browse files
committed
Implement theme-aware styling in NetworkMap component
1 parent 7cf294d commit b80f9bf

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

data/html/build-info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "version": "dev3.3.4", "commit": "3f04ef3", "builtAt": "2026-02-13T00:42:46Z" }
1+
{ "version": "dev3.3.5", "commit": "7cf294d", "builtAt": "2026-02-19T00:44:58Z" }

data/react-ui/src/components/NetworkMap.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ export function NetworkMap() {
3535
const [externalNode, setExternalNode] = useState(null);
3636
const [selectedSubnet, setSelectedSubnet] = useState(null);
3737
const [layoutStyle, setLayoutStyle] = useState("default");
38+
const [isDark, setIsDark] = useState(() => document.documentElement.classList.contains("dark"));
39+
40+
// Observe <html> class changes so canvas re-renders when theme toggles
41+
useEffect(() => {
42+
const observer = new MutationObserver(() => {
43+
setIsDark(document.documentElement.classList.contains("dark"));
44+
});
45+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
46+
return () => observer.disconnect();
47+
}, []);
3848

3949
/**
4050
* Initial data load (hosts + external)
@@ -80,6 +90,8 @@ export function NetworkMap() {
8090
useEffect(() => {
8191
if (!rawData.nonDockerHosts.length && !rawData.dockerHosts.length) return;
8292

93+
const labelColor = isDark ? "#fff" : "#000";
94+
8395
const nodes = new DataSet();
8496
const edges = new DataSet();
8597
const infoMap = {};
@@ -99,7 +111,7 @@ export function NetworkMap() {
99111
label: networkName ? `${networkName}` : `${subnet}.x`,
100112
shape: "box",
101113
color: getHubColor(subnet),
102-
font: { size: 14, color: "#000" },
114+
font: { size: 14, color: labelColor },
103115
level: 1, // Below Internet
104116
});
105117
}
@@ -119,7 +131,7 @@ export function NetworkMap() {
119131
label: networkName,
120132
shape: "box",
121133
color: "#10b981",
122-
font: { size: 12, color: "#000" },
134+
font: { size: 12, color: labelColor },
123135
level: 3,
124136
});
125137
}
@@ -261,7 +273,7 @@ export function NetworkMap() {
261273
label: `Internet\n(${externalNode.ip})`,
262274
shape: "box",
263275
color: "#f43f5e",
264-
font: { size: 12, color: "#000" },
276+
font: { size: 12, color: labelColor },
265277
level: 0,
266278
});
267279
}
@@ -340,7 +352,7 @@ export function NetworkMap() {
340352
springConstant: 0.05,
341353
},
342354
},
343-
nodes: { shape: "dot", size: 16, font: { size: 12 } },
355+
nodes: { shape: "dot", size: 16, font: { size: 12, color: labelColor } },
344356
edges: {
345357
arrows: "to",
346358
smooth: true,
@@ -384,7 +396,7 @@ export function NetworkMap() {
384396
});
385397
networkRef.current = net;
386398
}
387-
}, [rawData, filters, layoutStyle, externalNode]);
399+
}, [rawData, filters, layoutStyle, externalNode, isDark]);
388400

389401
return (
390402
<div className="relative w-full h-full bg-white dark:bg-gray-800 border dark:border-gray-700 rounded p-4 flex flex-col">

0 commit comments

Comments
 (0)