Skip to content

Commit

Permalink
Fix code editor in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Mendapara committed Jun 12, 2023
1 parent 4b2e058 commit 5a3801f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Editor from "@monaco-editor/react";
import clsx from "clsx";
import { useCallback } from "react";

import { useAppTheme } from "@/hooks/use-app-theme";
import { FieldControl, FieldProps } from "../../builder";
import { useInput } from "../../builder/hooks";

Expand All @@ -12,6 +13,9 @@ export function CodeEditor(props: FieldProps<string>) {
const { mode, codeSyntax, height = 400, width = "100%" } = schema;

const language = mode || codeSyntax;
const appTheme = useAppTheme();

const theme = appTheme === "dark" ? "vs-dark" : "light";

const { value, setValue } = useInput(valueAtom, {
defaultValue: "",
Expand All @@ -36,6 +40,7 @@ export function CodeEditor(props: FieldProps<string>) {
})}
>
<Editor
theme={theme}
language={language}
value={value}
width={w}
Expand Down

0 comments on commit 5a3801f

Please sign in to comment.