2022-12-27 10:00:53 +00:00
|
|
|
import * as React from "react";
|
2023-01-27 07:58:48 +00:00
|
|
|
|
|
|
|
import { Global } from "@emotion/react";
|
|
|
|
import { ThemeProvider } from "@mui/system";
|
2022-12-27 10:00:53 +00:00
|
|
|
import type { GatsbyBrowser } from "gatsby";
|
2023-01-27 07:58:48 +00:00
|
|
|
|
2022-12-27 10:00:53 +00:00
|
|
|
import { Layout } from "./src/components/Layout";
|
|
|
|
import { createGlobalStyle } from "./src/styles/global-styles";
|
|
|
|
import { theme } from "./src/theme/theme";
|
|
|
|
|
2023-01-27 07:58:48 +00:00
|
|
|
import "./src/styles/global-styles.css";
|
|
|
|
import "./src/styles/browser-styles.css";
|
|
|
|
|
|
|
|
const getLoaderElements = () => {
|
|
|
|
return [
|
|
|
|
document.getElementsByClassName("loader").item(0) as HTMLDivElement,
|
|
|
|
document.getElementsByClassName("loader-wrapper").item(0) as HTMLDivElement,
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const onInitialClientRender = () => {
|
|
|
|
getLoaderElements().forEach((el) => (el.style.opacity = "0"));
|
|
|
|
setTimeout(() => {
|
|
|
|
document.body.removeChild(getLoaderElements()[1]);
|
|
|
|
}, 1000);
|
|
|
|
};
|
|
|
|
|
2022-12-27 10:00:53 +00:00
|
|
|
export const wrapPageElement: GatsbyBrowser["wrapPageElement"] = ({
|
|
|
|
element,
|
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<ThemeProvider theme={theme}>
|
|
|
|
<Global styles={createGlobalStyle(theme)} />
|
|
|
|
<Layout>{element}</Layout>
|
|
|
|
</ThemeProvider>
|
|
|
|
);
|
|
|
|
};
|