MCPcopy
hub / github.com/opentrace/opentrace / useThemeKey

Function useThemeKey

ui/src/components/graph/useThemeKey.ts:29–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 * that read CSS variables (node/edge/label colors, graph background).
28 */
29export function useThemeKey(): string {
30 const [key, setKey] = useState(readThemeKey);
31
32 useEffect(() => {
33 const observer = new MutationObserver(() => {
34 setKey(readThemeKey());
35 });
36 observer.observe(document.documentElement, {
37 attributes: true,
38 attributeFilter: ['data-theme', 'data-mode'],
39 });
40 return () => observer.disconnect();
41 }, []);
42
43 return key;
44}

Callers 2

useGraphVisualsFunction · 0.90

Calls 3

readThemeKeyFunction · 0.85
observeMethod · 0.80
disconnectMethod · 0.80

Tested by

no test coverage detected