|
@@ -10,16 +10,18 @@ import App from 'next/app';
|
|
|
import { useState } from "react";
|
|
import { useState } from "react";
|
|
|
import "@fontsource/roboto";
|
|
import "@fontsource/roboto";
|
|
|
import {
|
|
import {
|
|
|
- CssBaseline, FormGroup,
|
|
|
|
|
|
|
+ CssBaseline, FormGroup, ToggleButton,
|
|
|
} from "@mui/material";
|
|
} from "@mui/material";
|
|
|
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
|
import Grid from "@material-ui/core/Grid";
|
|
import Grid from "@material-ui/core/Grid";
|
|
|
import { makeStyles } from "@material-ui/core";
|
|
import { makeStyles } from "@material-ui/core";
|
|
|
import { useTheme } from "@material-ui/core/styles";
|
|
import { useTheme } from "@material-ui/core/styles";
|
|
|
import useMediaQuery from "@material-ui/core/useMediaQuery";
|
|
import useMediaQuery from "@material-ui/core/useMediaQuery";
|
|
|
-import { withTheme } from "../components/light_dark";
|
|
|
|
|
-import FormControlLabel from "@material-ui/core/FormControlLabel";
|
|
|
|
|
-import Switch from "@material-ui/core/Switch";
|
|
|
|
|
|
|
+import dynamic from 'next/dynamic';
|
|
|
|
|
+import styled from '@emotion/styled';
|
|
|
|
|
+const toggleTheme = dynamic(() => import("../components/light_dark"),{
|
|
|
|
|
+ ssr:false
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
const useStyles = makeStyles((theme) => ({
|
|
|
root: {
|
|
root: {
|
|
@@ -35,7 +37,6 @@ const DynamicComponentWithNoSSR = <>Some JSX</>
|
|
|
// Client-side cache, shared for the whole session of the user in the browser.
|
|
// Client-side cache, shared for the whole session of the user in the browser.
|
|
|
const clientSideEmotionCache = createEmotionCache();
|
|
const clientSideEmotionCache = createEmotionCache();
|
|
|
function MyApp(props) {
|
|
function MyApp(props) {
|
|
|
- const { darkMode, setDarkMode } = props;
|
|
|
|
|
const classes = useStyles();
|
|
const classes = useStyles();
|
|
|
const Theme = useTheme();
|
|
const Theme = useTheme();
|
|
|
const matches = useMediaQuery(theme.breakpoints.down("xs"));
|
|
const matches = useMediaQuery(theme.breakpoints.down("xs"));
|
|
@@ -47,7 +48,6 @@ function MyApp(props) {
|
|
|
console.log('You are on the server')
|
|
console.log('You are on the server')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<CacheProvider value={emotionCache}>
|
|
<CacheProvider value={emotionCache}>
|
|
@@ -59,16 +59,7 @@ return (
|
|
|
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
|
|
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
|
|
|
<CssBaseline />
|
|
<CssBaseline />
|
|
|
<Component {...pageProps} />
|
|
<Component {...pageProps} />
|
|
|
- <FormGroup>
|
|
|
|
|
- <FormControlLabel
|
|
|
|
|
- control={
|
|
|
|
|
- <Switch
|
|
|
|
|
- checked={theme}
|
|
|
|
|
- onChange={() => withTheme(!theme)} />
|
|
|
|
|
- }
|
|
|
|
|
- label="Dark Mode"
|
|
|
|
|
- />
|
|
|
|
|
- </FormGroup>
|
|
|
|
|
|
|
+ <toggleTheme/>
|
|
|
</ThemeProvider>
|
|
</ThemeProvider>
|
|
|
</Layout>
|
|
</Layout>
|
|
|
</CacheProvider>
|
|
</CacheProvider>
|
|
@@ -82,4 +73,4 @@ MyApp.propTypes = {
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-export default withTheme(MyApp);
|
|
|
|
|
|
|
+export default MyApp;
|