diff --git a/assets/theme.svg b/assets/theme.svg new file mode 100644 index 0000000..f2f31ac --- /dev/null +++ b/assets/theme.svg @@ -0,0 +1,41 @@ + + + \ No newline at end of file diff --git a/src/renderer/Editor.css b/src/renderer/Editor.css index 1545e40..9ccd9ec 100644 --- a/src/renderer/Editor.css +++ b/src/renderer/Editor.css @@ -92,6 +92,8 @@ .Editor-toolbar img { width: 100%; height: 100%; + width: 20px; + height: 20px; transition: filter 0.25s; /* Fix other filter variables so transition is directly from black to blue: */ filter: invert(0%) sepia(100%) hue-rotate(180deg) saturate(0); diff --git a/src/renderer/Editor.tsx b/src/renderer/Editor.tsx index 4af4d76..427c786 100644 --- a/src/renderer/Editor.tsx +++ b/src/renderer/Editor.tsx @@ -15,6 +15,17 @@ import zoomOutSvg from '../../assets/zoom-out.svg'; import startRobot from '../../assets/start-robot.svg'; import stopRobot from '../../assets/stop-robot.svg'; import keyboardKeySvg from '../../assets/keyboard-key.svg'; +import themeSvg from '../../assets/theme.svg'; + +import 'ace-builds/src-noconflict/theme-chrome'; +import 'ace-builds/src-noconflict/theme-clouds'; +import 'ace-builds/src-noconflict/theme-dawn'; +import 'ace-builds/src-noconflict/theme-dreamweaver'; +import 'ace-builds/src-noconflict/theme-monokai'; +import 'ace-builds/src-noconflict/theme-tomorrow_night'; +import 'ace-builds/src-noconflict/theme-clouds_midnight'; +import 'ace-builds/src-noconflict/theme-ambiance'; + import './Editor.css'; /** @@ -38,6 +49,7 @@ const STATUS_TOOLTIPS: { [k in EditorContentStatus]: string } = { extDirty: 'The code that will be uploaded to the robot was last changed in an external program.', }; + /** * Content of the editor status indicator (next to the file name). */ @@ -47,6 +59,20 @@ const STATUS_TEXT: { [k in EditorContentStatus]: string } = { extDirty: 'Externally modified', }; +/** + * Color themes for the ACE code editor. + */ +const ACE_THEMES = { + dawn: 'Dawn', + chrome: 'Chrome', + clouds: 'Clouds', + dreamweaver: 'Dreamweaver', + monokai: 'Monokai', + tomorrow_night: 'Tomorrow Night', + clouds_midnight: 'Clouds Midnight', + ambiance: 'Ambiance', +}; + /** * Component holding the Ace editor and editor toolbar. * @param props - props @@ -141,6 +167,12 @@ export default function Editor({ setFontSize((old) => old + (increase ? 1 : -1)); }; + const [theme, setTheme] = useState('dawn'); // Default theme + const handleThemeChange = (newTheme: string) => { + const cleanTheme = newTheme.replace('ace/theme/', ''); + setTheme(cleanTheme); + }; + return (
+