diff --git a/frontend/src/lib/NavItem.tsx b/frontend/src/lib/NavItem.tsx
new file mode 100644
index 0000000..38e3db7
--- /dev/null
+++ b/frontend/src/lib/NavItem.tsx
@@ -0,0 +1,22 @@
+import { ReactNode, PropsWithChildren } from "react";
+import { Link } from "react-router-dom";
+
+export interface Props {
+ children?: ReactNode | undefined;
+ to: string;
+ plain?: boolean | undefined; // Do not wrap in
+}
+
+export default function NavItem(props: Props) {
+ const ret =
+ {props.children}
+
+
+ if (props.plain) {
+ return ret
+ }
+ return {ret};
+}
diff --git a/frontend/src/lib/Navigation.tsx b/frontend/src/lib/Navigation.tsx
index d4a4314..889e3ec 100644
--- a/frontend/src/lib/Navigation.tsx
+++ b/frontend/src/lib/Navigation.tsx
@@ -1,13 +1,15 @@
-import Logo from "./logo";
import { useState } from "react";
import { Link } from "react-router-dom";
import { MoonStars, Sun, List } from "react-bootstrap-icons";
+import NavItem from "./NavItem";
+import Logo from "./logo";
+
function Navigation() {
const [darkTheme, setDarkTheme] = useState(
localStorage.theme === "dark" ||
- (!("theme" in localStorage) &&
- window.matchMedia("(prefers-color-scheme: dark)").matches)
+ (!("theme" in localStorage) &&
+ window.matchMedia("(prefers-color-scheme: dark)").matches)
);
const [showMenu, setShowMenu] = useState(false);
@@ -18,73 +20,71 @@ function Navigation() {
document.documentElement.classList.remove("dark");
}
- const storeTheme = (system: boolean) => {
- if (system) {
+ const storeTheme = (useDarkTheme: boolean | null) => {
+ if (useDarkTheme === null) {
localStorage.removeItem("theme");
} else {
- localStorage.setItem("theme", darkTheme ? "dark" : "light");
+ localStorage.setItem("theme", useDarkTheme ? "dark" : "light");
}
};
return (
-
-
-
-
-
-
-
-
-
-
-
{
- storeTheme(false);
- setDarkTheme(!darkTheme);
- }}
- title={
- darkTheme ? "Switch to light mode" : "Switch to dark mode"
- }
- className="cursor-pointer"
- >
- {darkTheme ? (
-
- ) : (
-
- )}
-
-
setShowMenu(!showMenu)} title="Show menu" className="cursor-pointer flex lg:hidden">
+ <>
+
+
+
+
+
+
+
+
+
+
+
{
+ setDarkTheme(!darkTheme);
+ storeTheme(!darkTheme);
+ }}
+ title={
+ darkTheme ? "Switch to light mode" : "Switch to dark mode"
+ }
+ className="cursor-pointer"
+ >
+ {darkTheme ? (
+
+ ) : (
+
+ )}
+
+
setShowMenu(!showMenu)} title="Show menu" className="cursor-pointer flex lg:hidden">
+
-
-
+
+ >
);
}