MCPcopy
hub / github.com/opentrace/opentrace / getGraphThemeColors

Function getGraphThemeColors

ui/src/components/colors/graphThemeColors.ts:52–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50let cache: { themeKey: string; colors: GraphThemeColors } | null = null;
51
52export function getGraphThemeColors(): GraphThemeColors {
53 if (typeof document === 'undefined') return DEFAULTS;
54
55 const root = document.documentElement;
56 const themeKey = `${root.dataset.theme ?? ''}_${root.dataset.mode ?? ''}`;
57 if (cache && cache.themeKey === themeKey) return cache.colors;
58
59 const style = getComputedStyle(root);
60 const bg = style.getPropertyValue('--graph-bg').trim() || DEFAULTS.bg;
61 const labelColor =
62 style.getPropertyValue('--graph-label-color').trim() || DEFAULTS.labelColor;
63 const labelShadow =
64 style.getPropertyValue('--graph-label-shadow').trim() ||
65 DEFAULTS.labelShadow;
66 const dimBgHex = style.getPropertyValue('--graph-dim-bg').trim() || '#1a1b2e';
67 const dimBg = parseHexRgb(dimBgHex);
68
69 const colors: GraphThemeColors = { bg, labelColor, labelShadow, dimBg };
70 cache = { themeKey, colors };
71 return colors;
72}

Callers 5

_initMethod · 0.90
setThemeColorsMethod · 0.90
createLabelMethod · 0.90
dimColorFunction · 0.90

Calls 1

parseHexRgbFunction · 0.85

Tested by

no test coverage detected