Skip to content

Commit

Permalink
feat: add theme provider to app
Browse files Browse the repository at this point in the history
  • Loading branch information
jonyw4 committed Nov 24, 2021
1 parent dcfdefd commit fd8424b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions webapp/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import "normalize.css";
import "../components/global/styles/global.css";
import { LocaleContext } from "../components/global";
import { UIProvider } from "../components/global";
import { useRouter } from "next/router";
import type { AppProps } from "next/app";
import { ThemeLocalStorageRepository } from "../infra/ThemeLocalStorageRepository";
import { adaptThemeRepositoryToThemeData } from "../components/global/adapters";

export default function MyApp({ Component, pageProps }: AppProps) {
const router = useRouter();
Expand All @@ -12,9 +14,12 @@ export default function MyApp({ Component, pageProps }: AppProps) {
router.push({ pathname, query }, asPath, { locale: nextLocale });
};

const themeRepository = new ThemeLocalStorageRepository();
const themeData = adaptThemeRepositoryToThemeData(themeRepository)

return (
<LocaleContext.Provider value={{ locale: locale, changeLocale }}>
<UIProvider themeData={themeData} locale={{ locale, changeLocale }}>
<Component {...pageProps} />
</LocaleContext.Provider>
</UIProvider>
);
}
2 changes: 1 addition & 1 deletion webapp/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyDocument extends Document {
rel="stylesheet"
/>
</Head>
<body data-theme="dark">
<body>
<Main />
<NextScript />
</body>
Expand Down

0 comments on commit fd8424b

Please sign in to comment.