Added dark and light theme swithcing for code editor
This commit is contained in:
@@ -5,7 +5,8 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogContent
|
DialogContent,
|
||||||
|
Typography
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
|
|
||||||
import Checkbox from '@mui/material/Checkbox';
|
import Checkbox from '@mui/material/Checkbox';
|
||||||
@@ -26,6 +27,7 @@ import ReactJson from "react-json-view";
|
|||||||
import CodeMirror from '@uiw/react-codemirror';
|
import CodeMirror from '@uiw/react-codemirror';
|
||||||
import 'codemirror/keymap/sublime';
|
import 'codemirror/keymap/sublime';
|
||||||
import 'codemirror/theme/gruvbox-dark.css';
|
import 'codemirror/theme/gruvbox-dark.css';
|
||||||
|
import 'codemirror/theme/duotone-light.css';
|
||||||
|
|
||||||
const CodeEditor = (props) => {
|
const CodeEditor = (props) => {
|
||||||
const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata } = props
|
const { fieldCount, setFieldCount, actionlist, changeActionParameterCodeMirror, expansionModalOpen, setExpansionModalOpen, codedata, setcodedata } = props
|
||||||
@@ -35,6 +37,7 @@ const CodeEditor = (props) => {
|
|||||||
const [validation, setValidation] = React.useState(false);
|
const [validation, setValidation] = React.useState(false);
|
||||||
const [expOutput, setExpOutput] = React.useState(" ");
|
const [expOutput, setExpOutput] = React.useState(" ");
|
||||||
const [linewrap, setlinewrap] = React.useState(true);
|
const [linewrap, setlinewrap] = React.useState(true);
|
||||||
|
const [codeTheme, setcodeTheme] = React.useState("gruvbox-dark");
|
||||||
|
|
||||||
const autoFormat = (input) => {
|
const autoFormat = (input) => {
|
||||||
if (validation !== true) {
|
if (validation !== true) {
|
||||||
@@ -148,7 +151,7 @@ const CodeEditor = (props) => {
|
|||||||
expectedOutput(value.getValue())
|
expectedOutput(value.getValue())
|
||||||
}}
|
}}
|
||||||
options={{
|
options={{
|
||||||
theme: 'gruvbox-dark',
|
theme: codeTheme,
|
||||||
keyMap: 'sublime',
|
keyMap: 'sublime',
|
||||||
mode: 'javascript',
|
mode: 'javascript',
|
||||||
lineWrapping: linewrap,
|
lineWrapping: linewrap,
|
||||||
@@ -162,12 +165,13 @@ const CodeEditor = (props) => {
|
|||||||
marginBottom: -30,
|
marginBottom: -30,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p
|
<Typography
|
||||||
|
variant = 'body2'
|
||||||
|
color = 'textSecondary'
|
||||||
style={{
|
style={{
|
||||||
color: "white",
|
color: "white",
|
||||||
fontFamily: "monospace",
|
paddingLeft: 360,
|
||||||
paddingLeft: 480,
|
width: 50,
|
||||||
width: 100,
|
|
||||||
display: 'inline',
|
display: 'inline',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -190,7 +194,39 @@ const CodeEditor = (props) => {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</p>
|
</Typography>
|
||||||
|
|
||||||
|
<Typography
|
||||||
|
variant = 'body2'
|
||||||
|
color = 'textSecondary'
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
paddingLeft: 10,
|
||||||
|
width: 100,
|
||||||
|
display: 'inline',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Dark Theme
|
||||||
|
<Checkbox
|
||||||
|
onClick={() => {
|
||||||
|
if (codeTheme == "gruvbox-dark") {
|
||||||
|
setcodeTheme("duotone-light")
|
||||||
|
}
|
||||||
|
if (codeTheme == "duotone-light"){
|
||||||
|
setcodeTheme("gruvbox-dark")
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
defaultChecked
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
color: orange[600],
|
||||||
|
'&.Mui-checked': {
|
||||||
|
color: orange[800],
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Typography>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user