A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
ui: add basic navigation
thecodrr1f0ca754c3d1
diff --git a/apps/web/src/Components/Editor/editor.css b/apps/web/src/Components/Editor/editor.cssindex 5099f0895..fbb9b49bb 100644--- a/apps/web/src/Components/Editor/editor.css+++ b/apps/web/src/Components/Editor/editor.css@@ -28,6 +28,7 @@width: 120px !important;}.ql-toolbar.ql-snow {+ width: 100%;border: none !important;border-bottom: 1px solid #f0f0f0 !important;border-top: 1px solid #f0f0f0 !important;diff --git a/apps/web/src/Components/Editor/index.js b/apps/web/src/Components/Editor/index.jsindex 735c9e267..5bd82966e 100644--- a/apps/web/src/Components/Editor/index.js+++ b/apps/web/src/Components/Editor/index.js@@ -32,7 +32,23 @@ const modules = {};const Editor = props => {+ const ref = ref => (Editor.quillRef = ref);+useEffect(() => {+ if (Editor.quillRef) {+ const quill = Editor.quillRef.getEditor();+ if (quill) {+ quill.keyboard.addBinding(+ {+ key: "S",+ shortKey: true+ },+ () => {+ /* save note here */+ }+ );+ }+ }// move the toolbar outside (easiest way)const toolbar = document.querySelector(".ql-toolbar.ql-snow");//const quill = document.querySelector(".quill");@@ -44,6 +60,7 @@ const Editor = props => {//editor.appendChild(quill);}});+return (<FlexclassName="editor"@@ -62,7 +79,7 @@ const Editor = props => {py={3}/><Box id="toolbar" display={["none", "flex", "flex"]}></Box>- <ReactQuill modules={modules} theme="snow" />+ <ReactQuill ref={ref} modules={modules} theme="snow" /></Flex>);};diff --git a/apps/web/src/app.js b/apps/web/src/app.jsindex 4d71662e6..5b1966ac3 100644--- a/apps/web/src/app.js+++ b/apps/web/src/app.js@@ -1,50 +1,54 @@-import React, { useState } from "react";+import React, { useState, useEffect } from "react";import "./app.css";import Editor from "./Components/Editor";import { ThemeProvider } from "emotion-theming";import { Flex, Box, Text, Button, Card, Heading } from "rebass";-import { Input } from "@rebass/forms";import * as Icon from "react-feather";import theme, { SHADOW } from "./theme";+import { routes, navigate } from "./navigation";+import Home from "../src/views/Home";++const NavMenuItem = props => {+ useEffect(() => {+ if (props.selected) {+ navigate(props.item.key);+ }+ });+ return (+ <Button+ onClick={props.onSelected}+ variant="nav"+ sx={{+ width: "full",+ borderRadius: "none",+ textAlign: "center",+ color: props.selected ? "accent" : "fontPrimary"+ }}+ px={0}+ >+ <props.item.icon+ size={25}+ strokeWidth={props.selected ? 2 : 1.3}+ style={{ marginRight: 3 }}+ />+ {/* <Text sx={{ fontSize: 15, marginLeft: 1 }}>{props.item.title}</Text> */}+ </Button>+ );+};-const NavMenuItem = props => (- <Button- onClick={props.onSelected}- variant="nav"- sx={{- width: "full",- borderRadius: "none",- textAlign: "center",- color: props.selected ? "accent" : "fontPrimary"- }}- px={0}- >- <props.item.icon- size={25}- strokeWidth={props.selected ? 2 : 1.3}- style={{ marginRight: 3 }}- />- {/* <Text sx={{ fontSize: 15, marginLeft: 1 }}>{props.item.title}</Text> */}- </Button>-);-const navItems = [- { title: "Arkane", icon: Icon.User },- { title: "Home", icon: Icon.Home },- { title: "Notebooks", icon: Icon.Book },- { title: "Folders", icon: Icon.Folder },- { title: "Lists", icon: Icon.List },- { title: "Get Pro", icon: Icon.Star }-];function App() {- const [selectedIndex, setSelectedIndex] = useState(1);+ const [selectedIndex, setSelectedIndex] = useState(0);return (<ThemeProvider theme={theme}><Flex height="100%" alignContent="stretch"><Box width={[0, 0, 70]} bg="navbg" px={0}>- {navItems.map((item, index) => (+ {Object.values(routes).map((item, index) => (<NavMenuItem- onSelected={() => setSelectedIndex(index)}- key={item.title}+ onSelected={() => {+ navigate(item.key);+ setSelectedIndex(index);+ }}+ key={item.key}item={item}selected={selectedIndex === index}/>@@ -52,64 +56,14 @@ function App() {</Box><Flex flex="1 1 auto" flexDirection="row" alignContent="stretch" px={0}><Flex+ className="navigationView"bg="primary"flexDirection="column"flex="1 1 auto"px={3}py={3}width={["100%", "40%", "13%"]}- >- <Heading fontSize="heading">Notes</Heading>- <Input- placeholder="Search"- fontFamily="body"- fontWeight="body"- fontSize="input"- bg="navbg"- my={2}- px={3}- py={3}- sx={{- boxShadow: SHADOW,- borderWidth: 0,- borderRadius: "default"- }}- />- <Box- bg="navbg"- my={2}- px={3}- py={3}- sx={{ borderRadius: "default" }}- >- <Flex flexDirection="row" justifyContent="space-between">- <Text fontFamily="body" fontSize="title" fontWeight="bold">- This is a note title- </Text>- <Flex flexDirection="row">- <Icon.Share2 size={20} strokeWidth={1.5} />- <Icon.Heart- size={20}- strokeWidth={1.5}- style={{ marginLeft: 15, marginRight: 10 }}- />- <Icon.MoreVertical size={20} strokeWidth={1.5} />- </Flex>- </Flex>- <Text fontFamily="body" fontSize="body" sx={{ marginTop: 1 }}>- You are born to be the greatest there ever was. Embrace your- true powers!- </Text>- <Text- fontFamily="body"- fontWeight="body"- fontSize={12}- color="accent"- >- 5 hours ago- </Text>- </Box>- </Flex>+ /><Editor /></Flex></Flex>diff --git a/apps/web/src/navigation/index.js b/apps/web/src/navigation/index.jsnew file mode 100644index 000000000..4d8da9cd1--- /dev/null+++ b/apps/web/src/navigation/index.js@@ -0,0 +1,87 @@+import React from "react";+import ReactDOM from "react-dom";+import Home from "../views/Home";+import { ThemeProvider } from "emotion-theming";+import { Heading } from "rebass";+import * as Icon from "react-feather";+import theme from "../theme";++export const routes = {+ home: {+ key: "home",+ title: "Home",+ component: Home,+ icon: Icon.Home+ },+ notebooks: {+ key: "notebooks",+ title: "Notebooks",+ component: undefined,+ icon: Icon.Book+ },+ lists: {+ key: "lists",+ title: "Lists",+ component: undefined,+ icon: Icon.List+ },+ trash: {+ key: "trash",+ title: "Trash",+ component: undefined,+ icon: Icon.Trash+ },+ settings: {+ key: "settings",+ title: "Settings",+ component: undefined,+ icon: Icon.Settings+ }+};+const history = {};++export function navigate(routeName, root = "navigationView") {+ let route = routes[routeName];++ // do not navigate if the previous route is the same+ if (!history[root]) {+ history[root] = [];+ }+ let historyContainer = history[root];+ if (+ historyContainer.length > 0 &&+ historyContainer[historyContainer.length - 1].title === route.title+ ) {+ return;+ }++ let rootView = document.querySelector(`.${root}`);+ if (!rootView) return;+ ReactDOM.render(getThemedComponent(route), rootView);++ historyContainer[historyContainer.length] = {+ ...route+ };+ history[root] = historyContainer;+}++export function goBack(root) {+ if (!history[root] || history[root].length <= 0) {+ return;+ }+ let route = history[root].pop();+ if (route) {+ let rootView = document.querySelector(`.${root}`);+ if (!rootView) return;+ ReactDOM.render(getThemedComponent(route), rootView);+ }+}++function getThemedComponent(route) {+ return (+ <ThemeProvider theme={theme}>+ <Heading fontSize="heading">{route.title}</Heading>+ {route.component && route.component()}+ </ThemeProvider>+ );+}diff --git a/apps/web/src/views/Home.js b/apps/web/src/views/Home.jsnew file mode 100644index 000000000..4cf9f3095--- /dev/null+++ b/apps/web/src/views/Home.js@@ -0,0 +1,48 @@+import React, { useEffect } from "react";+import { Flex, Box, Text, Heading } from "rebass";+import * as Icon from "react-feather";+import { SHADOW } from "../theme";+import { Input } from "@rebass/forms";++function Home() {+ return (+ <Box>+ <Input+ placeholder="Search"+ fontFamily="body"+ fontWeight="body"+ fontSize="input"+ bg="navbg"+ my={2}+ px={3}+ py={3}+ sx={{+ boxShadow: SHADOW,+ borderWidth: 0,+ borderRadius: "default"+ }}+ />+ <Box bg="navbg" px={3} py={3} sx={{ borderRadius: "default" }}>+ <Flex flexDirection="row" justifyContent="space-between">+ <Text fontFamily="body" fontSize="title" fontWeight="bold">+ This is a note title+ </Text>+ <Icon.MoreVertical+ size={20}+ strokeWidth={1.5}+ style={{ marginRight: -5 }}+ />+ </Flex>+ <Text fontFamily="body" fontSize="body" sx={{ marginTop: 1 }}>+ You are born to be the greatest there ever was. Embrace your true+ powers!+ </Text>+ <Text fontFamily="body" fontWeight="body" fontSize={12} color="accent">+ 5 hours ago+ </Text>+ </Box>+ </Box>+ );+}++export default Home;