@ -52,7 +52,7 @@ import {
UpdateRefsVisibilityCommandType ,
UpdateSelectionCommandType ,
} from '../../../../plus/webviews/graph/protocol' ;
import { Color , darken , lighten , mix , opacity } from '../../../../system/color' ;
import { Color , darken , getCssVariable , lighten, mix , opacity } from '../../../../system/color' ;
import { debounce } from '../../../../system/function' ;
import type { IpcMessage , IpcNotificationType } from '../../../protocol' ;
import { onIpc } from '../../../protocol' ;
@ -346,30 +346,30 @@ export class GraphApp extends App {
}
protected override onThemeUpdated ( e : ThemeChangeEvent ) {
const body Style = document . body . style ;
body Style. setProperty ( '--graph-theme-opacity-factor' , e . isLightTheme ? '0.5' : '1' ) ;
const root Style = document . documentElement . style ;
root Style. setProperty ( '--graph-theme-opacity-factor' , e . isLightTheme ? '0.5' : '1' ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-actionbar-background' ,
e . isLightTheme ? darken ( e . colors . background , 5 ) : lighten ( e . colors . background , 5 ) ,
) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-background' ,
e . isLightTheme ? darken ( e . colors . background , 5 ) : lighten ( e . colors . background , 5 ) ,
) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-background2' ,
e . isLightTheme ? darken ( e . colors . background , 10 ) : lighten ( e . colors . background , 10 ) ,
) ;
const color = e . computedStyle . getPropertyValu e( '--color-graph-text-selected-row' ) . trim ( ) ;
body Style. setProperty ( '--color-graph-text-dimmed-selected' , opacity ( color , 50 ) ) ;
body Style. setProperty ( '--color-graph-text-dimmed' , opacity ( e . colors . foreground , 20 ) ) ;
const color = getCssVariabl e( '--color-graph-text-selected-row' , e . computedStyle ) ;
root Style. setProperty ( '--color-graph-text-dimmed-selected' , opacity ( color , 50 ) ) ;
root Style. setProperty ( '--color-graph-text-dimmed' , opacity ( e . colors . foreground , 20 ) ) ;
body Style. setProperty ( '--color-graph-text-normal' , opacity ( e . colors . foreground , 85 ) ) ;
body Style. setProperty ( '--color-graph-text-secondary' , opacity ( e . colors . foreground , 65 ) ) ;
body Style. setProperty ( '--color-graph-text-disabled' , opacity ( e . colors . foreground , 50 ) ) ;
root Style. setProperty ( '--color-graph-text-normal' , opacity ( e . colors . foreground , 85 ) ) ;
root Style. setProperty ( '--color-graph-text-secondary' , opacity ( e . colors . foreground , 65 ) ) ;
root Style. setProperty ( '--color-graph-text-disabled' , opacity ( e . colors . foreground , 50 ) ) ;
const backgroundColor = Color . from ( e . colors . background ) ;
const foregroundColor = Color . from ( e . colors . foreground ) ;
@ -394,38 +394,38 @@ export class GraphApp extends App {
// minimap and scroll markers
let c = Color . fromCssVariable ( '--vscode-scrollbarSlider-background' , e . computedStyle ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-minimap-visibleAreaBackground' ,
c . luminance ( themeLuminance ( e . isLightTheme ? 0.6 : 0.1 ) ) . toString ( ) ,
) ;
if ( ! e . isLightTheme ) {
c = Color . fromCssVariable ( '--color-graph-scroll-marker-local-branches' , e . computedStyle ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-minimap-tip-branchBackground' ,
c . luminance ( themeLuminance ( 0.55 ) ) . toString ( ) ,
) ;
c = Color . fromCssVariable ( '--color-graph-scroll-marker-local-branches' , e . computedStyle ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-minimap-tip-branchBorder' ,
c . luminance ( themeLuminance ( 0.55 ) ) . toString ( ) ,
) ;
c = Color . fromCssVariable ( '--vscode-editor-foreground' , e . computedStyle ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-minimap-tip-branchForeground' ,
c . isLighter ( ) ? c . luminance ( 0.01 ) . toString ( ) : c . luminance ( 0.99 ) . toString ( ) ,
) ;
c = Color . fromCssVariable ( '--vscode-editor-foreground' , e . computedStyle ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-minimap-tip-headForeground' ,
c . isLighter ( ) ? c . luminance ( 0.01 ) . toString ( ) : c . luminance ( 0.99 ) . toString ( ) ,
) ;
c = Color . fromCssVariable ( '--vscode-editor-foreground' , e . computedStyle ) ;
body Style. setProperty (
root Style. setProperty (
'--color-graph-minimap-tip-upstreamForeground' ,
c . isLighter ( ) ? c . luminance ( 0.01 ) . toString ( ) : c . luminance ( 0.99 ) . toString ( ) ,
) ;
@ -436,36 +436,36 @@ export class GraphApp extends App {
const branchStatusPillLuminance = themeLuminance ( e . isLightTheme ? 0.92 : 0.02 ) ;
// branch status ahead
c = Color . fromCssVariable ( '--branch-status-ahead-foreground' , e . computedStyle ) ;
body Style. setProperty ( '--branch-status-ahead-background' , c . luminance ( branchStatusLuminance ) . toString ( ) ) ;
body Style. setProperty (
root Style. setProperty ( '--branch-status-ahead-background' , c . luminance ( branchStatusLuminance ) . toString ( ) ) ;
root Style. setProperty (
'--branch-status-ahead-hover-background' ,
c . luminance ( branchStatusHoverLuminance ) . toString ( ) ,
) ;
body Style. setProperty (
root Style. setProperty (
'--branch-status-ahead-pill-background' ,
c . luminance ( branchStatusPillLuminance ) . toString ( ) ,
) ;
// branch status behind
c = Color . fromCssVariable ( '--branch-status-behind-foreground' , e . computedStyle ) ;
body Style. setProperty ( '--branch-status-behind-background' , c . luminance ( branchStatusLuminance ) . toString ( ) ) ;
body Style. setProperty (
root Style. setProperty ( '--branch-status-behind-background' , c . luminance ( branchStatusLuminance ) . toString ( ) ) ;
root Style. setProperty (
'--branch-status-behind-hover-background' ,
c . luminance ( branchStatusHoverLuminance ) . toString ( ) ,
) ;
body Style. setProperty (
root Style. setProperty (
'--branch-status-behind-pill-background' ,
c . luminance ( branchStatusPillLuminance ) . toString ( ) ,
) ;
// branch status both
c = Color . fromCssVariable ( '--branch-status-both-foreground' , e . computedStyle ) ;
body Style. setProperty ( '--branch-status-both-background' , c . luminance ( branchStatusLuminance ) . toString ( ) ) ;
body Style. setProperty (
root Style. setProperty ( '--branch-status-both-background' , c . luminance ( branchStatusLuminance ) . toString ( ) ) ;
root Style. setProperty (
'--branch-status-both-hover-background' ,
c . luminance ( branchStatusHoverLuminance ) . toString ( ) ,
) ;
body Style. setProperty (
root Style. setProperty (
'--branch-status-both-pill-background' ,
c . luminance ( branchStatusPillLuminance ) . toString ( ) ,
) ;
@ -496,15 +496,15 @@ export class GraphApp extends App {
private getGraphTheming ( ) : { cssVariables : CssVariables ; themeOpacityFactor : number } {
// this will be called on theme updated as well as on config updated since it is dependent on the column colors from config changes and the background color from the theme
const computedStyle = window . getComputedStyle ( document . body ) ;
const bgColor = computedStyle . getPropertyValu e( '--color-background' ) ;
const computedStyle = window . getComputedStyle ( document . documentElement ) ;
const bgColor = getCssVariabl e( '--color-background' , computedStyle ) ;
const mixedGraphColors : CssVariables = { } ;
let i = 0 ;
let color ;
for ( const [ colorVar , colorDefault ] of graphLaneThemeColors ) {
color = computedStyle . getPropertyValue ( colorVar ) || colorDefault ;
color = getCssVariable ( colorVar , computedStyle ) || colorDefault ;
mixedGraphColors [ ` --column- ${ i } -color ` ] = color ;
@ -524,34 +524,34 @@ export class GraphApp extends App {
return {
cssVariables : {
'--app__bg0' : bgColor ,
'--panel__bg0' : computedStyle . getPropertyValu e( '--color-graph-background' ) ,
'--panel__bg1' : computedStyle . getPropertyValu e( '--color-graph-background2' ) ,
'--section-border' : computedStyle . getPropertyValu e( '--color-graph-background2' ) ,
'--panel__bg0' : getCssVariabl e( '--color-graph-background' , computedStyle ) ,
'--panel__bg1' : getCssVariabl e( '--color-graph-background2' , computedStyle ) ,
'--section-border' : getCssVariabl e( '--color-graph-background2' , computedStyle ) ,
'--selected-row' : computedStyle . getPropertyValu e( '--color-graph-selected-row' ) ,
'--selected-row' : getCssVariabl e( '--color-graph-selected-row' , computedStyle ) ,
'--selected-row-border' : isHighContrastTheme
? ` 1px solid ${ computedStyle . getPropertyValu e( '--color-graph-contrast-border' ) } `
? ` 1px solid ${ getCssVariabl e( '--color-graph-contrast-border' , computedStyle ) } `
: 'none' ,
'--hover-row' : computedStyle . getPropertyValu e( '--color-graph-hover-row' ) ,
'--hover-row' : getCssVariabl e( '--color-graph-hover-row' , computedStyle ) ,
'--hover-row-border' : isHighContrastTheme
? ` 1px dashed ${ computedStyle . getPropertyValu e( '--color-graph-contrast-border' ) } `
? ` 1px dashed ${ getCssVariabl e( '--color-graph-contrast-border' , computedStyle ) } `
: 'none' ,
'--text-selected' : computedStyle . getPropertyValu e( '--color-graph-text-selected' ) ,
'--text-selected-row' : computedStyle . getPropertyValu e( '--color-graph-text-selected-row' ) ,
'--text-hovered' : computedStyle . getPropertyValu e( '--color-graph-text-hovered' ) ,
'--text-dimmed-selected' : computedStyle . getPropertyValu e( '--color-graph-text-dimmed-selected' ) ,
'--text-dimmed' : computedStyle . getPropertyValu e( '--color-graph-text-dimmed' ) ,
'--text-normal' : computedStyle . getPropertyValu e( '--color-graph-text-normal' ) ,
'--text-secondary' : computedStyle . getPropertyValu e( '--color-graph-text-secondary' ) ,
'--text-disabled' : computedStyle . getPropertyValu e( '--color-graph-text-disabled' ) ,
'--text-accent' : computedStyle . getPropertyValu e( '--color-link-foreground' ) ,
'--text-inverse' : computedStyle . getPropertyValu e( '--vscode-input-background' ) ,
'--text-bright' : computedStyle . getPropertyValu e( '--vscode-input-background' ) ,
'--text-selected' : getCssVariabl e( '--color-graph-text-selected' , computedStyle ) ,
'--text-selected-row' : getCssVariabl e( '--color-graph-text-selected-row' , computedStyle ) ,
'--text-hovered' : getCssVariabl e( '--color-graph-text-hovered' , computedStyle ) ,
'--text-dimmed-selected' : getCssVariabl e( '--color-graph-text-dimmed-selected' , computedStyle ) ,
'--text-dimmed' : getCssVariabl e( '--color-graph-text-dimmed' , computedStyle ) ,
'--text-normal' : getCssVariabl e( '--color-graph-text-normal' , computedStyle ) ,
'--text-secondary' : getCssVariabl e( '--color-graph-text-secondary' , computedStyle ) ,
'--text-disabled' : getCssVariabl e( '--color-graph-text-disabled' , computedStyle ) ,
'--text-accent' : getCssVariabl e( '--color-link-foreground' , computedStyle ) ,
'--text-inverse' : getCssVariabl e( '--vscode-input-background' , computedStyle ) ,
'--text-bright' : getCssVariabl e( '--vscode-input-background' , computedStyle ) ,
. . . mixedGraphColors ,
} ,
themeOpacityFactor : parseInt ( computedStyle . getPropertyValu e( '--graph-theme-opacity-factor' ) ) || 1 ,
themeOpacityFactor : parseInt ( getCssVariabl e( '--graph-theme-opacity-factor' , computedStyle ) ) || 1 ,
} ;
}