From b7e4c13da44364df659cc35530c15ea0e665f772 Mon Sep 17 00:00:00 2001 From: nobleknightt <60701544+nobleknightt@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:37:58 +0530 Subject: [PATCH] feat: adapt color theme to browser's theme --- public/favicon.ico | Bin 15406 -> 15406 bytes src/App.jsx | 84 +++++++++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 33 deletions(-) diff --git a/public/favicon.ico b/public/favicon.ico index 701556e4432b8124b17f940b34f819b1f141528c..8029b16ec2ad5bc419433c6097ef6aee1779dcf7 100644 GIT binary patch literal 15406 zcmeHOd$3nk6+Tx`q)bF5ON+piY@8CP%$!W}F=d&PmJjk#mY7;2DKTm~M)}~WD2P`s zUJ&JRAEs%dXx0@{^KIf4gnKWfj58EE!!QgDzp=CWzP>2 zYkh0&wbx#2?{kx+AsLYDw_k#CL~_Z%Bsn@sk`W{9^ASUnWFhKCk9O}zCCRhHlH>@q zK^OF}^(gxOH6+RME*aC>BaLl6vL4s2wr*UwXWjCybc`X=fQCS0@A-d2(zaO!FYlJ7 z-#jPjg^#Cl-eV#YSEbUtPNc0T#l=$6MeC#~nJO1GOp|kxDY6Htu72X5w&A;Ex_pN)ZhTRiK70%MO;2Ut*&-*krE=PXBA>n6 zv;jSlGyWjb4h)w)sr}{O=zq*I$b0mXG$r3d=7}_~1y;ig{80XY{HBWx0Kd6wY~8J| zip*P+rqsv$PH7x~_vA5owdK+7`ja1VAAE8yuU54Oa+#;c!^^^}D)mUfZ8eaF5| zXL8E@)JG~`SPc50*A9L1;1XJ$oyfTu3-&*BKHJ#7j{dHRPsuLI z{t?q3?;L+mL*$%Ctj-Qw5aS1}UDrIFt|$Kn;9vYE-)kGI3(`5E)xJOaKE;@|Tfg89 zY20&0YWn~D&%t}6!&H_)Cqr+y`aS>Ate+X1)}9nLDPz96T+H|#fOdDdF(Tg<(D+8X z#l9DKG){U|NxL<19DDUEW-(Byrj_;tW@$I|`rmo+U1}ZD!v*RmEk-SRbO&_Gst0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ff --git a/src/App.jsx b/src/App.jsx index 9ff6dd7..928eed1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,10 +1,10 @@ -import { useEffect, useRef, useState } from 'react'; -import Editor, { loader } from '@monaco-editor/react'; -import clearIcon from "./assets/images/clear.png"; -import outputIcon from "./assets/images/output.png"; -import pythonIcon from "./assets/images/python.png"; -import runIcon from "./assets/images/run.png"; -// import oneDarkProTheme from './assets/themes/OneDark-Pro.json'; +import { useEffect, useRef, useState } from "react"; +import Editor, { loader } from "@monaco-editor/react"; +// import clearIcon from "./assets/images/clear.png"; +// import outputIcon from "./assets/images/output.png"; +// import pythonIcon from "./assets/images/python.png"; +// import runIcon from "./assets/images/run.png"; +// import oneDarkProTheme from "./assets/themes/OneDark-Pro.json"; export default function App() { const editorRef = useRef(null); @@ -14,7 +14,7 @@ export default function App() { async function ping() { setReady(false); try { - await fetch(`${import.meta.env.VITE_API_URL}/ping`, {method: "GET"}); + await fetch(`${import.meta.env.VITE_API_URL}/ping`, { method: "GET" }); setReady(true); } catch (error) { console.error(error) @@ -29,8 +29,8 @@ export default function App() { // useEffect(() => { // loader.init().then((monaco) => { - // monaco.editor.defineTheme('one-dark-pro', { - // base: 'vs-dark', + // monaco.editor.defineTheme("one-dark-pro", { + // base: "vs-dark", // inherit: true, // rules: oneDarkProTheme.tokenColors, // colors: oneDarkProTheme.colors, @@ -40,8 +40,15 @@ export default function App() { function handleEditorDidMount(editor, monaco) { editorRef.current = editor; - editorRef.current.updateOptions({ theme: "vs" }); - // editorRef.current.updateOptions({ theme: "vs-dark" }); + + const isDarkTheme = window.matchMedia("(prefers-color-scheme: dark)").matches; + editorRef.current.updateOptions({ theme: isDarkTheme ? "vs-dark" : "vs" }); + + window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", event => { + const newTheme = event.matches ? "vs-dark" : "vs"; + editorRef.current.updateOptions({ theme: newTheme }); + }); + // editorRef.current.updateOptions({ theme: "one-dark-pro" }); } @@ -50,7 +57,7 @@ export default function App() { try { const response = await fetch( - `${import.meta.env.VITE_API_URL}/execute`, + `${import.meta.env.VITE_API_URL}/execute`, { method: "POST", headers: { @@ -77,27 +84,33 @@ export default function App() { } return ( -
+
-
-
- - Python +
+
+ + + + Python
- -
-
+
-
+
- - Output + + + + + Output
-
-
-
{output}
+
+
{output}