Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added frontend/public/favicon-dark.ico
Binary file not shown.
Binary file added frontend/public/favicon-light.ico
Binary file not shown.
Binary file added frontend/public/favicon.ico
Binary file not shown.
9 changes: 5 additions & 4 deletions frontend/src/app/layout.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Inter } from "next/font/google";
import "./ui/globals.css";

import { motion } from "framer-motion";
import UpdateNotifier from "./ui/snackBar";
import Providers from "./providers";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -15,8 +14,10 @@ export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={inter.className}>
<UpdateNotifier />
{children}
<Providers>
<UpdateNotifier />
{children}
</Providers>
</body>
</html>
);
Expand Down
39 changes: 39 additions & 0 deletions frontend/src/app/providers.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use client";

import { createTheme, ThemeProvider, CssBaseline } from "@mui/material";
import { useState, useEffect } from "react";
import { useMediaQuery } from "@mui/material";
import Head from "next/head";

export default function Providers({ children }) {
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
const [mode, setMode] = useState(prefersDarkMode ? "dark" : "light");

useEffect(() => {
setMode(prefersDarkMode ? "dark" : "light");
}, [prefersDarkMode]);

const theme = createTheme({ palette: { mode } });

return (
<ThemeProvider theme={theme}>
<CssBaseline />
<FaviconUpdater mode={mode} />
{children}
</ThemeProvider>
);
}

function FaviconUpdater({ mode }) {
useEffect(() => {
const favicon =
mode === "dark" ? "/favicon-dark.ico" : "/favicon-light.ico";
document.querySelector("link[rel='icon']")?.setAttribute("href", favicon);
}, [mode]);

return (
<Head>
<link rel="icon" href="/favicon-light.ico" />
</Head>
);
}