Spaces:
Running
Running
fix theme system
Browse files
components/ask-ai/uploader.tsx
CHANGED
|
@@ -21,7 +21,6 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
| 21 |
import { ProjectWithCommits } from "@/actions/projects";
|
| 22 |
import { toast } from "sonner";
|
| 23 |
import Loading from "../loading";
|
| 24 |
-
// todo: implement the uploader component
|
| 25 |
|
| 26 |
export const Uploader = ({
|
| 27 |
medias,
|
|
|
|
| 21 |
import { ProjectWithCommits } from "@/actions/projects";
|
| 22 |
import { toast } from "sonner";
|
| 23 |
import Loading from "../loading";
|
|
|
|
| 24 |
|
| 25 |
export const Uploader = ({
|
| 26 |
medias,
|
components/code/index.tsx
CHANGED
|
@@ -15,8 +15,6 @@ import { cn } from "@/lib/utils";
|
|
| 15 |
import Loading from "../loading";
|
| 16 |
import { ProjectWithCommits } from "@/actions/projects";
|
| 17 |
|
| 18 |
-
// todo: while no theme setted but in dark mode, the dark theme is not setted correctly.
|
| 19 |
-
|
| 20 |
export function AppEditorCode() {
|
| 21 |
const queryClient = useQueryClient();
|
| 22 |
const { repoId } = useParams<{ repoId: string }>();
|
|
|
|
| 15 |
import Loading from "../loading";
|
| 16 |
import { ProjectWithCommits } from "@/actions/projects";
|
| 17 |
|
|
|
|
|
|
|
| 18 |
export function AppEditorCode() {
|
| 19 |
const queryClient = useQueryClient();
|
| 20 |
const { repoId } = useParams<{ repoId: string }>();
|
components/code/monaco-editor.tsx
CHANGED
|
@@ -107,6 +107,17 @@ export function AppEditorMonacoEditor({
|
|
| 107 |
};
|
| 108 |
}, []);
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
return (
|
| 111 |
<SandpackStack className="h-full!">
|
| 112 |
<FileTabs />
|
|
@@ -115,7 +126,7 @@ export function AppEditorMonacoEditor({
|
|
| 115 |
width="100%"
|
| 116 |
height="100%"
|
| 117 |
language={language}
|
| 118 |
-
theme={
|
| 119 |
key={sandpack.activeFile}
|
| 120 |
options={{
|
| 121 |
fontSize: 14,
|
|
|
|
| 107 |
};
|
| 108 |
}, []);
|
| 109 |
|
| 110 |
+
const themeEditor = useMemo(() => {
|
| 111 |
+
const isSystemDark =
|
| 112 |
+
window.matchMedia &&
|
| 113 |
+
window.matchMedia("(prefers-color-scheme: dark)").matches;
|
| 114 |
+
const effectiveTheme =
|
| 115 |
+
theme === "system" ? (isSystemDark ? "dark" : "light") : theme;
|
| 116 |
+
return effectiveTheme === "dark" ? "Night" : "NightLight";
|
| 117 |
+
}, [theme]);
|
| 118 |
+
|
| 119 |
+
console.log("++ THEME ++", theme);
|
| 120 |
+
|
| 121 |
return (
|
| 122 |
<SandpackStack className="h-full!">
|
| 123 |
<FileTabs />
|
|
|
|
| 126 |
width="100%"
|
| 127 |
height="100%"
|
| 128 |
language={language}
|
| 129 |
+
theme={themeEditor}
|
| 130 |
key={sandpack.activeFile}
|
| 131 |
options={{
|
| 132 |
fontSize: 14,
|