Skip to content

Commit 1e5300b

Browse files
authored
Merge pull request #502 from devtron-labs/feat/theming
feat: add support for dark mode v1
2 parents 9ea2c2f + ddea55a commit 1e5300b

File tree

120 files changed

+818
-559
lines changed

Some content is hidden

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

120 files changed

+818
-559
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.4.8",
3+
"version": "1.4.9",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Icon/ic-laptop.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-moon.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Assets/Icon/ic-nav-rocket.svg

Lines changed: 1 addition & 1 deletion
Loading

src/Assets/Icon/ic-rotate-devtron.svg

Lines changed: 87 additions & 86 deletions
Loading

src/Assets/Icon/ic-sun.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Common/AddCDButton/AddCDButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default function AddCDButton({
6969
<rect width="20" height="20" rx="10" fill="#664BEE" className="add-cd-edge-btn" />
7070
<path
7171
d="M6.5 10H13.5M10 6.5V13.5"
72-
stroke="white"
72+
stroke="#fff"
7373
strokeWidth="1.5"
7474
strokeLinecap="round"
7575
strokeLinejoin="round"

src/Common/CodeEditor/CodeEditor.reducer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import YAML from 'yaml'
1818
import { noop, YAMLStringify } from '@Common/Helper'
1919
import { MODES } from '../Constants'
20-
import { Action, CodeEditorInitialValueType, CodeEditorState, CodeEditorThemesKeys } from './types'
20+
import { Action, CodeEditorInitialValueType, CodeEditorState } from './types'
21+
import { getCodeEditorThemeFromAppTheme } from './utils'
2122

2223
export const CodeEditorReducer = (state: CodeEditorState, action: Action) => {
2324
switch (action.type) {
@@ -77,9 +78,10 @@ export const initialState = ({
7778
diffView,
7879
noParsing,
7980
tabSize,
81+
appTheme,
8082
}: CodeEditorInitialValueType): CodeEditorState => ({
8183
mode: mode as MODES,
82-
theme: (theme || CodeEditorThemesKeys.vs) as CodeEditorThemesKeys,
84+
theme: getCodeEditorThemeFromAppTheme(theme, appTheme),
8385
code: noParsing ? value : parseValueToCode(value, mode, tabSize),
8486
defaultCode: noParsing ? defaultValue : parseValueToCode(defaultValue, mode, tabSize),
8587
diffMode: diffView,

src/Common/CodeEditor/CodeEditor.tsx

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import {
4242
} from './types'
4343
import { CodeEditorReducer, initialState, parseValueToCode } from './CodeEditor.reducer'
4444
import { DEFAULT_JSON_SCHEMA_URI, MODES } from '../Constants'
45+
import { useTheme } from '@Shared/Providers'
46+
import { getCodeEditorThemeFromAppTheme } from './utils'
4547

4648
const CodeEditorContext = React.createContext(null)
4749

@@ -70,7 +72,7 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
7072
onChange,
7173
readOnly,
7274
diffView,
73-
theme = '',
75+
theme,
7476
loading,
7577
customLoader,
7678
focus,
@@ -83,6 +85,8 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
8385
adjustEditorHeightToContent = false,
8486
disableSearch = false,
8587
}) => {
88+
const { appTheme } = useTheme()
89+
8690
if (cleanData) {
8791
value = cleanKubeManifest(value)
8892
defaultValue = cleanKubeManifest(defaultValue)
@@ -94,7 +98,16 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
9498
const memoisedReducer = React.useCallback(CodeEditorReducer, [])
9599
const [state, dispatch] = useReducer(
96100
memoisedReducer,
97-
initialState({ mode, theme, value, defaultValue, diffView, noParsing, tabSize }),
101+
initialState({
102+
mode,
103+
theme,
104+
value,
105+
defaultValue,
106+
diffView,
107+
noParsing,
108+
tabSize,
109+
appTheme,
110+
}),
98111
)
99112
const [, json, yamlCode, error] = useJsonYaml(state.code, tabSize, state.mode, !state.noParsing)
100113
const [, originalJson, originalYaml] = useJsonYaml(state.defaultCode, tabSize, state.mode, !state.noParsing)
@@ -128,25 +141,9 @@ const CodeEditor: React.FC<CodeEditorInterface> & CodeEditorComposition = React.
128141
},
129142
})
130143

131-
monaco.editor.defineTheme(CodeEditorThemesKeys.deleteDraft, {
132-
base: 'vs',
133-
inherit: true,
134-
rules: [],
135-
colors: {
136-
'diffEditor.insertedTextBackground': '#ffd4d1',
137-
'diffEditor.removedTextBackground': '#ffffff33',
138-
},
139-
})
140-
141-
monaco.editor.defineTheme(CodeEditorThemesKeys.unpublished, {
142-
base: 'vs',
143-
inherit: true,
144-
rules: [],
145-
colors: {
146-
'diffEditor.insertedTextBackground': '#eaf1dd',
147-
'diffEditor.removedTextBackground': '#ffffff33',
148-
},
149-
})
144+
useEffect(() => {
145+
dispatch({ type: 'setTheme', value: getCodeEditorThemeFromAppTheme(theme, appTheme) })
146+
}, [appTheme])
150147

151148
useEffect(() => {
152149
const rule = !disableSearch

0 commit comments

Comments
 (0)