@@ -62,7 +62,17 @@ public virtual string ReplaceCssVariables(string html)
6262 var editorBackground = backgroundColor ;
6363 var editorForeground = textColor ;
6464
65- // Buttons - use command bar colors which are designed for interactive elements
65+ // Primary buttons - use hyperlink color for a prominent blue appearance
66+ var primaryButtonBackground = linkColor ;
67+ var primaryButtonForeground = "#FFFFFF" ;
68+ var primaryButtonHoverBackground = AdjustBrightness ( primaryButtonBackground , 1.15f ) ;
69+
70+ // Secondary buttons - use input background for visible contrast with main background
71+ var secondaryButtonBackground = inputBackground ;
72+ var secondaryButtonForeground = textColor ;
73+ var secondaryButtonHoverBackground = AdjustBrightness ( secondaryButtonBackground , 1.15f ) ;
74+
75+ // Legacy vscode- prefixed button variables (kept for compatibility)
6676 var buttonBackground = VSColorTheme . GetThemedColor ( EnvironmentColors . CommandBarMenuBackgroundGradientBeginColorKey ) . ToHex ( ) ;
6777 var buttonText = textColor ;
6878 var buttonHoverBackground = VSColorTheme . GetThemedColor ( EnvironmentColors . CommandBarMouseOverBackgroundBeginColorKey ) . ToHex ( ) ;
@@ -97,19 +107,27 @@ public virtual string ReplaceCssVariables(string html)
97107 { "vscode-errorForeground" , errorForeground } ,
98108 { "vscode-input-background" , inputBackground } ,
99109 { "vscode-editor-inactiveSelectionBackground" , inactiveSelectionBackground } ,
100- { "vscode-button-background" , buttonBackground } ,
101- { "vscode-button-foreground" , buttonText } ,
102- { "vscode-button-hoverBackground" , buttonHoverBackground } ,
103- { "vscode-button-secondaryBackground" , ColorToRgba ( buttonBackground , 0.6 ) } ,
104- { "vscode-button-secondaryForeground" , buttonText } ,
105- { "vscode-button-secondaryHoverBackground" , ColorToRgba ( buttonHoverBackground , 0.7 ) } ,
106110 { "vscode-list-hoverBackground" , listHoverBackground } ,
107111 { "vscode-input-border" , inputBorder } ,
108112 { "vscode-panel-border" , borderColor } ,
109113 { "vscode-focusBorder" , linkColor } ,
110114 { "vscode-scrollbarSlider-background" , scrollbarThumb } ,
111115 { "vscode-scrollbarSlider-hoverBackground" , scrollbarThumbHover } ,
112116 { "vscode-scrollbarSlider-activeBackground" , scrollbarThumbHover } ,
117+ // Button variables (vscode- prefix for legacy compatibility)
118+ { "vscode-button-background" , buttonBackground } ,
119+ { "vscode-button-foreground" , buttonText } ,
120+ { "vscode-button-hoverBackground" , buttonHoverBackground } ,
121+ { "vscode-button-secondaryBackground" , ColorToRgba ( buttonBackground , 0.6 ) } ,
122+ { "vscode-button-secondaryForeground" , buttonText } ,
123+ { "vscode-button-secondaryHoverBackground" , ColorToRgba ( buttonHoverBackground , 0.7 ) } ,
124+ // Button variables (LS HTML uses these without vscode- prefix)
125+ { "button-background-color" , primaryButtonBackground } ,
126+ { "button-foreground" , primaryButtonForeground } ,
127+ { "button-hover-background" , primaryButtonHoverBackground } ,
128+ { "button-secondary-background" , secondaryButtonBackground } ,
129+ { "button-secondary-foreground" , secondaryButtonForeground } ,
130+ { "button-secondary-hover-background" , secondaryButtonHoverBackground } ,
113131 // Legacy variables (for fallback HTML)
114132 { "default-font" , "'Segoe UI', Tahoma, Geneva, Verdana, sans-serif" } ,
115133 { "text-color" , textColor } ,
@@ -165,5 +183,37 @@ private string ColorToRgba(string hexColor, double alpha)
165183 int b = Convert . ToInt32 ( hexColor . Substring ( 4 , 2 ) , 16 ) ;
166184 return $ "rgba({ r } , { g } , { b } , { alpha : F2} )";
167185 }
186+
187+ /// <summary>
188+ /// Adjusts the brightness of a hex color by a given factor.
189+ /// </summary>
190+ /// <param name="hexColor">The hex color string (e.g., "#0e639c")</param>
191+ /// <param name="factor">Brightness multiplier (> 1.0 for lighter, < 1.0 for darker)</param>
192+ /// <returns>Adjusted hex color string</returns>
193+ private string AdjustBrightness ( string hexColor , float factor )
194+ {
195+ if ( string . IsNullOrEmpty ( hexColor ) || ! hexColor . StartsWith ( "#" ) )
196+ {
197+ return hexColor ;
198+ }
199+
200+ try
201+ {
202+ var hex = hexColor . Substring ( 1 ) ;
203+ int r = Convert . ToInt32 ( hex . Substring ( 0 , 2 ) , 16 ) ;
204+ int g = Convert . ToInt32 ( hex . Substring ( 2 , 2 ) , 16 ) ;
205+ int b = Convert . ToInt32 ( hex . Substring ( 4 , 2 ) , 16 ) ;
206+
207+ r = Math . Min ( 255 , Math . Max ( 0 , ( int ) ( r * factor ) ) ) ;
208+ g = Math . Min ( 255 , Math . Max ( 0 , ( int ) ( g * factor ) ) ) ;
209+ b = Math . Min ( 255 , Math . Max ( 0 , ( int ) ( b * factor ) ) ) ;
210+
211+ return $ "#{ r : X2} { g : X2} { b : X2} ";
212+ }
213+ catch
214+ {
215+ return hexColor ;
216+ }
217+ }
168218 }
169219}
0 commit comments