Skip to content

Commit

Permalink
fix: diff modal editor background
Browse files Browse the repository at this point in the history
monaco applies the theme to all editors
thus, we cannot have two separate themes at the same time
  • Loading branch information
devcatalin committed Aug 31, 2021
1 parent 4debe15 commit c200aa4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
13 changes: 11 additions & 2 deletions src/components/organisms/DiffModal/DiffModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {useEffect, useState} from 'react';
import {stringify} from 'yaml';

import {KUBESHOP_MONACO_DIFF_THEME} from '@utils/monaco';
import {KUBESHOP_MONACO_THEME} from '@utils/monaco';

import Colors from '@styles/Colors';
import {applyResourceWithConfirm} from '@redux/services/applyResourceWithConfirm';
Expand Down Expand Up @@ -38,6 +38,15 @@ const LeftButton = styled(Button)`

const MonacoDiffContainer = styled.div`
padding: 8px;
& .monaco-editor .monaco-editor-background {
background-color: ${Colors.grey1000} !important;
}
& .monaco-editor .margin {
background-color: ${Colors.grey1000} !important;
}
& .diffOverview {
background-color: ${Colors.grey1000} !important;
}
`;

const DiffModal = () => {
Expand Down Expand Up @@ -120,7 +129,7 @@ const DiffModal = () => {
original={resourceContent}
value={diffContent}
options={options}
theme={KUBESHOP_MONACO_DIFF_THEME}
theme={KUBESHOP_MONACO_THEME}
/>
</MonacoDiffContainer>
</StyledModal>
Expand Down
16 changes: 1 addition & 15 deletions src/utils/monaco.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {monaco} from 'react-monaco-editor';

import Colors from '@styles/Colors';

const KUBESHOP_MONACO_THEME = 'kubeshopTheme';
const KUBESHOP_MONACO_DIFF_THEME = 'kubeshopDiffTheme';

const KUBESHOP_THEME_DATA: monaco.editor.IStandaloneThemeData = {
base: 'vs-dark',
Expand All @@ -22,17 +19,6 @@ const createKubeshopTheme = (editor: typeof monaco.editor) => {
editor.defineTheme(KUBESHOP_MONACO_THEME, KUBESHOP_THEME_DATA);
};

const createKubeshopDiffTheme = (editor: typeof monaco.editor) => {
editor.defineTheme(KUBESHOP_MONACO_DIFF_THEME, {
...KUBESHOP_THEME_DATA,
colors: {
...KUBESHOP_THEME_DATA.colors,
'editor.background': Colors.grey1000,
},
});
};

createKubeshopTheme(monaco.editor);
createKubeshopDiffTheme(monaco.editor);

export {KUBESHOP_MONACO_THEME, KUBESHOP_MONACO_DIFF_THEME};
export {KUBESHOP_MONACO_THEME};

0 comments on commit c200aa4

Please sign in to comment.