mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +08:00
fix: widget color scheme
This commit is contained in:
parent
72236c08d6
commit
a11089e1cf
@ -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 />
|
||||
|
@ -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>
|
||||
</>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user