Stitches styles config and theme switcher logic
This commit is contained in:
@@ -1,19 +1,28 @@
|
||||
/** @jsxImportSource theme-ui */
|
||||
import "../styles/globals.css";
|
||||
import type { AppProps } from "next/app";
|
||||
import { ThemeProvider } from "theme-ui";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import { ThemeProvider } from "next-themes";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
|
||||
import { theme } from "../theme";
|
||||
import { darkTheme } from "../stitches.config";
|
||||
import Navigation from "../components/Navigation";
|
||||
|
||||
function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
|
||||
return (
|
||||
<>
|
||||
<SessionProvider session={session}>
|
||||
<ThemeProvider theme={theme}>
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="dark"
|
||||
enableSystem={false}
|
||||
value={{
|
||||
light: "light",
|
||||
dark: darkTheme.className,
|
||||
}}
|
||||
>
|
||||
<Navigation />
|
||||
<Component {...pageProps} />
|
||||
<Toaster />
|
||||
</ThemeProvider>
|
||||
</SessionProvider>
|
||||
</>
|
||||
|
||||
@@ -6,6 +6,8 @@ import Document, {
|
||||
DocumentContext,
|
||||
} from "next/document";
|
||||
|
||||
import { globalStyles, getCssText } from "../stitches.config";
|
||||
|
||||
class MyDocument extends Document {
|
||||
static async getInitialProps(ctx: DocumentContext) {
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
@@ -13,6 +15,7 @@ class MyDocument extends Document {
|
||||
return initialProps;
|
||||
}
|
||||
render() {
|
||||
globalStyles();
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
@@ -28,6 +31,10 @@ class MyDocument extends Document {
|
||||
href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital@0;1&family=Work+Sans:wght@400;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<style
|
||||
id="stitches"
|
||||
dangerouslySetInnerHTML={{ __html: getCssText() }}
|
||||
/>
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
|
||||
Reference in New Issue
Block a user