Skip to content

Commit

Permalink
[dark mode] code editor follows theme
Browse files Browse the repository at this point in the history
relates #66
  • Loading branch information
paulgirard committed Jun 19, 2024
1 parent 1cb21da commit cb19e01
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/views/graphPage/modals/FunctionEditorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { useTranslation } from "react-i18next";

import { CloseIcon, CodeEditorIcon, RunIcon, SaveIcon } from "../../../components/common-icons";
import { Modal } from "../../../components/modals";
import { usePreferences } from "../../../core/context/dataContexts";
import { ModalProps } from "../../../core/modals/types";
import { getAppliedTheme } from "../../../core/preferences/utils";

//eslint-disable-next-line @typescript-eslint/ban-types
interface FunctionEditorModalProps<T = Function> {
Expand All @@ -19,6 +21,7 @@ interface FunctionEditorModalProps<T = Function> {
export function FunctionEditorModal<T>(props: ModalProps<FunctionEditorModalProps<T>, { run: boolean; script: T }>) {
const { t } = useTranslation();
const { cancel, submit } = props;
const { theme } = usePreferences();
const { title, withSaveAndRun, checkFunction, functionJsDoc, defaultFunction, value } = props.arguments;

const [error, setError] = useState<string | null>(null);
Expand All @@ -40,7 +43,6 @@ export function FunctionEditorModal<T>(props: ModalProps<FunctionEditorModalProp
},
[checkFunction, submit],
);

return (
<Modal
className="modal-xl"
Expand All @@ -57,6 +59,7 @@ export function FunctionEditorModal<T>(props: ModalProps<FunctionEditorModalProp
{error && <p className="text-danger text-center">{error}</p>}
<Editor
height="40vh"
theme={getAppliedTheme(theme) === "light" ? "light" : "vs-dark"}
defaultLanguage="javascript"
value={code || ""}
onChange={(e) => {
Expand Down

0 comments on commit cb19e01

Please sign in to comment.