Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 54b79b7

Browse files
committedJun 19, 2024
fixed wrong theme changing
1 parent a62d586 commit 54b79b7

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed
 

‎app/components/code-capture/controls/control-options.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function ControlOptions() {
5252
<Select
5353
onValueChange={(value) => {
5454
changeEditorTheme(value);
55-
updateEditorWindowTheme();
55+
updateEditorWindowTheme(value);
5656
}}
5757
>
5858
<SelectTrigger>

‎app/components/code-capture/preview/window-header.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import useStore from "@/lib/store/store";
55
export default function WindowHeader() {
66
const editorThemeColors = useStore((state) => state.editorThemeColors);
77

8-
console.log("edit", editorThemeColors);
9-
108
return (
119
<div
1210
className="window-header rounded-t-md flex justify-between w-full py-3 px-4 items-center"

‎hooks/editor-theme.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import { applyTheme } from "@/lib/editor/themes/apply-theme";
22
import useStore from "@/lib/store/store";
33

44
export default function useEditorTheme() {
5-
6-
const editorTheme = useStore((state) => state.editorTheme);
7-
const editorThemeColors = useStore((state) => state.editorThemeColors);
5+
86
const changeEditorThemeColors = useStore(
97
(state) => state.changeEditorThemeColors
108
);
119

12-
const updateEditorWindowTheme = async () => {
13-
const colors = await applyTheme(editorTheme);
10+
const updateEditorWindowTheme = async (themeName: string) => {
11+
const colors = await applyTheme(themeName);
1412
changeEditorThemeColors(colors);
15-
13;
1613
};
1714

1815
return { updateEditorWindowTheme };

‎lib/editor/themes/apply-theme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { loader } from "@monaco-editor/react";
22

33
const applyTheme = async (themeName: string) => {
4-
console.log(themeName);
4+
console.log("themeName", themeName);
5+
56
let themeData = await import(`monaco-themes/themes/${themeName}.json`);
67

78
themeName &&

‎lib/monoco-editor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export default function MonacoEditor() {
1313
const windowWidth = useStore((state) => state.windowWidth);
1414
const changeWindowWidth = useStore((state) => state.changeWindowWidth);
1515

16+
const editorTheme = useStore((state) => state.editorTheme);
17+
1618
const editorLanguage = useStore((state) => state.editorLanguage);
1719

1820
// to adjust editor width based on its content
@@ -27,8 +29,6 @@ export default function MonacoEditor() {
2729
}
2830
};
2931

30-
console.log("changed language", editorLanguage);
31-
3232
return (
3333
<Editor
3434
language={editorLanguage}
@@ -41,7 +41,7 @@ export default function MonacoEditor() {
4141
theme="vs-dark"
4242
onMount={(editor) => {
4343
editorRef.current = editor;
44-
updateEditorWindowTheme();
44+
updateEditorWindowTheme(editorTheme);
4545
}}
4646
onChange={() => {
4747
controlEditorWidth();

0 commit comments

Comments
 (0)
Please sign in to comment.