Skip to content

Commit

Permalink
Use new useMediaQuery hook to determine dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Sep 11, 2024
1 parent 4123687 commit c6f0c41
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions thallium-frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ToastContainer } from "react-toastify";

import "react-toastify/dist/ReactToastify.css";
import "./styles/toast-overrides.css";
import { useMediaQuery } from "./utils/hooks.ts";


const GlobalStyle = createGlobalStyle`
Expand Down Expand Up @@ -97,18 +98,12 @@ const router = createBrowserRouter([


function App() {
const [isDarkMode, setIsDarkMode] = useState(false);
const isDarkMode = useMediaQuery("(prefers-color-scheme: dark)");

maybeRefreshTask();

const theme = isDarkMode ? themes.dark : themes.light;

useEffect(() => {
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;

setIsDarkMode(prefersDark);
}, []);

return (
<ThemeProvider theme={theme}>
<AppContainer>
Expand Down

0 comments on commit c6f0c41

Please sign in to comment.