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
feat: fix ui for mobile and tablet
thecodrr7a9489df3959
diff --git a/apps/web/src/components/button/index.js b/apps/web/src/components/button/index.jsindex f030108bb..b72821a4b 100644--- a/apps/web/src/components/button/index.js+++ b/apps/web/src/components/button/index.js@@ -9,8 +9,8 @@ function Button(props) {<Flexdata-test-id={props.testId}bg="primary"- py={2}- px={2}+ py={3}+ px={3}mx={2}alignItems="center"display={["flex", "none", "none"]}diff --git a/apps/web/src/components/editor/editor.css b/apps/web/src/components/editor/editor.cssindex 3fbaa65a2..684a7d8bf 100644--- a/apps/web/src/components/editor/editor.css+++ b/apps/web/src/components/editor/editor.css@@ -21,7 +21,7 @@}.ql-toolbar.ql-snow span {padding-top: 1px;- font-size: 18px;+ font-size: 1.125em;}.ql-formats {@@ -166,16 +166,16 @@.ql-editor .ql-syntax,code {font-family: monospace !important;- font-size: 14px;+ font-size: 0.875rem;}.ql-editor .ql-syntax * {font-family: monospace !important;- font-size: 14px;+ font-size: 0.875rem;}.ql-editor {- font-size: 14px;+ font-size: 0.875rem;color: var(--text) !important;padding: 10px !important;}diff --git a/apps/web/src/components/editor/header.js b/apps/web/src/components/editor/header.jsindex aab7d0966..6e5c1ccfc 100644--- a/apps/web/src/components/editor/header.js+++ b/apps/web/src/components/editor/header.js@@ -11,7 +11,7 @@ function Header() {const setSession = useStore((store) => store.setSession);return (- <Flex justifyContent="center">+ <Flex mx={[2, 2, 0]} mb={[2, 2, 0]}><TitleBoxshouldFocus={sessionState === SESSION_STATES.new}title={title}diff --git a/apps/web/src/components/editor/titlebox.js b/apps/web/src/components/editor/titlebox.jsindex 1b0882031..018bcbd6a 100644--- a/apps/web/src/components/editor/titlebox.js+++ b/apps/web/src/components/editor/titlebox.js@@ -30,7 +30,7 @@ function TitleBox(props) {style={{backgroundColor: "transparent",fontFamily: theme.fonts["heading"],- fontSize: 42,+ fontSize: "2.625em",fontWeight: theme.fontWeights["heading"],resize: "none",paddingRight: theme.space[2],diff --git a/apps/web/src/components/editor/toolbar.js b/apps/web/src/components/editor/toolbar.jsindex c60262697..6036f7555 100644--- a/apps/web/src/components/editor/toolbar.js+++ b/apps/web/src/components/editor/toolbar.js@@ -6,6 +6,7 @@ import { useStore as useAppStore } from "../../stores/app-store";import { useStore } from "../../stores/editor-store";import { showToast } from "../../utils/toast";import { EventManagers } from "../../utils/observablearray";+import Animated from "../animated";function Toolbar(props) {const { quill } = props;@@ -16,6 +17,24 @@ function Toolbar(props) {const toggleFocusMode = useAppStore((store) => store.toggleFocusMode);const toggleProperties = useStore((store) => store.toggleProperties);const clearSession = useStore((store) => store.clearSession);+ const title = useStore((store) => store.session.title);+ const [isTitleVisible, setIsTitleVisible] = useState(false);++ useEffect(() => {+ const editorScroll = document.querySelector(".editorScroll");+ function onScroll(e) {+ const headerOffset = document.querySelector(".editorTitle").scrollHeight;+ const hideOffset = headerOffset + 100;+ if (e.target.scrollTop > hideOffset && !isTitleVisible)+ setIsTitleVisible(true);+ else if (e.target.scrollTop <= hideOffset && isTitleVisible)+ setIsTitleVisible(false);+ }+ editorScroll.addEventListener("scroll", onScroll);+ return () => {+ editorScroll.removeEventListener("scroll", onScroll);+ };+ }, [isTitleVisible]);useEffect(() => {if (!quill?.history) return;@@ -65,17 +84,28 @@ function Toolbar(props) {);return (- <Flex m={2} justifyContent={["space-between", "space-between", "flex-end"]}>- <Icon.ChevronLeft- sx={{- display: ["block", "block", "none"],- }}- size={30}- onClick={() => {- clearSession();- showToast("success", "Note saved!");- }}- />+ <Flex m={2} justifyContent={"space-between"}>+ <Flex justifyContent="center" alignItems="center">+ <Icon.ChevronLeft+ sx={{+ display: ["block", "block", "none"],+ }}+ size={30}+ onClick={() => {+ clearSession();+ showToast("success", "Note saved!");+ }}+ />+ <Animated.Text+ ml={[2, 2, 0]}+ initial={{ opacity: isTitleVisible ? 1 : 0 }}+ animate={{ opacity: isTitleVisible ? 1 : 0 }}+ transition={{ duration: 0.5 }}+ fontWeight="heading"+ >+ {title}+ </Animated.Text>+ </Flex><Flex justifyContent="flex-end">{tools.map((tool) => (<Buttondiff --git a/apps/web/src/components/global-menu-wrapper/index.js b/apps/web/src/components/global-menu-wrapper/index.jsindex 02fc8efc3..adcc7983d 100644--- a/apps/web/src/components/global-menu-wrapper/index.js+++ b/apps/web/src/components/global-menu-wrapper/index.js@@ -34,6 +34,7 @@ function GlobalMenuWrapper() {id="globalContextMenu"menuItems={items}data={data}+ state={state}title={title}style={{position: "absolute",diff --git a/apps/web/src/components/icons/index.js b/apps/web/src/components/icons/index.jsindex 6f0e74409..d6f17b6b8 100644--- a/apps/web/src/components/icons/index.js+++ b/apps/web/src/components/icons/index.js@@ -3,9 +3,13 @@ import MDIIcon from "@mdi/react";import * as Icons from "@mdi/js";import { useTheme } from "emotion-theming";import Animated from "../animated";+import useMobile from "../../utils/use-mobile";function Icon({ name, size = 24, color = "icon", stroke, rotate }) {const theme = useTheme();+ const isMobile = useMobile();+ size += isMobile ? 4 : 0;+return (<MDIIconpath={name}diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.jsindex 560c00ab0..dc335356f 100644--- a/apps/web/src/components/list-item/index.js+++ b/apps/web/src/components/list-item/index.js@@ -127,14 +127,13 @@ function ListItem(props) {/>)}<Text- as="h3"color={props.bg ? props.bg : "text"}fontFamily={"heading"}fontSize="title"fontWeight={"bold"}sx={{- lineHeight: "1.4em",- maxHeight: "1.4em", // 2 lines, i hope+ lineHeight: "1.4rem",+ maxHeight: "1.4rem", // 2 lines, i hopeoverflow: "hidden",textOverflow: "ellipsis",}}diff --git a/apps/web/src/components/menu/colors.js b/apps/web/src/components/menu/colors.jsindex a289badf2..784e1622d 100644--- a/apps/web/src/components/menu/colors.js+++ b/apps/web/src/components/menu/colors.js@@ -4,11 +4,12 @@ import * as Icon from "../icons/index";import { objectMap } from "../../utils/object";import { useStore } from "../../stores/note-store";import { Flex } from "rebass";+import useMobile from "../../utils/use-mobile";function Colors(props) {const { id, colors } = props.data;const setColor = useStore((store) => store.setColor);-+ const isMobile = useMobile();return (<Flex flexWrap="wrap">{objectMap(COLORS, (label, code) => (@@ -16,9 +17,11 @@ function Colors(props) {sx={{ position: "relative" }}onClick={() => setColor(id, label)}key={label}+ justifyContent="center"+ alignItems="center"><Icon.Circle- size={25}+ size={isMobile ? 45 : 25}style={{ cursor: "pointer" }}color={code}strokeWidth={0}@@ -29,12 +32,10 @@ function Colors(props) {data-test-id={`menuitem-colors-${label}-check`}sx={{position: "absolute",- left: 1,- top: 1,cursor: "pointer",}}color="static"- size={14}+ size={isMobile ? 24 : 14}/>)}</Flex>diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.jsindex 00fb611c8..2c90f687a 100644--- a/apps/web/src/components/menu/index.js+++ b/apps/web/src/components/menu/index.js@@ -1,13 +1,79 @@-import React from "react";+import { useAnimation } from "framer-motion";+import React, { useEffect } from "react";import { Flex, Box, Text } from "rebass";import { SUBSCRIPTION_STATUS } from "../../common";import { useStore as useUserStore } from "../../stores/user-store";+import useMobile from "../../utils/use-mobile";+import Animated from "../animated";function Menu(props) {const isTrial = useUserStore((store) => store.user?.subscription?.status === SUBSCRIPTION_STATUS.TRIAL);+ const isMobile = useMobile();+ const Container = isMobile ? MobileMenuContainer : MenuContainer;+ return (+ <Container {...props}>+ {props.menuItems.map(+ (item) =>+ item.visible !== false && (+ <Flex+ data-test-id={`menuitem-${item.title+ .split(" ")+ .join("")+ .toLowerCase()}`}+ key={item.title}+ onClick={async (e) => {+ e.stopPropagation();+ if (props.closeMenu) {+ props.closeMenu();+ }++ if (!item.component) {+ item.onClick(props.data);+ }+ }}+ flexDirection="row"+ alignItems="center"+ justifyContent="space-between"+ py={"8px"}+ px={3}+ sx={{+ color: item.color || "text",+ cursor: "pointer",+ ":hover": {+ backgroundColor: "shade",+ },+ }}+ >+ {item.component ? (+ <item.component data={props.data} />+ ) : (+ <Text as="span" fontFamily="body" fontSize="menu">+ {item.title}+ </Text>+ )}+ {item.onlyPro && !isTrial && (+ <Text+ fontSize="body"+ bg="primary"+ color="static"+ px={1}+ sx={{ borderRadius: "default" }}+ >+ Pro+ </Text>+ )}+ </Flex>+ )+ )}+ </Container>+ );+}+export default Menu;++function MenuContainer(props) {return (<Flexid={props.id}@@ -26,7 +92,7 @@ function Menu(props) {<Box width="100%"><TextfontFamily="body"- fontSize="body"+ fontSize="subtitle"color="primary"py={"8px"}px={3}@@ -34,61 +100,65 @@ function Menu(props) {>Properties</Text>- {props.menuItems.map(- (item) =>- item.visible !== false && (- <Flex- data-test-id={`menuitem-${item.title- .split(" ")- .join("")- .toLowerCase()}`}- key={item.title}- onClick={async (e) => {- e.stopPropagation();- if (props.closeMenu) {- props.closeMenu();- }-- if (!item.component) {- item.onClick(props.data);- }- }}- flexDirection="row"- alignItems="center"- justifyContent="space-between"- py={"8px"}- px={3}- sx={{- color: item.color || "text",- cursor: "pointer",- ":hover": {- backgroundColor: "shade",- },- }}- >- {item.component ? (- <item.component data={props.data} />- ) : (- <Text as="span" fontFamily="body" fontSize="menu">- {item.title}- </Text>- )}- {item.onlyPro && !isTrial && (- <Text- fontSize="menu"- bg="primary"- color="static"- px={1}- sx={{ borderRadius: "default" }}- >- Pro- </Text>- )}- </Flex>- )- )}+ {props.children}</Box></Flex>);}-export default Menu;++function MobileMenuContainer(props) {+ const { style, id, state } = props;+ const animation = useAnimation();+ useEffect(() => {+ if (state === "open") {+ animation.start({ y: 0 });+ const menu = document.getElementById(id);+ menu.style.top = 0;+ menu.style.left = 0;+ } else {+ animation.start({ y: 500 });+ }+ }, [state, animation, id]);+ return (+ <Flex+ flexDirection="column"+ id={id}+ style={style}+ width="100%"+ height="100%"+ bg="overlay"+ overflow="hidden"+ sx={{ position: "relative" }}+ >+ <Animated.Flex+ width="100%"+ bg="background"+ sx={{+ position: "absolute",+ bottom: 0,+ borderTopLeftRadius: 10,+ borderTopRightRadius: 10,+ overflow: "hidden",+ }}+ initial={{ y: 500 }}+ animate={animation}+ flexDirection="column"+ p={2}+ >+ <Box+ width={50}+ height={7}+ bg="shade"+ alignSelf="center"+ sx={{ borderRadius: "default" }}+ />+ <Flex flex="1" flexDirection="column" overflowY="scroll">+ <Text variant="title" mt={2} alignSelf="center">+ Properties+ </Text>+ {props.children}+ </Flex>+ </Animated.Flex>+ </Flex>+ );+}diff --git a/apps/web/src/components/navigation-menu/navigation-item.js b/apps/web/src/components/navigation-menu/navigation-item.jsindex 912f9d29d..f6196dd56 100644--- a/apps/web/src/components/navigation-menu/navigation-item.js+++ b/apps/web/src/components/navigation-menu/navigation-item.js@@ -33,7 +33,7 @@ function NavigationItem(props) {/><Textvariant="body"- fontSize={12}+ fontSize="subtitle"color={props.selected ? "primary" : "text"}ml={1}>diff --git a/apps/web/src/components/route-container/index.js b/apps/web/src/components/route-container/index.jsindex 2f7bf951b..eb9d45088 100644--- a/apps/web/src/components/route-container/index.js+++ b/apps/web/src/components/route-container/index.js@@ -1,6 +1,6 @@import React from "react";import Animated from "../animated";-import { Box, Flex, Heading, Text } from "rebass";+import { Box, Flex, Text } from "rebass";import * as Icon from "../icons";import { useStore } from "../../stores/app-store";import { useStore as useSelectionStore } from "../../stores/selection-store";@@ -45,34 +45,31 @@ function Header(props) {return (<Flex mx={2} flexDirection="column"><Flex alignItems="center" justifyContent="space-between">- <Flex alignItems="center" py={2}>+ <Flex justifyContent="center" alignItems="center" py={2}>{canGoBack || onlyBackButton ? (- <Box- height={38}- width={38}- sx={{ flexShrink: 0 }}+ <Icon.ChevronLeft+ size={38}onClick={() => window.history.back()}- >- <Icon.ChevronLeft- size={38}- color="fontPrimary"- data-test-id="go-back"- />- </Box>+ sx={{ flexShrink: 0 }}+ color="fontPrimary"+ data-test-id="go-back"+ />) : (<Icon.MenuonClick={toggleSideMenu}sx={{+ flexShrink: 0,ml: 0,mr: 4,+ mt: 1,display: [onlyBackButton ? "none" : "block", "none", "none"],}}- size={28}+ size={30}/>)}- <Heading data-test-id="routeHeader" fontSize="heading" color={"text"}>+ <Text variant="heading" data-test-id="routeHeader" color={"text"}>{title}- </Heading>+ </Text></Flex><SelectionOptions options={SELECTION_OPTIONS_MAP[type]} />{!isSelectionMode && (diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex 8aa648406..96b2b6d94 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -3,12 +3,18 @@ body {font-size: 16px;}+@media only screen and (max-width: 480px) {+ html,+ body {+ font-size: 18px;+ }+}+:root,body,#root {margin: 0;height: 100%;- overflow: hidden;}* {diff --git a/apps/web/src/theme/font/fontsize.js b/apps/web/src/theme/font/fontsize.jsindex aae510609..3cce9ff8b 100644--- a/apps/web/src/theme/font/fontsize.js+++ b/apps/web/src/theme/font/fontsize.js@@ -1,13 +1,13 @@class FontSizeFactory {- constructor(scaleFactor) {+ constructor() {return {- heading: 24 * scaleFactor,- input: 14 * scaleFactor,- title: 14 * scaleFactor,- subtitle: 12 * scaleFactor,- body: 13 * scaleFactor,- menu: 14 * scaleFactor,- subBody: 10 * scaleFactor,+ heading: "1.5rem",+ input: "0.875rem",+ title: "0.875rem",+ subtitle: "0.750rem",+ body: "0.750rem",+ menu: "0.8rem",+ subBody: "0.625rem",};}}