Skip to content

Commit 9a6ed01

Browse files
authored
fix: optimize the Color Theme (#395)
* fix: set the sidebar width as 230px * feat: add polyfill function for the colorTheme * feat: add default panel title color * fix: optimize the splitPane and scrollable styles * feat: add background color for the minimap * fix: optimize the colorTheme * test: update the Workbench snapshot * refactor: optimize the perfectColors function
1 parent f99b10f commit 9a6ed01

File tree

11 files changed

+57
-55
lines changed

11 files changed

+57
-55
lines changed

src/extensions/theme-monokai/themes/monokai-color-theme.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"editor.selectionHighlightBackground": "#575b6180",
1717
"editor.selectionBackground": "#878b9180",
1818
"minimap.selectionHighlight": "#878b9180",
19+
"minimap.background": "#272822",
1920
"editor.wordHighlightBackground": "#4a4a7680",
2021
"editor.wordHighlightStrongBackground": "#6a6a9680",
2122
"editor.lineHighlightBackground": "#3e3d32",

src/model/workbench/layout.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class LayoutModel implements ILayout {
3131
public sidebar: ISidebarViewState;
3232
public menuBar: ViewVisibility;
3333
constructor(
34-
splitPanePos: string[] = ['300px', 'auto'],
34+
splitPanePos: string[] = ['230px', 'auto'],
3535
horizontalSplitPanePos = ['70%', 'auto'],
3636
activityBar = { hidden: false },
3737
panel = { hidden: false, panelMaximized: false },

src/services/theme/colorRegistry.ts

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ const defaultVS = {
6969

7070
'panel.background': Color.white,
7171
'panel.border': 'rgba(128, 128, 128, 0.35)',
72+
'panelTitle.activeForeground': 'rgb(66, 66, 66)',
73+
'panelTitle.activeBorder': 'rgb(66, 66, 66)',
7274

7375
'activityBar.background': 'rgb(51, 51, 51)',
7476
'activityBar.activeBorder': '#fff',
@@ -143,6 +145,8 @@ const defaultDark = {
143145

144146
'panel.background': 'rgb(30, 30, 30)',
145147
'panel.border': '#3C3C3C',
148+
'panelTitle.activeBorder': 'rgb(231, 231, 231)',
149+
'panelTitle.activeForeground': 'rgb(231, 231, 231)',
146150

147151
'activityBar.background': 'rgb(51, 51, 51)',
148152
'activityBar.activeBorder': '#fff',
@@ -204,6 +208,8 @@ const defaultHc = {
204208
'menu.separatorBackground': '#6FC3DF',
205209

206210
'panel.border': '#6FC3DF',
211+
'panelTitle.activeBorder': 'rgb(231, 231, 231)',
212+
'panelTitle.activeForeground': 'rgb(231, 231, 231)',
207213

208214
'activityBar.background': 'rgb(51, 51, 51)',
209215
'activityBar.activeBorder': '#fff',

src/services/theme/helper.ts

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { IColorTheme } from 'mo/model/colorTheme';
1+
import { cloneDeep } from 'lodash';
2+
import { IColors, IColorTheme } from 'mo/model/colorTheme';
23
import { getBuiltInColors } from 'mo/services/theme/colorRegistry';
34
import { editor as MonacoEditor } from 'monaco-editor';
45

@@ -27,11 +28,35 @@ export function convertToCSSVars(colors: object) {
2728
`;
2829
}
2930

31+
/**
32+
* Perfect the Color Theme,
33+
* because some theme extensions not assign the fully,
34+
* this function automatic helps to polyfill the color theme
35+
* @param colors
36+
* @returns colors
37+
*/
38+
function perfectColors(colors: IColors): IColors {
39+
const nextColors = cloneDeep(colors);
40+
const inheritMap = [
41+
['minimap.background', 'editor.background'],
42+
['minimapSlider.background', 'scrollbarSlider.background'],
43+
['minimapSlider.hoverBackground', 'scrollbarSlider.hoverBackground'],
44+
['minimapSlider.activeBackground', 'scrollbarSlider.activeBackground'],
45+
];
46+
47+
inheritMap.forEach(([inheritSourceColor, inheritTargetColor]) => {
48+
if (nextColors[inheritTargetColor]) {
49+
nextColors[inheritSourceColor] = nextColors[inheritTargetColor];
50+
}
51+
});
52+
return nextColors;
53+
}
54+
3055
export function getThemeData(
3156
theme: IColorTheme
3257
): MonacoEditor.IStandaloneThemeData {
3358
const builtInColors = getBuiltInColors(theme);
34-
const colors = Object.assign({}, builtInColors, theme.colors);
59+
const colors = perfectColors(Object.assign(builtInColors, theme.colors));
3560

3661
const convertColors = {};
3762
for (const colorId in colors) {

src/style/theme/menubar.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// =============== MenuBar =============== //
44
#{$menuBar} {
55
background-color: var(--activityBar-background);
6-
border-color: var(--activityBar-border);
7-
color: var(--activityBar-foreground);
6+
color: var(--activityBar-inactiveForeground);
87

98
#{$menu} {
109
&__item {

src/style/theme/panel.scss

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
border-color: var(--panel-border);
77

88
&__header {
9-
#{$tab}__item {
10-
color: var(--panelTitle-inactiveForeground);
11-
12-
&--active {
9+
#{$tabs} {
10+
#{$tab}__item--active {
1311
border-color: var(--panelTitle-activeBorder);
1412
color: var(--panelTitle-activeForeground);
1513

src/workbench/__tests__/__snapshots__/workbench.test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ exports[`Test Workbench Component Match The WorkbenchView snapshot 1`] = `
6969
data-type="SplitPane"
7070
>
7171
<div
72-
style="display: -webkit-box,-moz-box,-ms-flexbox,-webkit-flex,flex; outline: none; min-width: 170px; max-width: calc(80% - 1px*0.8); flex-grow: 0; width: 300px;"
72+
style="display: -webkit-box,-moz-box,-ms-flexbox,-webkit-flex,flex; outline: none; min-width: 170px; max-width: calc(80% - 1px*0.8); flex-grow: 0; width: 230px;"
7373
>
7474
<div
7575
class="mo-sidebar"

src/workbench/activityBar/style.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
display: flex;
3131
height: 48px;
3232
justify-content: center;
33-
margin-bottom: 4px;
3433
position: relative;
3534
transition: transform 50ms ease;
3635
width: 48px;
@@ -67,6 +66,6 @@
6766
left: 0;
6867
position: absolute;
6968
top: 0;
70-
width: 1px;
69+
width: 2px;
7170
}
7271
}

src/workbench/menuBar/style.scss

+4
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313
left: 0;
1414
top: 0;
1515
}
16+
17+
&__action {
18+
font-size: 16px;
19+
}
1620
}

src/workbench/panel/style.scss

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $icon-size: 35px;
3232
#{$tab}__item {
3333
background: inherit;
3434
border: 0;
35+
color: var(--panelTitle-inactiveForeground);
3536
font-size: 11px;
3637
padding: 0 10px;
3738
text-transform: uppercase;

src/workbench/style.scss

+12-43
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,19 @@
2424
left: 0;
2525
width: auto;
2626

27-
/* stylelint-disable */
28-
.Resizer {
29-
background-clip: padding;
30-
background-clip: padding;
31-
background-clip: padding-box;
32-
box-sizing: border-box;
33-
box-sizing: border-box;
34-
box-sizing: border-box;
35-
opacity: 0.2;
36-
z-index: 1;
27+
// For SplitPane resizer
28+
div[data-type='Resizer'] {
29+
background: none;
3730
}
3831

39-
.Resizer:hover {
40-
transition: all 2s ease;
41-
transition: all 2s ease;
42-
}
43-
44-
.Resizer.horizontal {
45-
border-bottom: 5px solid transparent;
46-
border-top: 5px solid transparent;
47-
cursor: row-resize;
48-
height: 11px;
49-
margin: -5px 0;
50-
width: 100%;
51-
}
52-
53-
.Resizer.horizontal:hover {
54-
border-bottom: 5px solid transparent;
55-
border-top: 5px solid transparent;
56-
}
57-
58-
.Resizer.vertical {
59-
border-left: 5px solid transparent;
60-
border-right: 5px solid transparent;
61-
cursor: col-resize;
62-
margin: 0 -5px;
63-
width: 11px;
64-
}
65-
66-
.Resizer.disabled {
67-
cursor: not-allowed;
68-
}
69-
70-
.Resizer.disabled:hover {
71-
border-color: transparent;
32+
.monaco-scrollable-element {
33+
/* stylelint-disable-next-line*/
34+
& > .scrollbar > .slider {
35+
background: var(--scrollbarSlider-activeBackground);
36+
/* stylelint-disable-next-line*/
37+
&:hover {
38+
background: var(--scrollbarSlider-hoverBackground);
39+
}
40+
}
7241
}
7342
}

0 commit comments

Comments
 (0)