Skip to content

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

ui: responsiveness and nav design improvements

thecodrr3b2ac11d382c
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index 6cce959ff..88e08d9d5 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -1,11 +1,12 @@
import React, { useState, useEffect } from "react";
import "./app.css";
import Editor from "./components/editor";
-import { Flex, Box, Button } from "rebass";
+import { Flex, Box, Button, Text } from "rebass";
import { ThemeProvider } from "./utils/theme";
import RootNavigator from "./navigation/navigators/rootnavigator";
import "./app.css";
import { usePersistentState } from "./utils/hooks";
+import { ev } from "./common";
const NavMenuItem = props => {
return (
@@ -15,21 +16,39 @@ 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",
":hover": {
- backgroundColor: "shade"
+ color: "primary"
}
}}
px={0}
+ py={3}
>
- <props.item.icon
- size={25}
- strokeWidth={props.selected ? 2 : 1.3}
- style={{ marginRight: 3 }}
- fill={props.item.color || "transparent"}
- />
- {/* <Text sx={{ fontSize: 15, marginLeft: 1 }}>{props.item.title}</Text> */}
+ <Flex
+ justifyContent={["flex-start", "center", "center"]}
+ alignItems="center"
+ sx={{ marginLeft: [2, 0, 0] }}
+ >
+ <props.item.icon
+ size={24}
+ strokeWidth={props.item.color ? 0 : props.selected ? 2 : 1.3}
+ style={{ marginRight: 2 }}
+ fill={props.item.color || "transparent"}
+ />
+ <Text
+ sx={{
+ display: ["flex", "none", "none"],
+ fontSize: 15,
+ marginLeft: 1
+ }}
+ >
+ {props.item.title}
+ </Text>
+ </Flex>
</Button>
);
};
@@ -44,8 +63,16 @@ function App() {
0
);
const [show, setShow] = usePersistentState("navContainerState", true);
+ const [sideMenuOpen, setSideMenuOpen] = useState(false);
useEffect(() => {
RootNavigator.navigate(Object.keys(RootNavigator.routes)[selectedIndex]);
+ function openSideMenu() {
+ setSideMenuOpen(true);
+ }
+ ev.addListener("openSideMenu", openSideMenu);
+ return () => {
+ ev.removeListener("openSideMenu", openSideMenu);
+ };
}, []);
return (
<ThemeProvider>
@@ -57,11 +84,15 @@ function App() {
>
<Box
sx={{
+ zIndex: 999,
borderRight: "1px solid",
- borderRightColor: "border",
- minWidth: 70,
- maxWidth: 70
+ borderRightColor: "primary",
+ minWidth: ["85%", 60, 60],
+ maxWidth: ["85%", 60, 60],
+ display: [sideMenuOpen ? "block" : "none", "block", "block"],
+ position: ["absolute", "relative", "relative"]
}}
+ bg={"shade"}
px={0}
>
{Object.values(RootNavigator.routes).map((item, index) => (
@@ -93,45 +124,42 @@ function App() {
sx={{
borderRight: "1px solid",
borderColor: "border",
- width: !getNavigationViewWidth()
- ? ["100%", "40%", "23%"]
- : getNavigationViewWidth()
+ width: ["100%", "100%", "30%"]
}}
flexDirection="column"
flex="1 1 auto"
//style={{ width: "362px" }}
/>
- {show && (
- <Box
- className="resize-handle"
- bg="border"
- sx={{
- width: 5,
- opacity: 0,
- cursor: "col-resize"
- }}
- draggable={true}
- onMouseDown={e => {
- startX = e.clientX;
- let view = document
- .querySelector(".RootNavigator")
- .getBoundingClientRect();
- startWidth = parseInt(view.width, 10);
- }}
- onDrag={e => {
- let view = document.querySelector(".RootNavigator");
- view.style.width = `${startWidth + e.clientX - startX}px`;
- }}
- onDragEnd={e => {
- let view = document.querySelector(".RootNavigator");
- view.style.width = view.getBoundingClientRect().width;
- window.localStorage.setItem(
- "navigationViewWidth",
- view.style.width
- );
- }}
- />
- )}
+ <Box
+ className="resize-handle"
+ bg="border"
+ sx={{
+ width: 5,
+ display: ["none", "none", show ? "block" : "none"],
+ opacity: 0,
+ cursor: "col-resize"
+ }}
+ draggable={true}
+ onMouseDown={e => {
+ startX = e.clientX;
+ let view = document
+ .querySelector(".RootNavigator")
+ .getBoundingClientRect();
+ startWidth = parseInt(view.width, 10);
+ }}
+ onDrag={e => {
+ let view = document.querySelector(".RootNavigator");
+ view.style.width = `${startWidth + e.clientX - startX}px`;
+ }}
+ onDragEnd={e => {
+ let view = document.querySelector(".RootNavigator");
+ view.style.width = view.getBoundingClientRect().width;
+ window.localStorage.setItem(
+ "navigationViewWidth",
+ view.style.width
+ );
+ }}
+ />
<Editor />
</Flex>
<Box id="dialogContainer" />
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 8589d9d8a..59bbf9fc8 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -156,7 +156,7 @@ export default class Editor extends React.Component {
render() {
return (
- <Flex width={["0%", "50%", "77%"]}>
+ <Flex width={["0%", "0%", "100%"]}>
<Flex
className="editor"
flex="1 1 auto"
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index ba7455847..e6e762e71 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -15,10 +15,10 @@ const Properties = props => {
position: "absolute",
top: "50%",
right: 0,
- height: 60,
color: "static",
borderRadius: "100px 0px 0px 100px",
- cursor: "pointer"
+ cursor: "pointer",
+ height: [0, 0, 60]
}}
alignItems="center"
justifyContent="center"
@@ -31,7 +31,7 @@ const Properties = props => {
sx={{
borderLeft: "1px solid",
borderColor: "border",
- width: "20%"
+ width: [0, 0, "20%"]
}}
flexDirection="column"
bg="shade"
diff --git a/apps/web/src/navigation/index.js b/apps/web/src/navigation/index.js
index df1ea634b..64038a0dd 100644
--- a/apps/web/src/navigation/index.js
+++ b/apps/web/src/navigation/index.js
@@ -3,6 +3,7 @@ import ReactDOM from "react-dom";
import { Box, Flex, Heading, Text } from "rebass";
import * as Icon from "react-feather";
import { ThemeProvider } from "../utils/theme";
+import { ev } from "../common";
export default class Navigator {
constructor(root, routes, options = {}) {
@@ -83,11 +84,23 @@ const NavigationContainer = props => {
onClick={props.backAction}
height={38}
color="fontPrimary"
- sx={{ marginLeft: -10 /*correction */, marginRight: 2 }}
+ sx={{ marginLeft: -2 /*correction */, marginRight: 2 }}
>
<Icon.ChevronLeft size={38} />
</Box>
)}
+ <Box
+ onClick={() => ev.emit("openSideMenu")}
+ height={38}
+ color="fontPrimary"
+ sx={{
+ marginLeft: -5 /*correction */,
+ marginRight: 1,
+ display: ["block", "none", "none"]
+ }}
+ >
+ <Icon.Menu size={38} />
+ </Box>
<Heading fontSize="heading">
{props.route.title || props.route.params.title}
</Heading>
diff --git a/apps/web/src/utils/theme.js b/apps/web/src/utils/theme.js
index e4d342f8d..b0404e76c 100644
--- a/apps/web/src/utils/theme.js
+++ b/apps/web/src/utils/theme.js
@@ -44,11 +44,11 @@ const shadowsLight = {
};
const theme = (colors, shadows) => ({
- breakpoints: ["480px", "834px", "1200px"],
+ breakpoints: ["480px", "1000px", "1000px"],
colors: colors,
space: [0, 5, 10, 12, 15],
fontSizes: {
- heading: 36,
+ heading: 32,
input: 16,
title: 18,
subtitle: 18,