Skip to content

Commit 568b04a

Browse files
authored
feat: update high contrast theme (#1728)
* feat: update high contrast theme * chore: update icon theme type * chore: update test
1 parent 94ac126 commit 568b04a

82 files changed

Lines changed: 2046 additions & 752 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/editor/src/browser/decoration-applier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class MonacoEditorDecorationApplier extends Disposable {
173173
function assignModelDecorationOptions(
174174
target: monaco.editor.IModelDecorationOptions,
175175
property: IDynamicModelDecorationProperty,
176-
currentTheme: undefined | 'dark' | 'light' | 'hc',
176+
currentTheme: undefined | 'dark' | 'light' | 'hcDark' | 'hcLight',
177177
) {
178178
if (property.overviewRulerLane) {
179179
if (!target.overviewRuler) {

packages/extension/__tests__/hosted/api/vscode/ext.host.theming.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { IThemeService, ThemeType } from '@opensumi/ide-theme';
88

99
import { createBrowserInjector } from '../../../../../../tools/dev-tool/src/injector-helper';
1010

11-
1211
const emitterA = new Emitter<any>();
1312
const emitterB = new Emitter<any>();
1413

@@ -62,6 +61,6 @@ describe('vscode extHostTheming Test', () => {
6261
expect(e.kind).toEqual(ColorThemeKind.HighContrast);
6362
done();
6463
});
65-
themeChangeEmitter.fire({ type: 'hc' });
64+
themeChangeEmitter.fire({ type: 'hcDark' });
6665
});
6766
});

packages/extension/__tests__/node/merge-contributes.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ describe('mergeContributes', () => {
108108
dark: '#FFFFFF13',
109109
light: '#0000000C',
110110
highContrast: '#FFFFFF13',
111+
highContrastLight: '#FFFFFF13',
111112
},
112113
};
113114

@@ -118,6 +119,7 @@ describe('mergeContributes', () => {
118119
dark: '#BEBEBE',
119120
light: '#747474',
120121
highContrast: '#BEBEBE',
122+
highContrastLight: '#BEBEBE',
121123
},
122124
};
123125

packages/extension/src/browser/vscode/api/main.thread.api.webview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export class MainThreadWebview extends Disposable implements IMainThreadWebview
405405
this._persistWebviewPanelMeta(id);
406406
}
407407

408-
$setIconPath(id: string, value: { light: string; dark: string; hc: string } | undefined): void {
408+
$setIconPath(id: string, value: { light: string; dark: string } | undefined): void {
409409
const webviewPanel = this.getWebviewPanel(id);
410410
if (!webviewPanel.editorWebview) {
411411
return;

packages/extension/src/browser/vscode/contributes/color.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ export class ColorsContributionPoint extends VSCodeContributePoint<ColorsSchema>
5151
highContrast: {
5252
description: localize(
5353
'contributes.defaults.highContrast',
54-
'The default color for high contrast themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default.',
54+
'The default color for high contrast dark themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default. If not provided, the `dark` color is used as default for high contrast dark themes.',
55+
),
56+
type: 'string',
57+
anyOf: [{ type: 'string', format: 'color-hex' }],
58+
},
59+
highContrastLight: {
60+
description: localize(
61+
'contributes.defaults.highContrastLight',
62+
'The default color for high contrast light themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default. If not provided, the `light` color is used as default for high contrast light themes.',
5563
),
5664
type: 'string',
5765
anyOf: [{ type: 'string', format: 'color-hex' }],

packages/extension/src/common/vscode/ext-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,7 @@ export enum ColorThemeKind {
26562656
Light = 1,
26572657
Dark = 2,
26582658
HighContrast = 3,
2659+
HighContrastLight = 4,
26592660
}
26602661

26612662
export enum SymbolTag {

packages/extension/src/common/vscode/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export interface IView {
8888
export interface IColor {
8989
id: string;
9090
description: string;
91-
defaults: { light: string; dark: string; highContrast: string };
91+
defaults: { light: string; dark: string; highContrast: string; highContrastLight: string };
9292
}
9393

9494
export interface IExtensionContributions {

packages/extension/src/common/vscode/webview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface IMainThreadWebview {
4141
$disposeWebview(id: string): void;
4242
$reveal(id: string, showOptions: WebviewPanelShowOptions): void;
4343
$setTitle(id: string, value: string): void;
44-
$setIconPath(id: string, value?: { light: string; dark: string; hc: string } | string): void;
44+
$setIconPath(id: string, value?: { light: string; dark: string } | string): void;
4545

4646
$setHtml(id: string, value: string): void;
4747
$setOptions(id: string, options: IWebviewOptions): void;

packages/extension/src/hosted/api/vscode/ext.host.api.webview.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,15 @@ export class ExtHostWebviewPanel implements WebviewPanel {
200200
this.assertNotDisposed();
201201
if (this._iconPath !== value) {
202202
this._iconPath = value;
203-
let param: { light: string; dark: string; hc: string } = { light: '', dark: '', hc: '' };
203+
let param: { light: string; dark: string } = {
204+
light: '',
205+
dark: '',
206+
};
204207
if (Uri.isUri(value)) {
205-
param = { light: value.toString(), dark: value.toString(), hc: value.toString() };
208+
param = { light: value.toString(), dark: value.toString() };
206209
} else {
207210
const v = value as { light: Uri; dark: Uri };
208-
param = { light: v.light.toString(), dark: v.dark.toString(), hc: '' };
211+
param = { light: v.light.toString(), dark: v.dark.toString() };
209212
}
210213
this._proxy.$setIconPath(this._handle, param);
211214
}

packages/extension/src/hosted/api/vscode/ext.host.theming.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,23 @@ export class ExtHostTheming implements IExtHostTheming {
2020
}
2121

2222
$onColorThemeChange(type: string): void {
23-
const kind =
24-
type === 'light' ? ColorThemeKind.Light : type === 'dark' ? ColorThemeKind.Dark : ColorThemeKind.HighContrast;
23+
let kind: ColorThemeKind;
24+
switch (type) {
25+
case 'light':
26+
kind = ColorThemeKind.Light;
27+
break;
28+
case 'dark':
29+
kind = ColorThemeKind.Dark;
30+
break;
31+
case 'hcDark':
32+
kind = ColorThemeKind.HighContrast;
33+
break;
34+
case 'hcLight':
35+
kind = ColorThemeKind.HighContrastLight;
36+
break;
37+
default:
38+
kind = ColorThemeKind.Dark;
39+
}
2540
this._actual = new ColorTheme(kind);
2641
this._onDidChangeActiveColorTheme.fire(this._actual);
2742
}

0 commit comments

Comments
 (0)