generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
'use client'; | ||
|
||
import { ThemeProvider } from 'next-themes'; | ||
import type { PropsWithChildren } from 'react'; | ||
import {ThemeProvider as NextThemeProvider, } from 'next-themes'; | ||
import type {PropsWithChildren} from 'react'; | ||
|
||
import MuiThemeProvider from "@/components/helpers/MuiThemeProvider"; | ||
import Footer from '@/components/layout/Footer'; | ||
import Header from '@/components/layout/Header'; | ||
|
||
export default function LayoutClient({ children }: PropsWithChildren) { | ||
export default function LayoutClient({children}: PropsWithChildren) { | ||
|
||
return ( | ||
<ThemeProvider attribute='class' defaultTheme='light' enableSystem={false}> | ||
<Header /> | ||
<NextThemeProvider attribute='class' defaultTheme='light' enableSystem={false}> | ||
<MuiThemeProvider > | ||
|
||
<Header/> | ||
|
||
<main id='content'>{children}</main> | ||
<main id='content'>{children}</main> | ||
|
||
<Footer /> | ||
</ThemeProvider> | ||
<Footer/> | ||
</MuiThemeProvider> | ||
</NextThemeProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { GlobalStyles } from "@mui/material"; | ||
import { CssBaseline, ThemeProvider } from "@mui/material"; | ||
import { useTheme } from "next-themes"; | ||
import { FC, useEffect, useState } from "react"; | ||
|
||
import { darkTheme, globalStyles, lightTheme } from "@/theme"; | ||
|
||
const MUIThemeProvider: FC<{ children: React.ReactNode }> = ({ | ||
children, | ||
}) => { | ||
const { resolvedTheme } = useTheme(); | ||
const [currentTheme, setCurrentTheme] = useState(lightTheme); | ||
|
||
useEffect(() => { | ||
resolvedTheme === "light" | ||
? setCurrentTheme(lightTheme) | ||
: setCurrentTheme(darkTheme); | ||
}, [resolvedTheme]); | ||
|
||
return ( | ||
<ThemeProvider theme={currentTheme}> | ||
<CssBaseline /> | ||
<GlobalStyles styles={globalStyles} /> | ||
{children} | ||
</ThemeProvider> | ||
); | ||
}; | ||
|
||
export default MUIThemeProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import createCache from "@emotion/cache"; | ||
|
||
// prepend: true moves MUI styles to the top of the <head> so they're loaded first. | ||
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules. | ||
export default function createEmotionCache() { | ||
return createCache({ key: "css", prepend: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createTheme, css, PaletteOptions } from "@mui/material/styles"; | ||
|
||
export type AllowedTheme = NonNullable<PaletteOptions["mode"]>; | ||
|
||
export const DEFAULT_THEME: AllowedTheme = "light"; | ||
|
||
export const lightTheme = createTheme({ | ||
palette: { | ||
primary: { main: "#9147FF" }, | ||
secondary: { main: "#2a48f3" }, | ||
mode: "light", | ||
}, | ||
}); | ||
|
||
export const darkTheme = createTheme({ | ||
palette: { | ||
primary: { main: "#9147FF" }, | ||
secondary: { main: "#2a48f3" }, | ||
mode: "dark", | ||
}, | ||
}); | ||
|
||
export const globalStyles = css` | ||
//:root { | ||
// body { | ||
// background-color: #fff; | ||
// color: #121212; | ||
// } | ||
//} | ||
// | ||
//[data-theme="dark"] { | ||
// body { | ||
// background-color: #121212; | ||
// color: #fff; | ||
// } | ||
//} | ||
`; |