add code editor

This commit is contained in:
SethBurkart123
2024-03-31 11:37:29 +11:00
parent cfeb7ede5b
commit 0be761ce62
5 changed files with 49 additions and 20 deletions
+30
View File
@@ -0,0 +1,30 @@
import CodeMirror, { ViewUpdate } from '@uiw/react-codemirror'
import { githubDark, githubLight } from '@uiw/codemirror-theme-github'
import { less } from '@codemirror/lang-less'
import { useCallback, useEffect, useState } from 'react';
export default function CodeEditor({ callback, initialState }: { callback: (value: string) => void, initialState: string }) {
const [value, setValue] = useState(initialState)
const [darkMode, setDarkMode] = useState(true)
useEffect(() => {
if (document.body.classList.contains('dark')) {
setDarkMode(true)
}
}, [])
const onChange = useCallback((value: string, _: ViewUpdate) => {
setValue(value)
callback(value)
}, [])
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()]} onChange={onChange} />
)
}
+2
View File
@@ -7,6 +7,7 @@ import browser from 'webextension-polyfill';
import font from '../resources/fonts/IconFamily.woff'
import * as Sentry from "@sentry/react";
import ThemeCreator from './pages/ThemeCreator';
browser.storage.local.get().then(({ telemetry, DarkMode }) => {
if (DarkMode) document.body.classList.add('dark');
@@ -41,6 +42,7 @@ root.render(
<Routes>
<Route path="/settings" element={<SettingsPage standalone={true} />} />
<Route path="/settings/embedded" element={<SettingsPage standalone={false} />} />
<Route path="/themeCreator" element={<ThemeCreator />} />
</Routes>
</HashRouter>
</React.StrictMode>,
-20
View File
@@ -1,20 +0,0 @@
const About: React.FC = () => {
return (
<div className="flex flex-col overflow-y-scroll divide-y divide-zinc-100/50 dark:divide-zinc-700/50">
<div>
<h2 className="text-lg font-bold">About</h2>
<p className="py-2">BetterSEQTA+ is a branch of BetterSEQTA which was originally developed by Nulkem. It was discontinued. So BetterSEQTA+ has come in to fill in that gap!</p>
<p className="py-2">We are currently working on fixing bugs and adding new features. If you want to request a feature or report a bug, you can do so on
<a className="pl-1 text-blue-500 underline hover:text-blue-600" href="https://github.com/BetterSEQTA/BetterSEQTA-Plus" target="_blank">Github</a>.
</p>
</div>
<div>
<h2 className="pt-2 text-lg font-bold">Credits</h2>
<p className="py-2">Nulkem for the original extension, OG-RandomTechChannel, Crazypersonalph, and the current maintainer BetterSEQTA</p>
</div>
</div>
);
};
export default About;
+14
View File
@@ -0,0 +1,14 @@
import CodeEditor from '../components/CodeEditor';
export default function ThemeCreator() {
const handleSave = (value: string) => {
// Save the theme
console.log(value)
}
return (
<div className='w-full h-full'>
<CodeEditor initialState={'.hi {}'} callback={handleSave} />
</div>
);
}