Skip to content

Commit 2724ca6

Browse files
committed
styler: allow Color
1 parent 313ede6 commit 2724ca6

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/vs/platform/theme/common/colorRegistry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ function lessProminent(colorValue: ColorValue, backgroundColorValue: ColorValue,
473473
/**
474474
* @param colorValue Resolve a color value in the context of a theme
475475
*/
476-
function resolveColorValue(colorValue: ColorValue | null, theme: ITheme): Color | undefined {
476+
export function resolveColorValue(colorValue: ColorValue | null, theme: ITheme): Color | undefined {
477477
if (colorValue === null) {
478478
return undefined;
479479
} else if (typeof colorValue === 'string') {

src/vs/platform/theme/common/styler.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { ITheme, IThemeService } from 'vs/platform/theme/common/themeService';
7-
import { focusBorder, inputBackground, inputForeground, ColorIdentifier, selectForeground, selectBackground, selectListBackground, selectBorder, inputBorder, foreground, editorBackground, contrastBorder, inputActiveOptionBorder, inputActiveOptionBackground, listFocusBackground, listFocusForeground, listActiveSelectionBackground, listActiveSelectionForeground, listInactiveSelectionForeground, listInactiveSelectionBackground, listInactiveFocusBackground, listHoverBackground, listHoverForeground, listDropBackground, pickerGroupBorder, pickerGroupForeground, widgetShadow, inputValidationInfoBorder, inputValidationInfoBackground, inputValidationWarningBorder, inputValidationWarningBackground, inputValidationErrorBorder, inputValidationErrorBackground, activeContrastBorder, buttonForeground, buttonBackground, buttonHoverBackground, ColorFunction, badgeBackground, badgeForeground, progressBarBackground, breadcrumbsForeground, breadcrumbsFocusForeground, breadcrumbsActiveSelectionForeground, breadcrumbsBackground, editorWidgetBorder, inputValidationInfoForeground, inputValidationWarningForeground, inputValidationErrorForeground, menuForeground, menuBackground, menuSelectionForeground, menuSelectionBackground, menuSelectionBorder, menuBorder, menuSeparatorBackground, darken, listFilterWidgetOutline, listFilterWidgetNoMatchesOutline, listFilterWidgetBackground, editorWidgetBackground, treeIndentGuidesStroke, editorWidgetForeground, simpleCheckboxBackground, simpleCheckboxBorder, simpleCheckboxForeground } from 'vs/platform/theme/common/colorRegistry';
7+
import { focusBorder, inputBackground, inputForeground, ColorIdentifier, selectForeground, selectBackground, selectListBackground, selectBorder, inputBorder, foreground, editorBackground, contrastBorder, inputActiveOptionBorder, inputActiveOptionBackground, listFocusBackground, listFocusForeground, listActiveSelectionBackground, listActiveSelectionForeground, listInactiveSelectionForeground, listInactiveSelectionBackground, listInactiveFocusBackground, listHoverBackground, listHoverForeground, listDropBackground, pickerGroupBorder, pickerGroupForeground, widgetShadow, inputValidationInfoBorder, inputValidationInfoBackground, inputValidationWarningBorder, inputValidationWarningBackground, inputValidationErrorBorder, inputValidationErrorBackground, activeContrastBorder, buttonForeground, buttonBackground, buttonHoverBackground, ColorFunction, badgeBackground, badgeForeground, progressBarBackground, breadcrumbsForeground, breadcrumbsFocusForeground, breadcrumbsActiveSelectionForeground, breadcrumbsBackground, editorWidgetBorder, inputValidationInfoForeground, inputValidationWarningForeground, inputValidationErrorForeground, menuForeground, menuBackground, menuSelectionForeground, menuSelectionBackground, menuSelectionBorder, menuBorder, menuSeparatorBackground, darken, listFilterWidgetOutline, listFilterWidgetNoMatchesOutline, listFilterWidgetBackground, editorWidgetBackground, treeIndentGuidesStroke, editorWidgetForeground, simpleCheckboxBackground, simpleCheckboxBorder, simpleCheckboxForeground, ColorValue, resolveColorValue } from 'vs/platform/theme/common/colorRegistry';
88
import { IDisposable } from 'vs/base/common/lifecycle';
99
import { Color } from 'vs/base/common/color';
1010
import { mixin } from 'vs/base/common/objects';
@@ -20,7 +20,7 @@ export interface IThemable {
2020
}
2121

2222
export interface IColorMapping {
23-
[optionsKey: string]: ColorIdentifier | ColorFunction | undefined;
23+
[optionsKey: string]: ColorValue | undefined;
2424
}
2525

2626
export interface IComputedStyles {
@@ -30,11 +30,9 @@ export interface IComputedStyles {
3030
export function computeStyles(theme: ITheme, styleMap: IColorMapping): IComputedStyles {
3131
const styles = Object.create(null) as IComputedStyles;
3232
for (let key in styleMap) {
33-
const value = styleMap[key as string];
34-
if (typeof value === 'string') {
35-
styles[key] = theme.getColor(value);
36-
} else if (typeof value === 'function') {
37-
styles[key] = value(theme);
33+
const value = styleMap[key];
34+
if (value) {
35+
styles[key] = resolveColorValue(value, theme);
3836
}
3937
}
4038

0 commit comments

Comments
 (0)