Skip to content

Commit f360343

Browse files
committed
Add background image and update Editor theme
- Introduced a background image in the main application layout for enhanced visual appeal. - Updated the Editor component to use a transparent theme for improved aesthetics. - Cleaned up the App component by removing unnecessary padding in the editor container.
1 parent 8ad4434 commit f360343

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

src/app/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const App = () => {
4545
<div className="flex flex-col h-screen w-full p-4 gap-4">
4646
<NavBar />
4747
<div className="flex-1 w-full min-h-0 flex gap-4">
48-
<div className="w-[60%] rounded-lg overflow-hidden border p-1">
48+
<div className="w-[60%] rounded-lg overflow-hidden border">
4949
<Suspense fallback={<div>Loading...</div>}>
5050
<Editor />
5151
</Suspense>

src/assets/background.png

4.8 MB
Loading

src/components/Editor.tsx

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,79 @@
1+
import * as monaco from "monaco-editor";
12
import { useState, useEffect, useRef, Suspense, SetStateAction } from "react";
23
import MonacoEditor from "@monaco-editor/react";
34

45
import languageToSyntax from "../assets/mapLanguageToSyntax.json";
56
import { useAppSettings, useCodeEditor } from "@/store/store";
67
import { useTheme } from "@/context/ThemeProvider";
8+
import { loader } from "@monaco-editor/react";
9+
10+
loader.config({ monaco });
11+
12+
monaco.editor.defineTheme("transparent", {
13+
base: "vs-dark",
14+
inherit: true,
15+
rules: [
16+
{
17+
background: "00000000",
18+
} as any,
19+
{
20+
token: "comment",
21+
foreground: "6a9955",
22+
},
23+
{
24+
token: "string",
25+
foreground: "ce9178",
26+
},
27+
{
28+
token: "number",
29+
foreground: "b5cea8",
30+
},
31+
{
32+
token: "keyword",
33+
foreground: "569cd6",
34+
},
35+
{
36+
token: "type",
37+
foreground: "4ec9b0",
38+
},
39+
{
40+
token: "delimiter",
41+
foreground: "d4d4d4",
42+
},
43+
{
44+
token: "tag",
45+
foreground: "569cd6",
46+
},
47+
{
48+
token: "attribute.name",
49+
foreground: "9cdcfe",
50+
},
51+
{
52+
token: "attribute.value",
53+
foreground: "ce9178",
54+
},
55+
{
56+
token: "operator",
57+
foreground: "d4d4d4",
58+
},
59+
],
60+
colors: {
61+
"editor.background": "#00000000",
62+
"editor.foreground": "#d4d4d4",
63+
"editor.lineHighlightBackground": "#ffffff1a",
64+
"editorCursor.foreground": "#d4d4d4",
65+
"editorWhitespace.foreground": "#ffffff1a",
66+
"editorIndentGuide.background": "#ffffff1a",
67+
"editorIndentGuide.activeBackground": "#ffffff33",
68+
"editor.selectionBackground": "#264f78",
69+
70+
"minimap.background": "#00000000",
71+
"minimap.selectionHighlight": "#264f7880",
72+
"minimapSlider.background": "#ffffff20",
73+
"minimapSlider.hoverBackground": "#ffffff33",
74+
"minimapSlider.activeBackground": "#ffffff44",
75+
},
76+
});
777

878
const Editor = () => {
979
const { resolvedTheme: theme } = useTheme();
@@ -22,9 +92,9 @@ const Editor = () => {
2292
const resizeObserver = useRef<ResizeObserver | null>(null);
2393
const [editorOptions, setEditorOptions] = useState({});
2494
const execute = useCodeEditor((s) => s.execute);
25-
const code = useCodeEditor(s => s.code);
26-
const language = useCodeEditor(s => s.language);
27-
const setCode = useCodeEditor(s => s.setCode);
95+
const code = useCodeEditor((s) => s.code);
96+
const language = useCodeEditor((s) => s.language);
97+
const setCode = useCodeEditor((s) => s.setCode);
2898

2999
const editorDidMount = (editor: any, monaco: any) => {
30100
editor.onKeyDown((event: any) => {
@@ -104,9 +174,11 @@ const Editor = () => {
104174
language={
105175
languageToSyntax[language as keyof typeof languageToSyntax]
106176
}
107-
theme={`vs-${theme}`}
177+
theme={`transparent`}
108178
value={code}
109-
options={editorOptions}
179+
options={{
180+
...editorOptions,
181+
}}
110182
onChange={(newCode, event) => {
111183
setCode(newCode ?? "");
112184
}}

src/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ import { HashRouter, Routes, Route } from "react-router";
55
import App from "./app/App";
66
import { Toaster } from "./components/ui/sonner";
77
import { ThemeProvider } from "./context/ThemeProvider";
8+
import BGImage from "@/assets/background.png";
89

910
createRoot(document.getElementById("root")!).render(
1011
<ThemeProvider>
12+
<div className="h-screen w-screen absolute left-0 top-0 -z-10 overflow-hidden">
13+
<img
14+
className="absolute left-0 right-0 top-0 bottom-0 bg-cover -z-10"
15+
src={BGImage}
16+
alt="background-image"
17+
/>
18+
</div>
1119
<HashRouter>
1220
<Routes>
1321
<Route index element={<App />} />

0 commit comments

Comments
 (0)