Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: embed theme toggle in settings button

thecodrr94567cfe5657
diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.js
index d14cb0c37..01fc41110 100644
--- a/apps/web/src/components/navigation-menu/index.js
+++ b/apps/web/src/components/navigation-menu/index.js
@@ -1,5 +1,5 @@
import { useCallback, useEffect } from "react";
-import { Box, Flex } from "rebass";
+import { Box, Button, Flex } from "rebass";
import {
Note,
Notebook,
@@ -13,7 +13,6 @@ import {
Topic,
DarkMode,
LightMode,
- Sync,
Login,
Circle,
} from "../icons";
@@ -61,13 +60,11 @@ const routes = [
{ title: "Trash", path: "/trash", icon: Trash },
];
-const bottomRoutes = [
- {
- title: "Settings",
- path: "/settings",
- icon: Settings,
- },
-];
+const settings = {
+ title: "Settings",
+ path: "/settings",
+ icon: Settings,
+};
const NAVIGATION_MENU_WIDTH = "10em";
const NAVIGATION_MENU_TABLET_WIDTH = "4em";
@@ -81,6 +78,11 @@ function NavigationMenu(props) {
const refreshNavItems = useAppStore((store) => store.refreshNavItems);
const isLoggedIn = useUserStore((store) => store.isLoggedIn);
const isMobile = useMobile();
+ const theme = useThemeStore((store) => store.theme);
+ const toggleNightMode = useThemeStore((store) => store.toggleNightMode);
+ const setFollowSystemTheme = useThemeStore(
+ (store) => store.setFollowSystemTheme
+ );
const _navigate = useCallback(
(path) => {
@@ -242,17 +244,41 @@ function NavigationMenu(props) {
onClick={() => hardNavigate("/login")}
/>
)}
- {bottomRoutes.map((item) => (
- <NavigationItem
- key={item.path}
- title={item.title}
- icon={item.icon}
- onClick={() => {
- _navigate(item.path);
+
+ <NavigationItem
+ key={settings.path}
+ title={settings.title}
+ icon={settings.icon}
+ onClick={() => {
+ _navigate(settings.path);
+ }}
+ selected={location.startsWith(settings.path)}
+ >
+ <Button
+ variant={"icon"}
+ title="Toggle dark/light mode"
+ sx={{
+ position: "absolute",
+ right: "2px",
+ bg: "transparent",
+ borderRadius: "default",
+ ":hover:not(disabled)": {
+ bg: "background",
+ },
}}
- selected={location.startsWith(item.path)}
- />
- ))}
+ onClick={(e) => {
+ e.stopPropagation();
+ setFollowSystemTheme(false);
+ toggleNightMode();
+ }}
+ >
+ {theme === "dark" ? (
+ <DarkMode size={16} />
+ ) : (
+ <LightMode size={16} />
+ )}
+ </Button>
+ </NavigationItem>
</Flex>
</AnimatedFlex>
);
diff --git a/apps/web/src/components/navigation-menu/navigation-item.js b/apps/web/src/components/navigation-menu/navigation-item.js
index 844c8da2c..468139857 100644
--- a/apps/web/src/components/navigation-menu/navigation-item.js
+++ b/apps/web/src/components/navigation-menu/navigation-item.js
@@ -6,7 +6,15 @@ import useTablet from "../../utils/use-tablet";
import * as Icons from "../icons";
function NavigationItem(props) {
- const { icon: Icon, color, title, isLoading, isShortcut, isNew } = props;
+ const {
+ icon: Icon,
+ color,
+ title,
+ isLoading,
+ isShortcut,
+ isNew,
+ children,
+ } = props;
const toggleSideMenu = useAppStore((store) => store.toggleSideMenu);
const { openMenu } = useMenuTrigger();
const isMobile = useMobile();
@@ -15,7 +23,6 @@ function NavigationItem(props) {
return (
<Button
data-test-id={`navitem-${title.toLowerCase()}`}
- variant="icon"
bg={props.selected ? "border" : "transparent"}
px={2}
py={"9px"}
@@ -26,6 +33,10 @@ function NavigationItem(props) {
position: "relative",
":first-of-type": { mt: 1 },
":last-of-type": { mb: 1 },
+ ":hover:not(:disabled)": {
+ bg: "bgSecondaryHover",
+ filter: "brightness(100%)",
+ },
}}
label={title}
title={title}
@@ -76,6 +87,7 @@ function NavigationItem(props) {
>
{title}
</Text>
+ {children}
</Button>
);
}
diff --git a/apps/web/src/theme/colorscheme/dark.js b/apps/web/src/theme/colorscheme/dark.js
index 09d0158dc..75d02a676 100644
--- a/apps/web/src/theme/colorscheme/dark.js
+++ b/apps/web/src/theme/colorscheme/dark.js
@@ -11,6 +11,7 @@ class DarkColorSchemeFactory {
accent: "#000",
bgSecondary: "#2b2b2b",
bgSecondaryText: "#A1A1A1",
+ bgSecondaryHover: "#4b4b4b",
border: "#353535",
hover: "#2f2f2f",
fontSecondary: "#000",
diff --git a/apps/web/src/theme/colorscheme/light.js b/apps/web/src/theme/colorscheme/light.js
index 88622f1f8..299549e26 100644
--- a/apps/web/src/theme/colorscheme/light.js
+++ b/apps/web/src/theme/colorscheme/light.js
@@ -10,6 +10,7 @@ class LightColorSchemeFactory {
accent: "white",
bgSecondary: "#f7f7f7",
bgSecondaryText: "#5E5E5E",
+ bgSecondaryHover: "#dbdbdb",
border: "#e5e5e5",
hover: "#f0f0f0",
fontSecondary: "white",
diff --git a/apps/web/src/theme/variants/button.js b/apps/web/src/theme/variants/button.js
index 155c61a06..ad455216e 100644
--- a/apps/web/src/theme/variants/button.js
+++ b/apps/web/src/theme/variants/button.js
@@ -146,9 +146,9 @@ class Icon {
variant: "buttons.default",
color: "text",
borderRadius: "none",
- ":hover": {
- backgroundColor: "hover",
- filter: "brightness(90%)",
+ ":hover:not(disabled)": {
+ backgroundColor: "bgSecondaryHover",
+ filter: "brightness(100%)",
},
};
}