Skip to content

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

web: improve pane resizing

Abdullah Atta8049b024514b
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index 3a83ebffa..cd5cc5b1d 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -24,7 +24,7 @@ import useMobile from "./hooks/use-mobile";
import useTablet from "./hooks/use-tablet";
import { LazyMotion, domAnimation } from "framer-motion";
import useDatabase from "./hooks/use-database";
-import { Allotment } from "allotment";
+import { Allotment, LayoutPriority } from "allotment";
import "allotment/dist/style.css";
import Config from "./utils/config";
import { useStore } from "./stores/app-store";
@@ -128,10 +128,10 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
>
<Allotment
ref={panesRef}
- proportionalLayout
+ proportionalLayout={false}
onChange={(sizes) => {
Config.set("paneSizes", sizes);
- setIsNarrow(sizes[0] <= 132);
+ setIsNarrow(sizes[0] <= 55);
}}
>
<Allotment.Pane
@@ -139,6 +139,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
minSize={50}
preferredSize={isTablet ? 50 : paneSizes[0]}
visible={!isFocusMode}
+ priority={LayoutPriority.Low}
>
<Flex sx={{ overflow: "hidden", flex: 1 }}>
<SuspenseLoader
@@ -159,6 +160,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
minSize={2}
preferredSize={paneSizes[1]}
visible={show}
+ priority={LayoutPriority.Normal}
>
<Flex className="listMenu" variant="columnFill">
<SuspenseLoader
@@ -168,8 +170,10 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
/>
</Flex>
</Allotment.Pane>
-
- <Allotment.Pane className="pane editor-pane">
+ <Allotment.Pane
+ className="pane editor-pane"
+ priority={LayoutPriority.High}
+ >
<Flex
sx={{
overflow: "hidden",
diff --git a/apps/web/src/components/icons/index.tsx b/apps/web/src/components/icons/index.tsx
index 607a17776..129f29516 100644
--- a/apps/web/src/components/icons/index.tsx
+++ b/apps/web/src/components/icons/index.tsx
@@ -298,8 +298,8 @@ export const Login = createIcon(mdiLoginVariant);
export const Email = createIcon(mdiEmailAlertOutline);
export const Signup = createIcon(mdiAccountOutline);
export const Logout = createIcon(mdiLogoutVariant);
-export const FocusMode = createIcon(mdiSunglasses);
-export const NormalMode = createIcon(mdiGlasses);
+export const FocusMode = createIcon(mdiGlasses);
+export const NormalMode = createIcon(mdiSunglasses);
export const Settings = createIcon(mdiCogOutline);
export const Home = createIcon(mdiHomeOutline);
export const Restore = createIcon(mdiRecycle);
diff --git a/apps/web/src/components/navigation-menu/index.tsx b/apps/web/src/components/navigation-menu/index.tsx
index ec545460c..30f330736 100644
--- a/apps/web/src/components/navigation-menu/index.tsx
+++ b/apps/web/src/components/navigation-menu/index.tsx
@@ -249,7 +249,17 @@ function NavigationMenu(props: NavigationMenuProps) {
onClick={() => hardNavigate("/login")}
/>
)}
-
+ {isTablet && (
+ <NavigationItem
+ isTablet={isTablet}
+ title={theme === "dark" ? "Light mode" : "Dark mode"}
+ icon={theme === "dark" ? LightMode : DarkMode}
+ onClick={() => {
+ setFollowSystemTheme(false);
+ toggleNightMode();
+ }}
+ />
+ )}
<NavigationItem
isTablet={isTablet}
key={settings.path}
@@ -278,9 +288,9 @@ function NavigationMenu(props: NavigationMenuProps) {
}}
>
{theme === "dark" ? (
- <DarkMode size={16} />
- ) : (
<LightMode size={16} />
+ ) : (
+ <DarkMode size={16} />
)}
</Button>
)}
diff --git a/apps/web/src/components/navigation-menu/navigation-item.tsx b/apps/web/src/components/navigation-menu/navigation-item.tsx
index 771f97fb8..d21165d5b 100644
--- a/apps/web/src/components/navigation-menu/navigation-item.tsx
+++ b/apps/web/src/components/navigation-menu/navigation-item.tsx
@@ -35,6 +35,7 @@ type NavigationItemProps = {
isNew?: boolean;
selected?: boolean;
onClick?: () => void;
+ count?: number;
// TODO: add proper typings here
menuItems?: any[];
};
@@ -51,7 +52,8 @@ function NavigationItem(props: PropsWithChildren<NavigationItemProps>) {
isTablet,
selected,
onClick,
- menuItems
+ menuItems,
+ count
} = props;
const toggleSideMenu = useAppStore((store) => store.toggleSideMenu);
const { openMenu } = useMenuTrigger();
@@ -96,7 +98,7 @@ function NavigationItem(props: PropsWithChildren<NavigationItemProps>) {
}}
>
<Icon
- size={isTablet ? 18 : 15}
+ size={isTablet ? 16 : 15}
color={color || (selected ? "primary" : "icon")}
rotate={isLoading}
/>
@@ -132,7 +134,16 @@ function NavigationItem(props: PropsWithChildren<NavigationItemProps>) {
{title}
</Text>
</Button>
- {children}
+ {children ? (
+ children
+ ) : !isTablet && count !== undefined ? (
+ <Text
+ variant="subBody"
+ sx={{ mr: 1, bg: "hover", px: "3px", borderRadius: "default" }}
+ >
+ {count > 100 ? "100+" : count}
+ </Text>
+ ) : null}
</Flex>
);
}