styling: improve codeeditor component styling

This commit is contained in:
SethBurkart123
2024-03-31 12:02:46 +11:00
parent 08b7698093
commit 806d2419cb
4 changed files with 35 additions and 22 deletions
+11
View File
@@ -0,0 +1,11 @@
.cm-editor {
border-radius: 8px;
}
body:not(.dark) .cm-editor {
@apply bg-zinc-200;
}
.cm-editor.cm-focused {
outline: none;
}
+19 -9
View File
@@ -1,10 +1,11 @@
import CodeMirror, { ViewUpdate } from '@uiw/react-codemirror'
import { githubDark, githubLight } from '@uiw/codemirror-theme-github'
import { color, colorView, colorTheme } from '@uiw/codemirror-extensions-color';
import { color } from '@uiw/codemirror-extensions-color';
import { less } from '@codemirror/lang-less'
import { useCallback, useEffect, useState } from 'react';
import './CodeEditor.css'
export default function CodeEditor({ callback, initialState }: { callback: (value: string) => void, initialState: string }) {
export default function CodeEditor({ callback, initialState, height }: { callback: (value: string) => void, initialState: string, height: string }) {
const [value, setValue] = useState(initialState)
const [darkMode, setDarkMode] = useState(false)
@@ -20,12 +21,21 @@ export default function CodeEditor({ callback, initialState }: { callback: (valu
}, [])
return(
<CodeMirror basicSetup={{
allowMultipleSelections: true,
lineNumbers: false,
foldGutter: false,
dropCursor: true,
tabSize: 2
}} theme={ darkMode ? githubDark : githubLight } placeholder={"It's time to dream up some code!"} value={value} height="200px" extensions={[less(), color]} onChange={onChange} />
<CodeMirror
basicSetup={{
allowMultipleSelections: true,
lineNumbers: false,
foldGutter: false,
dropCursor: true,
tabSize: 2,
}}
theme={ darkMode ? githubDark : githubLight }
placeholder={"It's time to dream up some code!"}
className='rounded-lg'
value={value}
height={height}
extensions={[less(), color]}
onChange={onChange} />
)
}