✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
fix: theme color
AykutSaracc6147418d996
diff --git a/src/layout/EditorWrapper/index.tsx b/src/layout/EditorWrapper/index.tsxindex 8a46a5e4..70ffd305 100644--- a/src/layout/EditorWrapper/index.tsx+++ b/src/layout/EditorWrapper/index.tsx@@ -1,6 +1,6 @@import React from "react";import dynamic from "next/dynamic";-import { MantineProvider } from "@mantine/core";+import { MantineProvider, useMantineColorScheme } from "@mantine/core";import { ThemeProvider } from "styled-components";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { lightTheme, darkTheme } from "src/constants/theme";@@ -20,8 +20,13 @@ const queryClient = new QueryClient({export const EditorWrapper: React.FC<{children: React.ReactNode;}> = ({ children }) => {+ const { setColorScheme } = useMantineColorScheme();const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);+ React.useEffect(() => {+ if (darkmodeEnabled) setColorScheme("dark");+ }, [darkmodeEnabled, setColorScheme]);+return (<ThemeProvider theme={darkmodeEnabled ? darkTheme : lightTheme}><MantineProvider forceColorScheme={darkmodeEnabled ? "dark" : "light"}>diff --git a/src/pages/widget.tsx b/src/pages/widget.tsxindex 42e6f600..7fc5ff9d 100644--- a/src/pages/widget.tsx+++ b/src/pages/widget.tsx@@ -2,7 +2,7 @@ import React from "react";import dynamic from "next/dynamic";import Head from "next/head";import { useRouter } from "next/router";-import { MantineProvider } from "@mantine/core";+import { MantineProvider, useMantineColorScheme } from "@mantine/core";import { ThemeProvider } from "styled-components";import toast from "react-hot-toast";import { darkTheme, lightTheme } from "src/constants/theme";@@ -23,6 +23,7 @@ const Graph = dynamic(() => import("src/containers/Views/GraphView").then(c => cconst WidgetPage = () => {const { query, push, isReady } = useRouter();+ const { setColorScheme } = useMantineColorScheme();const [theme, setTheme] = React.useState<"dark" | "light">("dark");const checkEditorSession = useFile(state => state.checkEditorSession);const setContents = useFile(state => state.setContents);@@ -42,6 +43,7 @@ const WidgetPage = () => {try {if (!event.data?.json) return;if (event.data?.options?.theme === "light" || event.data?.options?.theme === "dark") {+ setColorScheme(event.data.options.theme);setTheme(event.data.options.theme);}@@ -55,7 +57,7 @@ const WidgetPage = () => {window.addEventListener("message", handler);return () => window.removeEventListener("message", handler);- }, [setContents, setDirection, theme]);+ }, [setColorScheme, setContents, setDirection, theme]);return (<MantineProvider forceColorScheme={theme}>