2021-05-02 10:42:38 +08:00
|
|
|
import "../styles/globals.css";
|
2021-05-01 18:34:45 +08:00
|
|
|
import "tailwindcss/tailwind.css";
|
2021-05-02 10:42:38 +08:00
|
|
|
import React from "react";
|
|
|
|
import { GlobalSidebar } from "../components/layouts/global-sidebar";
|
|
|
|
import styles from "./_app.module.css";
|
|
|
|
import { ApolloProvider } from "@apollo/client";
|
|
|
|
import { client } from "../commons/graphql/client";
|
2021-05-01 17:33:49 +08:00
|
|
|
|
|
|
|
function MyApp({ Component, pageProps }) {
|
2021-05-01 23:10:28 +08:00
|
|
|
return (
|
2021-05-02 10:42:38 +08:00
|
|
|
<ApolloProvider client={client}>
|
|
|
|
<div className={styles.page}>
|
|
|
|
<GlobalSidebar className={styles.sidebar} />
|
|
|
|
<div className={styles.primary}>
|
|
|
|
<header className={styles.pageHeader}>
|
|
|
|
<h1>{"Ivan Li 的个人博客"}</h1>
|
|
|
|
<div className={styles.actions}>
|
|
|
|
<button onClick={() => switchTheme("light")}>亮色</button>
|
|
|
|
<button onClick={() => switchTheme("dark")}>暗色</button>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<div className={styles.wrapper}>
|
|
|
|
<Component {...pageProps} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ApolloProvider>
|
2021-05-01 23:10:28 +08:00
|
|
|
);
|
2021-05-01 17:33:49 +08:00
|
|
|
}
|
|
|
|
|
2021-05-02 10:42:38 +08:00
|
|
|
function switchTheme(mode: "light" | "dark" | "auto") {
|
|
|
|
if (mode === "auto") {
|
|
|
|
mode = "light";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode === "dark") {
|
|
|
|
document.documentElement.classList.add("dark");
|
|
|
|
} else {
|
|
|
|
document.documentElement.classList.remove("dark");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MyApp;
|