()
| 50 | let cache: { themeKey: string; colors: GraphThemeColors } | null = null; |
| 51 | |
| 52 | export 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 | } |
no test coverage detected