Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

fix: widget color scheme

AykutSaraca11089e1cf6a
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx
index b26b4d90..d0e34a3d 100644
--- a/src/pages/_document.tsx
+++ b/src/pages/_document.tsx
@@ -58,7 +58,7 @@ class MyDocument extends Document {
<meta property="twitter:url" content="https://jsoncrack.com" key="twurl" />
<meta name="twitter:title" content={metatags.title} key="twtitle" />
<meta name="twitter:image" content={metatags.image} key="twimage" />
- <ColorSchemeScript defaultColorScheme="light" />
+ <ColorSchemeScript />
</Head>
<body>
<Main />
diff --git a/src/pages/widget.tsx b/src/pages/widget.tsx
index 64bfb67a..03052d01 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, useMantineColorScheme } from "@mantine/core";
+import { useMantineColorScheme } from "@mantine/core";
import { ThemeProvider } from "styled-components";
import toast from "react-hot-toast";
import { darkTheme, lightTheme } from "src/constants/theme";
@@ -47,7 +47,6 @@ 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);
}
@@ -63,16 +62,18 @@ const WidgetPage = () => {
return () => window.removeEventListener("message", handler);
}, [setColorScheme, setContents, setDirection, theme]);
+ React.useEffect(() => {
+ setColorScheme(theme);
+ }, [setColorScheme, theme]);
+
return (
<>
<Head>
<meta name="robots" content="noindex,nofollow" />
</Head>
<ThemeProvider theme={theme === "dark" ? darkTheme : lightTheme}>
- <MantineProvider defaultColorScheme={theme}>
- <Toolbar isWidget />
- <Graph isWidget />
- </MantineProvider>
+ <Toolbar isWidget />
+ <Graph isWidget />
</ThemeProvider>
</>
);