move RichCodeEditor to its own component

This commit is contained in:
Athou
2023-06-22 18:39:29 +02:00
parent 90e3044249
commit c1520652f2
2 changed files with 106 additions and 94 deletions

View File

@@ -0,0 +1,27 @@
import { useMantineTheme } from "@mantine/core"
import { Editor } from "@monaco-editor/react"
interface RichCodeEditorProps {
height: number | string
language: "css" | "javascript"
value: string
onChange: (value: string | undefined) => void
}
function RichCodeEditor(props: RichCodeEditorProps) {
const theme = useMantineTheme()
const editorTheme = theme.colorScheme === "dark" ? "vs-dark" : "light"
return (
<Editor
height={props.height}
defaultLanguage={props.language}
theme={editorTheme}
options={{ minimap: { enabled: false } }}
value={props.value}
onChange={props.onChange}
/>
)
}
export default RichCodeEditor