icns-frontend/pages/_app.tsx

37 lines
997 B
TypeScript
Raw Normal View History

2022-11-30 10:36:59 +00:00
import type { AppProps } from "next/app";
2022-12-16 09:14:47 +00:00
import { useRouter } from "next/router";
import React, { useMemo } from "react";
import { DefaultTheme, ThemeProvider } from "styled-components";
2022-12-14 15:39:51 +00:00
import ErrorBoundary from "../components/error-boundary";
import { GlobalStyle } from "../styles/global";
2022-12-16 09:14:47 +00:00
const homePageTheme: DefaultTheme = {
bgColor: "rgba(18, 18, 18, 1)",
bgGridColor: "rgba(51, 51, 51, 1)",
};
const defaultPageTheme: DefaultTheme = {
bgColor: "rgba(18, 18, 18, 0.8)",
bgGridColor: "rgba(51, 51, 51, 0.3)",
};
2022-11-30 08:11:45 +00:00
export default function App({ Component, pageProps }: AppProps) {
2022-12-16 09:14:47 +00:00
const router = useRouter();
const pageTheme = useMemo(() => {
return router.pathname === "/" ? homePageTheme : defaultPageTheme;
}, [router.pathname]);
return (
2022-12-16 09:14:47 +00:00
<ThemeProvider theme={pageTheme}>
<React.Fragment>
<GlobalStyle />
<ErrorBoundary>
2022-12-16 09:21:35 +00:00
<Component {...pageProps} />
</ErrorBoundary>
</React.Fragment>
</ThemeProvider>
);
2022-11-30 08:11:45 +00:00
}