Skip to content

Commit 51ed550

Browse files
author
Akos Kitta
committed
fix: simplified official theme labels
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 996bb01 commit 51ed550

File tree

4 files changed

+40
-24
lines changed

4 files changed

+40
-24
lines changed

arduino-ide-extension/src/browser/theia/core/theming.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Disposable } from '@theia/core';
12
import {
23
BuiltinThemeProvider,
34
ThemeService,
@@ -8,24 +9,24 @@ import { injectable } from '@theia/core/shared/inversify';
89
import { ThemeServiceWithDB as TheiaThemeServiceWithDB } from '@theia/monaco/lib/browser/monaco-indexed-db';
910

1011
export namespace ArduinoThemes {
11-
export const Light: Theme = {
12+
export const light: Theme = {
1213
id: 'arduino-theme',
1314
type: 'light',
14-
label: 'Light (Arduino)',
15+
label: 'Light',
1516
editorTheme: 'arduino-theme',
1617
};
17-
export const Dark: Theme = {
18+
export const dark: Theme = {
1819
id: 'arduino-theme-dark',
1920
type: 'dark',
20-
label: 'Dark (Arduino)',
21+
label: 'Dark',
2122
editorTheme: 'arduino-theme-dark',
2223
};
2324
}
2425

2526
const builtInThemeIds = new Set(
2627
[
27-
ArduinoThemes.Light,
28-
ArduinoThemes.Dark,
28+
ArduinoThemes.light,
29+
ArduinoThemes.dark,
2930
BuiltinThemeProvider.hcTheme,
3031
// TODO: add the HC light theme after Theia 1.36
3132
].map(({ id }) => id)
@@ -38,16 +39,16 @@ export function isBuiltInTheme(theme: Theme | string): boolean {
3839
export function compatibleBuiltInTheme(theme: Theme): Theme {
3940
switch (theme.type) {
4041
case 'light':
41-
return ArduinoThemes.Light;
42+
return ArduinoThemes.light;
4243
case 'dark':
43-
return ArduinoThemes.Dark;
44+
return ArduinoThemes.dark;
4445
case 'hc':
4546
return BuiltinThemeProvider.hcTheme;
4647
default: {
4748
console.warn(
4849
`Unhandled theme type: ${theme.type}. Theme ID: ${theme.id}, label: ${theme.label}`
4950
);
50-
return ArduinoThemes.Light;
51+
return ArduinoThemes.light;
5152
}
5253
}
5354
}
@@ -63,6 +64,20 @@ export class ThemeServiceWithDB extends TheiaThemeServiceWithDB {
6364
// this.register(ArduinoThemes.Light, ArduinoThemes.Dark); // TODO: check if needed
6465
super.init();
6566
}
67+
68+
override register(...themes: Theme[]): Disposable {
69+
const hcThemeIndex = themes.findIndex(
70+
(theme) => theme.id === BuiltinThemeProvider.hcTheme.id
71+
);
72+
if (hcThemeIndex >= 0) {
73+
const hcTheme = themes[hcThemeIndex];
74+
themes.splice(hcThemeIndex, 1, {
75+
...hcTheme,
76+
label: nls.localize('arduino/theme/hcDark', 'High Contrast (Dark)'),
77+
});
78+
}
79+
return super.register(...themes);
80+
}
6681
}
6782

6883
interface ThemeProvider {

arduino-ide-extension/src/browser/theia/monaco/monaco-theming-service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ export class MonacoThemingService extends TheiaMonacoThemingService {
104104
}
105105

106106
private registerArduinoThemes(): void {
107-
const { Light, Dark } = ArduinoThemes;
107+
const { light, dark } = ArduinoThemes;
108108
this.registerParsedTheme({
109-
id: Light.id,
110-
label: Light.label,
109+
id: light.id,
110+
label: light.label,
111111
uiTheme: 'vs',
112112
json: require('../../../../src/browser/data/default.color-theme.json'),
113113
});
114114
this.registerParsedTheme({
115-
id: Dark.id,
116-
label: Dark.label,
115+
id: dark.id,
116+
label: dark.label,
117117
uiTheme: 'vs-dark',
118118
json: require('../../../../src/browser/data/dark.color-theme.json'),
119119
});

arduino-ide-extension/src/test/browser/theming.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,35 @@ describe('theming', () => {
2828
it('if the current theme is a built-in theme, the result does not contain any contributed theme', () => {
2929
const actual = userConfigurableThemes({
3030
themes: () => [
31-
ArduinoThemes.Light,
32-
ArduinoThemes.Dark,
31+
ArduinoThemes.light,
32+
ArduinoThemes.dark,
3333
testTheme,
3434
BuiltinThemeProvider.hcTheme,
3535
anotherTestTheme,
3636
],
3737
currentTheme: () => BuiltinThemeProvider.hcTheme,
3838
});
3939
expect(actual.length).to.be.equal(3);
40-
expect(actual[0].id).to.be.equal(ArduinoThemes.Light.id);
41-
expect(actual[1].id).to.be.equal(ArduinoThemes.Dark.id);
40+
expect(actual[0].id).to.be.equal(ArduinoThemes.light.id);
41+
expect(actual[1].id).to.be.equal(ArduinoThemes.dark.id);
4242
expect(actual[2].id).to.be.equal(BuiltinThemeProvider.hcTheme.id);
4343
});
4444

4545
it('if the currently selected theme is a contributed one, it is the last element in the array', () => {
4646
const actual = userConfigurableThemes({
4747
themes: () => [
4848
BuiltinThemeProvider.hcTheme,
49-
ArduinoThemes.Dark,
50-
ArduinoThemes.Light,
49+
ArduinoThemes.dark,
50+
ArduinoThemes.light,
5151
testTheme,
5252
anotherTestTheme,
5353
],
5454
currentTheme: () => testTheme,
5555
});
5656
expect(actual.length).to.be.equal(4);
5757
expect(actual[0].id).to.be.equal(BuiltinThemeProvider.hcTheme.id);
58-
expect(actual[1].id).to.be.equal(ArduinoThemes.Dark.id);
59-
expect(actual[2].id).to.be.equal(ArduinoThemes.Light.id);
58+
expect(actual[1].id).to.be.equal(ArduinoThemes.dark.id);
59+
expect(actual[2].id).to.be.equal(ArduinoThemes.light.id);
6060
expect(actual[3].id).to.be.equal(testTheme.id);
6161
});
6262
});
@@ -67,8 +67,8 @@ describe('theming', () => {
6767
[BuiltinThemeProvider.lightTheme, false],
6868
[BuiltinThemeProvider.darkTheme, false],
6969
[BuiltinThemeProvider.hcTheme, true],
70-
[ArduinoThemes.Light, true],
71-
[ArduinoThemes.Dark, true],
70+
[ArduinoThemes.light, true],
71+
[ArduinoThemes.dark, true],
7272
[testTheme, false],
7373
] as [Theme, boolean][]
7474
).map(([theme, expected]) =>

i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@
469469
"theme": {
470470
"contributedTheme": "Contributed Theme",
471471
"couldNotLoadTheme": "Could not load your currently selected theme: {0}. Do you want to automatically select a compatible theme?",
472+
"hcDark": "High Contrast (Dark)",
472473
"selectManually": "Select Manually"
473474
},
474475
"title": {

0 commit comments

Comments
 (0)