Skip to content

Commit

Permalink
feat: editor theme
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Jul 18, 2024
1 parent 3219b92 commit d0d1bb7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
import React from "react";
import CodeMirror from "@uiw/react-codemirror";
import { csharp } from "@replit/codemirror-lang-csharp";
import { githubLight, githubDark } from "@uiw/codemirror-theme-github";
import { useTheme } from "next-themes";

export default function Editor() {
const { theme, systemTheme } = useTheme();

const currentTheme = theme !== "system" ? theme : systemTheme;
const editorTheme = currentTheme === "light" ? githubLight : githubDark;

const [value, setValue] = React.useState(`using System;
namespace Test
{
Expand All @@ -24,6 +31,7 @@ namespace Test
<CodeMirror
value={value}
height="1000px"
theme={editorTheme}
extensions={[csharp()]}
onChange={onChange}
/>
Expand Down
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@radix-ui/react-slot": "^1.1.0",
"@replit/codemirror-lang-csharp": "^6.2.0",
"@tanstack/react-virtual": "^3.8.3",
"@uiw/codemirror-theme-github": "^4.23.0",
"@uiw/react-codemirror": "^4.23.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand All @@ -39,5 +40,9 @@
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
},
"overrides": {
"react": "^18",
"react-dom": "^18"
}
}

0 comments on commit d0d1bb7

Please sign in to comment.