import "../styles/globals.css";
import "tailwindcss/tailwind.css";
import React from "react";
import { GlobalSidebar } from "../components/layouts/global-sidebar";
import styles from "./_app.module.css";
import { ApolloProvider } from "@apollo/client";
import { useApollo } from "../commons/graphql/client";
import { ThemeProvider, useTheme } from '../commons/theme';
import { SwitchTheme } from "../components/switch-theme";

function MyApp({ Component, pageProps }) {
  const apolloClient = useApollo(pageProps);
  return (
    <ApolloProvider client={apolloClient}>
      <ThemeProvider>
        <div className={styles.page}>
          <GlobalSidebar className={styles.sidebar} />
          <div className={styles.primary}>
            <header className={styles.pageHeader}>
              <h1>{"Ivan Li 的个人博客"}</h1>
              <div className={styles.actions}>
                <SwitchTheme />
              </div>
            </header>
            <div className={styles.wrapper}>
              <Component {...pageProps} />
            </div>
          </div>
        </div>
      </ThemeProvider>
    </ApolloProvider>
  );
}

export default MyApp;
