Skip to content

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

ui: seperate bottom routes

thecodrr6aaa79713b3d
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index 88e08d9d5..9de5b72bf 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -16,8 +16,6 @@ const NavMenuItem = props => {
sx={{
width: "full",
borderRadius: "none",
- borderLeft: props.selected && "3px solid",
- borderColor: "primary",
textAlign: "center",
color: props.selected ? "primary" : props.item.color || "text",
transition: "color 100ms linear",
@@ -82,39 +80,70 @@ function App() {
height="100%"
alignContent="stretch"
>
- <Box
+ <Flex
+ flexDirection="column"
+ justifyContent="space-between"
sx={{
zIndex: 999,
borderRight: "1px solid",
borderRightColor: "primary",
minWidth: ["85%", 60, 60],
maxWidth: ["85%", 60, 60],
- display: [sideMenuOpen ? "block" : "none", "block", "block"],
+ display: [sideMenuOpen ? "flex" : "none", "flex", "flex"],
position: ["absolute", "relative", "relative"]
}}
bg={"shade"}
px={0}
>
- {Object.values(RootNavigator.routes).map((item, index) => (
- <NavMenuItem
- onSelected={async () => {
- if (item.onClick) {
- return item.onClick();
- }
- if (selectedIndex === index) {
- setShow(!show);
- return;
- }
- if (RootNavigator.navigate(item.key)) {
- setSelectedIndex(index);
- }
- }}
- key={item.key}
- item={item}
- selected={selectedIndex === index}
- />
- ))}
- </Box>
+ <Box>
+ {Object.values(RootNavigator.routes).map(
+ (item, index) =>
+ !item.bottom && (
+ <NavMenuItem
+ onSelected={async () => {
+ if (item.onClick) {
+ return item.onClick();
+ }
+ if (selectedIndex === index) {
+ setShow(!show);
+ return;
+ }
+ if (RootNavigator.navigate(item.key)) {
+ setSelectedIndex(index);
+ }
+ }}
+ key={item.key}
+ item={item}
+ selected={selectedIndex === index}
+ />
+ )
+ )}
+ </Box>
+ <Box>
+ {Object.values(RootNavigator.routes).map(
+ (item, index) =>
+ item.bottom && (
+ <NavMenuItem
+ onSelected={async () => {
+ if (item.onClick) {
+ return item.onClick();
+ }
+ if (selectedIndex === index) {
+ setShow(!show);
+ return;
+ }
+ if (RootNavigator.navigate(item.key)) {
+ setSelectedIndex(index);
+ }
+ }}
+ key={item.key}
+ item={item}
+ selected={selectedIndex === index}
+ />
+ )
+ )}
+ </Box>
+ </Flex>
<Flex flex="1 1 auto" flexDirection="row" alignContent="stretch" px={0}>
<Flex
className="RootNavigator"
diff --git a/apps/web/src/navigation/navigators/rootnavigator.js b/apps/web/src/navigation/navigators/rootnavigator.js
index e8e23b85c..3bcd4fdae 100644
--- a/apps/web/src/navigation/navigators/rootnavigator.js
+++ b/apps/web/src/navigation/navigators/rootnavigator.js
@@ -10,7 +10,8 @@ import {
createRoute,
createNormalRoute,
createColorRoute,
- createDeadRoute
+ createDeadRoute,
+ makeBottomRoute
} from "../routes";
import Navigator from "../index";
import { showSignInDialog } from "../../components/dialogs";
@@ -27,6 +28,22 @@ const colorRoutes = {
...createColorRoute("gray", "gray")
};
+const bottomRoutes = {
+ ...makeBottomRoute(
+ createDeadRoute("nightmode", Icon.Moon, () => {
+ changeTheme();
+ })
+ ),
+ ...makeBottomRoute(
+ createDeadRoute("signin", Icon.LogIn, () => {
+ showSignInDialog(Icon.LogIn, "Login", "");
+ })
+ ),
+ ...makeBottomRoute(
+ createRoute("settings", SettingsContainer, { icon: Icon.Settings })
+ )
+};
+
const routes = {
...createNormalRoute("home", Home, Icon.Home),
...createRoute("notebooks", NotebooksContainer, {
@@ -34,14 +51,8 @@ const routes = {
}),
...createNormalRoute("favorites", Favorites, Icon.Star),
...createNormalRoute("trash", Trash, Icon.Trash2),
- ...createRoute("settings", SettingsContainer, { icon: Icon.Settings }),
- ...createDeadRoute("nightmode", Icon.Moon, () => {
- changeTheme();
- }),
...colorRoutes,
- ...createDeadRoute("signin", Icon.LogIn, () => {
- showSignInDialog(Icon.LogIn, "Login", "");
- })
+ ...bottomRoutes
};
const RootNavigator = new Navigator("RootNavigator", routes, {
diff --git a/apps/web/src/navigation/routes.js b/apps/web/src/navigation/routes.js
index 0aca8158a..1e2ee855b 100644
--- a/apps/web/src/navigation/routes.js
+++ b/apps/web/src/navigation/routes.js
@@ -16,10 +16,15 @@ export function createColorRoute(key, color) {
}
export function createNormalRoute(key, component, icon) {
- //console.log(component.name);
return createRoute(key, component, { title: component.name, icon });
}
export function createDeadRoute(key, icon, onClick) {
return createRoute(key, undefined, { icon, onClick, isDead: true });
}
+
+export function makeBottomRoute(route) {
+ let key = Object.keys(route)[0];
+ route[key].bottom = true;
+ return route;
+}