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: color scheme mantine

AykutSarac72236c08d6b6
diff --git a/src/components/Loading/index.tsx b/src/components/Loading/index.tsx
index d489d877..34dab96c 100644
--- a/src/components/Loading/index.tsx
+++ b/src/components/Loading/index.tsx
@@ -8,7 +8,7 @@ export const Loading = () => {
React.useEffect(() => {
const handleStart = (url: string) => {
- return url !== router.asPath && url === "/editor" && setLoading(true);
+ return url !== router.asPath && (url === "/editor" || url === "/widget") && setLoading(true);
};
const handleComplete = (url: string) => url === router.asPath && setLoading(false);
diff --git a/src/layout/Layout/index.tsx b/src/layout/Layout/index.tsx
index d0697c41..a411bebe 100644
--- a/src/layout/Layout/index.tsx
+++ b/src/layout/Layout/index.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { MantineProvider } from "@mantine/core";
+import { useMantineColorScheme } from "@mantine/core";
import styled, { ThemeProvider } from "styled-components";
import { lightTheme } from "src/constants/theme";
import { Footer } from "../Footer";
@@ -10,17 +10,21 @@ const StyledLayoutWrapper = styled.div`
`;
const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
+ const { setColorScheme } = useMantineColorScheme();
+
+ React.useEffect(() => {
+ setColorScheme("light");
+ }, [setColorScheme]);
+
return (
<React.Suspense>
- <MantineProvider forceColorScheme="light">
- <ThemeProvider theme={lightTheme}>
- <StyledLayoutWrapper>
- <Navbar />
- {children}
- <Footer />
- </StyledLayoutWrapper>
- </ThemeProvider>
- </MantineProvider>
+ <ThemeProvider theme={lightTheme}>
+ <StyledLayoutWrapper>
+ <Navbar />
+ {children}
+ <Footer />
+ </StyledLayoutWrapper>
+ </ThemeProvider>
</React.Suspense>
);
};
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx
index 0e1efa0e..b26b4d90 100644
--- a/src/pages/_document.tsx
+++ b/src/pages/_document.tsx
@@ -6,6 +6,7 @@ import Document, {
DocumentContext,
DocumentInitialProps,
} from "next/document";
+import { ColorSchemeScript } from "@mantine/core";
import { ServerStyleSheet } from "styled-components";
const metatags = Object.freeze({
@@ -57,6 +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" />
</Head>
<body>
<Main />
diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx
index 78f738ba..3c3cdb63 100644
--- a/src/pages/editor.tsx
+++ b/src/pages/editor.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 { useMantineColorScheme } from "@mantine/core";
import styled, { ThemeProvider } from "styled-components";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { darkTheme, lightTheme } from "src/constants/theme";
@@ -41,6 +41,7 @@ export const StyledEditorWrapper = styled.div`
const EditorPage: React.FC = () => {
const { query, isReady } = useRouter();
+ const { setColorScheme } = useMantineColorScheme();
const checkEditorSession = useFile(state => state.checkEditorSession);
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
@@ -48,6 +49,10 @@ const EditorPage: React.FC = () => {
if (isReady) checkEditorSession(query?.json);
}, [checkEditorSession, isReady, query]);
+ React.useEffect(() => {
+ setColorScheme(darkmodeEnabled ? "dark" : "light");
+ }, [darkmodeEnabled, setColorScheme]);
+
return (
<>
<Head>
@@ -55,21 +60,19 @@ const EditorPage: React.FC = () => {
<link rel="canonical" href="https://jsoncrack.com/editor" />
</Head>
<ThemeProvider theme={darkmodeEnabled ? darkTheme : lightTheme}>
- <MantineProvider forceColorScheme={darkmodeEnabled ? "dark" : "light"}>
- <QueryClientProvider client={queryClient}>
- <ExternalMode />
- <ModalController />
- <StyledEditorWrapper>
- <StyledPageWrapper>
- <Toolbar />
- <StyledEditorWrapper>
- <Panes />
- </StyledEditorWrapper>
- </StyledPageWrapper>
- <BottomBar />
- </StyledEditorWrapper>
- </QueryClientProvider>
- </MantineProvider>
+ <QueryClientProvider client={queryClient}>
+ <ExternalMode />
+ <ModalController />
+ <StyledEditorWrapper>
+ <StyledPageWrapper>
+ <Toolbar />
+ <StyledEditorWrapper>
+ <Panes />
+ </StyledEditorWrapper>
+ </StyledPageWrapper>
+ <BottomBar />
+ </StyledEditorWrapper>
+ </QueryClientProvider>
</ThemeProvider>
</>
);
diff --git a/src/pages/widget.tsx b/src/pages/widget.tsx
index eed1a4d6..64bfb67a 100644
--- a/src/pages/widget.tsx
+++ b/src/pages/widget.tsx
@@ -37,6 +37,7 @@ const WidgetPage = () => {
if (isReady) {
if (typeof query?.json === "string") checkEditorSession(query.json, true);
else clearGraph();
+
window.parent.postMessage(window.frameElement?.getAttribute("id"), "*");
}
}, [clearGraph, checkEditorSession, isReady, push, query.json, query.partner]);