Skip to content

Commit

Permalink
Merge pull request #161 from lostcarpark/TidyFormatting
Browse files Browse the repository at this point in the history
Tidy up formatting.
  • Loading branch information
lostcarpark authored Aug 4, 2024
2 parents b102283 + aae8d3f commit 498a11e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
15 changes: 7 additions & 8 deletions src/components/AppRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ const AppRoutes = () => {
</div>
);

const darken =
darkMode === "dark" ||
(darkMode === "browser" &&
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches);

const fetchProgram = useStoreActions((actions) => actions.fetchProgram);

useEffect(() => {
Expand All @@ -74,14 +80,7 @@ const AppRoutes = () => {
}, []);

return (
<ThemeSelector
isDark={
darkMode === "dark" ||
(darkMode === "browser" &&
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
}
>
<ThemeSelector isDark={darken}>
<Router basename={configData.BASE_PATH}>
<ScrollToTop>{theApp}</ScrollToTop>
</Router>
Expand Down
10 changes: 5 additions & 5 deletions src/components/ThemeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const DarkStyle = React.lazy(() => import("./DarkStyle"));

const ThemeSelector = ({ isDark, children }) => (
<>
<React.Suspense fallback={() => null}>
{!isDark && <LightStyle />}
{isDark && <DarkStyle />}
</React.Suspense>
{children}
<React.Suspense fallback={() => null}>
{!isDark && <LightStyle />}
{isDark && <DarkStyle />}
</React.Suspense>
{children}
</>
);

Expand Down

0 comments on commit 498a11e

Please sign in to comment.