From b75b16b19251b82326a3cee3cabc1e6dad7b11cd Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Tue, 23 Aug 2022 11:20:49 -0400 Subject: [PATCH] Simplfies graph style props --- src/webviews/apps/plus/graph/GraphWrapper.tsx | 35 ++++++++++----------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index c0a6bce..46d5f3f 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -25,34 +25,25 @@ export interface GraphWrapperProps extends State { onSelectionChange?: (selection: string[]) => void; } -// Copied from original pushed code of Miggy E. -// TODO: review that code as I'm not sure if it is the correct way to do that in Gitlens side. -// I suppose we need to use the GitLens themes here instead. -const getCssVariables = (mixedColumnColors: CssVariables | undefined): CssVariables => { - const body = document.body; - const computedStyle = window.getComputedStyle(body); - - return { - '--app__bg0': computedStyle.getPropertyValue('--color-background'), - '--panel__bg0': computedStyle.getPropertyValue('--graph-panel-bg'), - '--text-selected': computedStyle.getPropertyValue('--color-foreground'), - '--text-normal': computedStyle.getPropertyValue('--color-foreground--85'), - '--text-secondary': computedStyle.getPropertyValue('--color-foreground--65'), - '--text-disabled': computedStyle.getPropertyValue('--color-foreground--50'), - '--text-accent': computedStyle.getPropertyValue('--color-link-foreground'), - '--text-inverse': computedStyle.getPropertyValue('--vscode-input-background'), - '--text-bright': computedStyle.getPropertyValue('--vscode-input-background'), - ...mixedColumnColors, - }; -}; - const getStyleProps = ( mixedColumnColors: CssVariables | undefined, ): { cssVariables: CssVariables; themeOpacityFactor: number } => { const body = document.body; const computedStyle = window.getComputedStyle(body); + return { - cssVariables: getCssVariables(mixedColumnColors), + cssVariables: { + '--app__bg0': computedStyle.getPropertyValue('--color-background'), + '--panel__bg0': computedStyle.getPropertyValue('--graph-panel-bg'), + '--text-selected': computedStyle.getPropertyValue('--color-foreground'), + '--text-normal': computedStyle.getPropertyValue('--color-foreground--85'), + '--text-secondary': computedStyle.getPropertyValue('--color-foreground--65'), + '--text-disabled': computedStyle.getPropertyValue('--color-foreground--50'), + '--text-accent': computedStyle.getPropertyValue('--color-link-foreground'), + '--text-inverse': computedStyle.getPropertyValue('--vscode-input-background'), + '--text-bright': computedStyle.getPropertyValue('--vscode-input-background'), + ...mixedColumnColors, + }, themeOpacityFactor: parseInt(computedStyle.getPropertyValue('--graph-theme-opacity-factor')) || 1, }; };