Skip to content

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

global: update ui

Abdullah Attae18661516328
diff --git a/apps/web/package-lock.json b/apps/web/package-lock.json
index 4148fcf14..41279872f 100644
--- a/apps/web/package-lock.json
+++ b/apps/web/package-lock.json
@@ -77,7 +77,7 @@
"react-modal": "3.16.3",
"react-qrcode-logo": "^2.9.0",
"react-scroll-sync": "^0.11.2",
- "react-virtuoso": "^4.6.2",
+ "react-virtuoso": "^4.12.3",
"snarkdown": "^2.0.0",
"timeago.js": "4.0.2",
"w3c-keyname": "^2.2.6",
@@ -499,7 +499,7 @@
},
"../desktop": {
"name": "@notesnook/desktop",
- "version": "3.0.28",
+ "version": "3.0.29",
"hasInstallScript": true,
"license": "GPL-3.0-or-later",
"dependencies": {
@@ -508,7 +508,7 @@
"@trpc/client": "10.45.2",
"@trpc/server": "10.45.2",
"better-sqlite3-multiple-ciphers": "11.5.0",
- "electron-trpc": "0.6.1",
+ "electron-trpc": "0.7.1",
"electron-updater": "^6.3.4",
"icojs": "^0.19.4",
"sqlite-better-trigram": "0.0.2",
@@ -531,7 +531,7 @@
"slugify": "1.6.6",
"tree-kill": "^1.2.2",
"undici": "^6.19.8",
- "vitest": "2.1.8"
+ "vitest": "^2.1.8"
},
"optionalDependencies": {
"dmg-license": "^1.0.11"
diff --git a/apps/web/package.json b/apps/web/package.json
index e4791c44d..035ca3083 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -75,7 +75,7 @@
"react-modal": "3.16.3",
"react-qrcode-logo": "^2.9.0",
"react-scroll-sync": "^0.11.2",
- "react-virtuoso": "^4.6.2",
+ "react-virtuoso": "^4.12.3",
"snarkdown": "^2.0.0",
"timeago.js": "4.0.2",
"w3c-keyname": "^2.2.6",
diff --git a/apps/web/src/app-effects.tsx b/apps/web/src/app-effects.tsx
index ac52399b8..aa6e30b30 100644
--- a/apps/web/src/app-effects.tsx
+++ b/apps/web/src/app-effects.tsx
@@ -48,11 +48,9 @@ import { AnnouncementDialog } from "./dialogs/announcement-dialog";
import { logger } from "./utils/logger";
import { strings } from "@notesnook/intl";
-type AppEffectsProps = {
- setShow: (show: boolean) => void;
-};
-export default function AppEffects({ setShow }: AppEffectsProps) {
+export default function AppEffects() {
const refreshNavItems = useStore((store) => store.refreshNavItems);
+ const toggleListPane = useStore((store) => store.toggleListPane);
const updateLastSynced = useStore((store) => store.updateLastSynced);
const isFocusMode = useStore((store) => store.isFocusMode);
const initUser = useUserStore((store) => store.init);
@@ -234,7 +232,7 @@ export default function AppEffects({ setShow }: AppEffectsProps) {
}, []);
useEffect(() => {
- setShow(!isFocusMode);
+ toggleListPane(!isFocusMode);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFocusMode]);
diff --git a/apps/web/src/app.css b/apps/web/src/app.css
index 42c64aa36..2ff637528 100644
--- a/apps/web/src/app.css
+++ b/apps/web/src/app.css
@@ -1,8 +1,3 @@
-:root {
- --sash-size: 10px;
- --sash-hover-size: 4px;
-}
-
.tabsScroll,
.titlebarLogo,
.theme-scope-titleBar,
@@ -18,101 +13,77 @@
-webkit-app-region: no-drag;
}
-/* open-sans-regular - vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic */
@font-face {
- font-family: "Open Sans";
+ font-family: "Inter";
font-style: normal;
font-display: swap;
font-weight: 400;
- src: local(""),
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff2")
- format("woff2"),
- /* Super Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff")
- format("woff"),
- /* Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.ttf")
- format("truetype");
-}
-/* open-sans-600 - vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic */
+ src: local(""), url("./assets/fonts/Inter-Regular.woff2") format("woff2"),
+ url("./assets/fonts/Inter-Regular.ttf") format("truetype");
+}
+
@font-face {
- font-family: "Open Sans";
+ font-family: "Inter";
font-style: normal;
- font-weight: 600;
font-display: swap;
- src: local(""),
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff2")
- format("woff2"),
- /* Super Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff")
- format("woff"),
- /* Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.ttf")
- format("truetype");
-}
-/* open-sans-700 - vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic */
+ font-weight: 600;
+ src: local(""), url("./assets/fonts/Inter-SemiBold.woff2") format("woff2"),
+ url("./assets/fonts/Inter-SemiBold.ttf") format("truetype");
+}
+
@font-face {
- font-family: "Open Sans";
+ font-family: "Inter";
font-style: normal;
+ font-display: swap;
font-weight: 700;
+ src: local(""), url("./assets/fonts/Inter-Bold.woff2") format("woff2"),
+ url("./assets/fonts/Inter-Bold.ttf") format("truetype");
+}
+
+@font-face {
+ font-family: "Inter";
+ font-style: normal;
font-display: swap;
- src: local(""),
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff2")
- format("woff2"),
- /* Super Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff")
- format("woff"),
- /* Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.ttf")
- format("truetype");
-}
-/* open-sans-italic - vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic */
+ font-weight: 500;
+ src: local(""), url("./assets/fonts/Inter-Medium.woff2") format("woff2"),
+ url("./assets/fonts/Inter-Medium.ttf") format("truetype");
+}
+
@font-face {
- font-family: "Open Sans";
+ font-family: "Inter";
font-style: italic;
- font-weight: 400;
font-display: swap;
- src: local(""),
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff2")
- format("woff2"),
- /* Super Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff")
- format("woff"),
- /* Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.ttf")
- format("truetype");
-}
-/* open-sans-600italic - vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic */
+ font-weight: 400;
+ src: local(""), url("./assets/fonts/Inter-Italic.woff2") format("woff2"),
+ url("./assets/fonts/Inter-Italic.ttf") format("truetype");
+}
+
@font-face {
- font-family: "Open Sans";
+ font-family: "Inter";
font-style: italic;
- font-weight: 600;
font-display: swap;
+ font-weight: 600;
src: local(""),
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff2")
- format("woff2"),
- /* Super Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff")
- format("woff"),
- /* Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.ttf")
- format("truetype");
-}
-/* open-sans-700italic - vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic */
+ url("./assets/fonts/Inter-SemiBoldItalic.woff2") format("woff2"),
+ url("./assets/fonts/Inter-SemiBoldItalic.ttf") format("truetype");
+}
+
@font-face {
- font-family: "Open Sans";
+ font-family: "Inter";
font-style: italic;
+ font-display: swap;
font-weight: 700;
+ src: local(""), url("./assets/fonts/Inter-BoldItalic.woff2") format("woff2"),
+ url("./assets/fonts/Inter-BoldItalic.ttf") format("truetype");
+}
+
+@font-face {
+ font-family: "Inter";
+ font-style: italic;
font-display: swap;
- src: local(""),
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff2")
- format("woff2"),
- /* Super Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff")
- format("woff"),
- /* Modern Browsers */
- url("./assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.ttf")
- format("truetype");
+ font-weight: 500;
+ src: local(""), url("./assets/fonts/Inter-MediumItalic.woff2") format("woff2"),
+ url("./assets/fonts/Inter-MediumItalic.ttf") format("truetype");
}
.rpv-core__text-layer,
diff --git a/apps/web/src/app.tsx b/apps/web/src/app.tsx
index 15fc41c39..ce66d125a 100644
--- a/apps/web/src/app.tsx
+++ b/apps/web/src/app.tsx
@@ -52,7 +52,6 @@ new WebExtensionRelay();
function App() {
const isMobile = useMobile();
- const [show, setShow] = useState(true);
const isFocusMode = useStore((store) => store.isFocusMode);
const { isFocused } = useWindowFocus();
const { isFullscreen } = useWindowControls();
@@ -68,9 +67,6 @@ function App() {
.nav-pane {
opacity: 0.7;
}
- .titlebar {
- background: var(--background-secondary) !important;
- }
`}
/>
)}
@@ -78,15 +74,9 @@ function App() {
<Global
// These styles to make sure the app content doesn't overlap with the traffic lights.
styles={`
- .nav-pane,
- .mobile-nav-pane {
- margin-top: env(titlebar-area-height) !important;
- height: calc(100% - env(titlebar-area-height)) !important;
- }
- .nav-pane.collapsed + .list-pane .route-container-header,
- .nav-pane.collapsed + .list-pane.collapsed + .editor-pane .editor-action-bar,
- .nav-pane.collapsed + .editor-pane .editor-action-bar {
- padding-left: 25px;
+ .nav-pane .theme-scope-navigationMenu,
+ .mobile-nav-pane .theme-scope-navigationMenu {
+ padding-top: env(titlebar-area-height) !important;
}
.editor-pane:first-of-type .editor-action-bar,
.mobile-editor-pane.pane-active .editor-action-bar,
@@ -102,9 +92,9 @@ function App() {
.route-container-header .routeHeader {
font-size: ${getFontSizes().title};
}
- .global-split-pane .react-split__sash {
- height: calc(100% - ${TITLE_BAR_HEIGHT}px);
- }
+ // .global-split-pane .react-split__sash {
+ // height: calc(100% - ${TITLE_BAR_HEIGHT}px);
+ // }
`}
/>
) : null}
@@ -114,7 +104,7 @@ function App() {
<GlobalMenuWrapper />
</div>
</Suspense>
- <AppEffects setShow={setShow} />
+ <AppEffects />
<Flex
id="app"
@@ -126,11 +116,7 @@ function App() {
height: "100%"
}}
>
- {isMobile ? (
- <MobileAppContents />
- ) : (
- <DesktopAppContents setShow={setShow} show={show} />
- )}
+ {isMobile ? <MobileAppContents /> : <DesktopAppContents />}
<Toaster
containerClassName="toasts-container"
containerStyle={{ bottom: STATUS_BAR_HEIGHT + 10 }}
@@ -142,28 +128,12 @@ function App() {
export default App;
-type DesktopAppContentsProps = {
- show: boolean;
- setShow: (show: boolean) => void;
-};
-function DesktopAppContents({ show, setShow }: DesktopAppContentsProps) {
+function DesktopAppContents() {
const isFocusMode = useStore((store) => store.isFocusMode);
+ const isListPaneVisible = useStore((store) => store.isListPaneVisible);
const isTablet = useTablet();
- const [isNarrow, setIsNarrow] = useState(isTablet || false);
+ // const [isNarrow, setIsNarrow] = useState(isTablet || false);
const navPane = useRef<SplitPaneImperativeHandle>(null);
- const [isSideMenuOpen, setIsSideMenuOpen] = useState(false);
-
- useEffect(() => {
- const { unsubscribe } = AppEventManager.subscribe(
- AppEvents.toggleSideMenu,
- (state) => {
- setIsSideMenuOpen(Boolean(state));
- }
- );
- return () => {
- unsubscribe();
- };
- }, []);
useEffect(() => {
if (isTablet) navPane.current?.collapse(0);
@@ -178,50 +148,13 @@ function DesktopAppContents({ show, setShow }: DesktopAppContentsProps) {
overflow: "hidden"
}}
>
- {isTablet && (
- <Flex
- sx={{
- position: "absolute",
- left: 0,
- right: 0,
- zIndex: 1000,
- width: isSideMenuOpen ? "100%" : 0,
- height: "100%",
- background: "transparent",
- transition: "0.15s width ease-out"
- }}
- >
- <Box
- sx={{
- position: "absolute",
- width: "100%",
- height: "100%",
- top: 0,
- left: 0,
- background: "rgba(0,0,0,0.5)"
- }}
- onClick={() => {
- AppEventManager.publish(
- AppEvents.toggleSideMenu,
- !isSideMenuOpen
- );
- }}
- />
- <Flex sx={{ width: 300 }}>
- <NavigationMenu
- toggleNavigationContainer={() => {}}
- isTablet={false}
- />
- </Flex>
- </Flex>
- )}
<SplitPane
className="global-split-pane"
ref={navPane}
autoSaveId="global-panel-group"
direction="vertical"
onChange={(sizes) => {
- setIsNarrow(sizes[0] <= 70);
+ useStore.setState({ isNavPaneCollapsed: sizes[0] <= 70 });
}}
>
{isFocusMode ? null : (
@@ -229,19 +162,18 @@ function DesktopAppContents({ show, setShow }: DesktopAppContentsProps) {
id="nav-pane"
initialSize={isTablet ? 0 : 250}
className={`nav-pane`}
- minSize={isTablet ? 0 : 200}
- // snapSize={200}
- maxSize={isTablet ? 0 : 300}
+ snapSize={200}
+ minSize={40}
+ maxSize={isTablet ? 0 : 500}
+ style={{
+ overflow: "initial",
+ zIndex: 3
+ }}
>
- <NavigationMenu
- toggleNavigationContainer={(state) => {
- setShow(state || !show);
- }}
- isTablet={false}
- />
+ <NavigationMenu onExpand={() => navPane.current?.expand(0)} />
</Pane>
)}
- {!isFocusMode && show ? (
+ {!isFocusMode && isListPaneVisible ? (
<Pane
id="list-pane"
initialSize={380}
@@ -351,7 +283,7 @@ function MobileAppContents() {
flexShrink: 0
}}
>
- <NavigationMenu toggleNavigationContainer={() => {}} isTablet={false} />
+ <NavigationMenu />
</Flex>
<Flex
className="mobile-list-pane"
diff --git a/apps/web/src/assets/fonts/Inter-Bold.ttf b/apps/web/src/assets/fonts/Inter-Bold.ttf
new file mode 100644
index 000000000..9fb9b751e
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Bold.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-Bold.woff2 b/apps/web/src/assets/fonts/Inter-Bold.woff2
new file mode 100644
index 000000000..b9e3cb3b1
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Bold.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-BoldItalic.ttf b/apps/web/src/assets/fonts/Inter-BoldItalic.ttf
new file mode 100644
index 000000000..8d050001a
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-BoldItalic.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-BoldItalic.woff2 b/apps/web/src/assets/fonts/Inter-BoldItalic.woff2
new file mode 100644
index 000000000..31cd05221
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-BoldItalic.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-Italic.ttf b/apps/web/src/assets/fonts/Inter-Italic.ttf
new file mode 100644
index 000000000..e7ed211d2
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Italic.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-Italic.woff2 b/apps/web/src/assets/fonts/Inter-Italic.woff2
new file mode 100644
index 000000000..9a1ad2167
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Italic.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-Medium.ttf b/apps/web/src/assets/fonts/Inter-Medium.ttf
new file mode 100644
index 000000000..458cd0601
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Medium.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-Medium.woff2 b/apps/web/src/assets/fonts/Inter-Medium.woff2
new file mode 100644
index 000000000..fdfdcc699
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Medium.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-MediumItalic.ttf b/apps/web/src/assets/fonts/Inter-MediumItalic.ttf
new file mode 100644
index 000000000..22b898df3
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-MediumItalic.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-MediumItalic.woff2 b/apps/web/src/assets/fonts/Inter-MediumItalic.woff2
new file mode 100644
index 000000000..0dc5a3068
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-MediumItalic.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-Regular.ttf b/apps/web/src/assets/fonts/Inter-Regular.ttf
new file mode 100644
index 000000000..b7aaca8de
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Regular.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-Regular.woff2 b/apps/web/src/assets/fonts/Inter-Regular.woff2
new file mode 100644
index 000000000..2bcd222ec
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-Regular.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-SemiBold.ttf b/apps/web/src/assets/fonts/Inter-SemiBold.ttf
new file mode 100644
index 000000000..47f8ab1d6
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-SemiBold.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-SemiBold.woff2 b/apps/web/src/assets/fonts/Inter-SemiBold.woff2
new file mode 100644
index 000000000..fbae113d2
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-SemiBold.woff2 differ
diff --git a/apps/web/src/assets/fonts/Inter-SemiBoldItalic.ttf b/apps/web/src/assets/fonts/Inter-SemiBoldItalic.ttf
new file mode 100644
index 000000000..3f704a208
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-SemiBoldItalic.ttf differ
diff --git a/apps/web/src/assets/fonts/Inter-SemiBoldItalic.woff2 b/apps/web/src/assets/fonts/Inter-SemiBoldItalic.woff2
new file mode 100644
index 000000000..d67d01c6c
Binary files /dev/null and b/apps/web/src/assets/fonts/Inter-SemiBoldItalic.woff2 differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.ttf b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.ttf
deleted file mode 100644
index 0f921544b..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.ttf and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff
deleted file mode 100644
index 32c56a307..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff2 b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff2
deleted file mode 100644
index 26599958d..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600.woff2 and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.ttf b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.ttf
deleted file mode 100644
index 797f40f30..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.ttf and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff
deleted file mode 100644
index 8612cca5c..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff2 b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff2
deleted file mode 100644
index 932bb4d0e..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-600italic.woff2 and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.ttf b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.ttf
deleted file mode 100644
index e183c89bd..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.ttf and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff
deleted file mode 100644
index fd9eb374f..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff2 b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff2
deleted file mode 100644
index e44d73d1f..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700.woff2 and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.ttf b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.ttf
deleted file mode 100644
index 408f07d21..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.ttf and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff
deleted file mode 100644
index e9cf9d654..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff2 b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff2
deleted file mode 100644
index fd04386e1..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-700italic.woff2 and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.ttf b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.ttf
deleted file mode 100644
index c761fc6d0..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.ttf and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff
deleted file mode 100644
index 7b91f730c..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff2 b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff2
deleted file mode 100644
index f559fd43e..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-italic.woff2 and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.ttf b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.ttf
deleted file mode 100644
index cafe79820..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.ttf and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff
deleted file mode 100644
index 9bc5d1eed..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff and /dev/null differ
diff --git a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff2 b/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff2
deleted file mode 100644
index 2aa7f3338..000000000
Binary files a/apps/web/src/assets/fonts/open-sans-v34-vietnamese_latin-ext_latin_hebrew_greek-ext_greek_cyrillic-ext_cyrillic-regular.woff2 and /dev/null differ
diff --git a/apps/web/src/common/index.ts b/apps/web/src/common/index.ts
index 8a5be0991..dd5f5c9ff 100644
--- a/apps/web/src/common/index.ts
+++ b/apps/web/src/common/index.ts
@@ -46,6 +46,7 @@ import { strings } from "@notesnook/intl";
import { ABYTES, streamablefs } from "../interfaces/fs";
import { type ZipEntry } from "../utils/streams/unzip-stream";
import { ZipFile } from "../utils/streams/zip-stream";
+import { ConfirmDialog, showLogoutConfirmation } from "../dialogs/confirm";
export const CREATE_BUTTON_MAP = {
notes: {
@@ -421,3 +422,33 @@ async function restore(
);
}
}
+
+export async function logout() {
+ const result = await showLogoutConfirmation();
+ if (!result) return;
+
+ if (result.backup) {
+ try {
+ await createBackup({ mode: "partial" });
+ } catch (e) {
+ logger.error(e, "Failed to take backup before logout");
+ if (
+ !(await ConfirmDialog.show({
+ title: strings.failedToTakeBackup(),
+ message: strings.failedToTakeBackupMessage(),
+ negativeButtonText: strings.no(),
+ positiveButtonText: strings.yes()
+ }))
+ )
+ return;
+ }
+ }
+
+ await TaskManager.startTask({
+ type: "modal",
+ title: strings.loggingOut(),
+ subtitle: strings.pleaseWait(),
+ action: () => db.user.logout(true)
+ });
+ showToast("success", strings.loggedOut());
+}
diff --git a/apps/web/src/components/announcements/index.jsx b/apps/web/src/components/announcements/index.jsx
index c426ff32b..38110de12 100644
--- a/apps/web/src/components/announcements/index.jsx
+++ b/apps/web/src/components/announcements/index.jsx
@@ -33,7 +33,7 @@ function Announcements() {
const dismiss = useAnnouncementStore((store) => store.dismiss);
const announcement = announcements[0];
- if (!announcement) return <Notice />;
+ if (!announcement) return null;
return (
<Flex
mx={1}
diff --git a/apps/web/src/components/attachment/index.tsx b/apps/web/src/components/attachment/index.tsx
index 96b043ffd..72709ffd0 100644
--- a/apps/web/src/components/attachment/index.tsx
+++ b/apps/web/src/components/attachment/index.tsx
@@ -130,7 +130,7 @@ export function Attachment({
return (
<Box
as="tr"
- sx={{ height: 30, ":hover": { bg: "hover" } }}
+ sx={{ height: 25, ":hover": { bg: "hover" } }}
onContextMenu={(e) => {
e.preventDefault();
e.stopPropagation();
@@ -165,7 +165,8 @@ export function Attachment({
<td>
<Flex
sx={{
- alignItems: "center"
+ alignItems: "center",
+ ml: 2
}}
>
{status ? (
diff --git a/apps/web/src/components/cached-router/index.tsx b/apps/web/src/components/cached-router/index.tsx
index 43a452668..6e2abc9f2 100644
--- a/apps/web/src/components/cached-router/index.tsx
+++ b/apps/web/src/components/cached-router/index.tsx
@@ -18,12 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useEffect, useRef } from "react";
-import { getHomeRoute, NavigationEvents } from "../../navigation";
+import { getHomeRoute, navigate, NavigationEvents } from "../../navigation";
import { store as selectionStore } from "../../stores/selection-store";
import useRoutes from "../../hooks/use-routes";
import RouteContainer from "../route-container";
import routes from "../../navigation/routes";
-import { isRouteResult } from "../../navigation/types";
import { Freeze } from "react-freeze";
import { Flex } from "@theme-ui/components";
@@ -31,7 +30,15 @@ function CachedRouter() {
const [RouteResult, location] = useRoutes(routes, {
fallbackRoute: getHomeRoute(),
hooks: {
- beforeNavigate: () => selectionStore.toggleSelectionMode(false)
+ beforeNavigate: (location) => {
+ selectionStore.toggleSelectionMode(false);
+ if (location === "/") {
+ console.log("Redirecting to", getHomeRoute());
+ navigate(getHomeRoute());
+ return false;
+ }
+ return true;
+ }
}
});
const cachedRoutes = useRef<Record<string, React.FunctionComponent>>({});
@@ -41,17 +48,17 @@ function CachedRouter() {
NavigationEvents.publish("onNavigate", RouteResult, location);
}, [RouteResult, location]);
- if (!RouteResult || !isRouteResult(RouteResult)) return null;
- if (RouteResult.key === "general" || !cachedRoutes.current[RouteResult.key])
+ if (!RouteResult) return null;
+ if (
+ RouteResult.key === "general" ||
+ !cachedRoutes.current[RouteResult.key] ||
+ RouteResult.noCache
+ )
cachedRoutes.current[RouteResult.key] =
RouteResult.component as React.FunctionComponent;
return (
- <RouteContainer
- type={RouteResult.type}
- title={RouteResult.title}
- buttons={RouteResult.buttons}
- >
+ <RouteContainer {...RouteResult}>
{Object.entries(cachedRoutes.current).map(([key, Component]) => (
<Freeze key={key} freeze={key !== RouteResult.key}>
<Flex
diff --git a/apps/web/src/components/editor/action-bar.tsx b/apps/web/src/components/editor/action-bar.tsx
index ba96ea3b1..469e542c7 100644
--- a/apps/web/src/components/editor/action-bar.tsx
+++ b/apps/web/src/components/editor/action-bar.tsx
@@ -23,18 +23,11 @@ import {
ArrowLeft,
ArrowRight,
Cross,
- EditorFullWidth,
- EditorNormalWidth,
- ExitFullscreen,
- FocusMode,
- Fullscreen,
Lock,
NewTab,
- NormalMode,
Note,
NoteRemove,
Pin,
- Plus,
Properties,
Publish,
Published,
@@ -82,7 +75,7 @@ import { showPublishView } from "../publish-view";
import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
import useMobile from "../../hooks/use-mobile";
import { strings } from "@notesnook/intl";
-import { TITLE_BAR_HEIGHT, getWindowControls } from "../title-bar";
+import { getWindowControls } from "../title-bar";
import useTablet from "../../hooks/use-tablet";
import { isMac } from "../../utils/platform";
@@ -216,6 +209,7 @@ export function EditorActionBar() {
: 1,
pl: 1,
borderLeft: "1px solid var(--border)",
+ borderBottom: "1px solid var(--border)",
flexShrink: 0
}}
>
@@ -265,6 +259,7 @@ const TabStrip = React.memo(function TabStrip() {
sx={{
px: 1,
borderRight: "1px solid var(--border)",
+ borderBottom: "1px solid var(--border)",
alignItems: "center",
flexShrink: 0
}}
@@ -292,7 +287,7 @@ const TabStrip = React.memo(function TabStrip() {
<ScrollContainer
className="tabsScroll"
suppressScrollY
- style={{ flex: 1, height: TITLE_BAR_HEIGHT }}
+ style={{ flex: 1, height: "100%" }}
trackStyle={() => ({
backgroundColor: "transparent",
"--ms-track-size": "6px"
@@ -415,6 +410,9 @@ const TabStrip = React.memo(function TabStrip() {
);
}}
/>
+ <div
+ style={{ width: "100%", borderBottom: "1px solid var(--border)" }}
+ />
</Flex>
</ScrollContainer>
</Flex>
@@ -495,6 +493,9 @@ function Tab(props: TabProps) {
cursor: "pointer",
pl: 2,
borderRight: "1px solid var(--border)",
+ borderBottom: isActive
+ ? "1px solid transparent"
+ : "1px solid var(--border)",
":last-of-type": { borderRight: 0 },
transform: CSS.Transform.toString(transform),
@@ -509,7 +510,7 @@ function Tab(props: TabProps) {
"& .closeTabButton": {
opacity: 1
},
- bg: isActive ? "hover-selected" : "hover"
+ bg: isActive ? "background-selected" : "hover"
}
}}
onContextMenu={(e) => {
@@ -553,14 +554,13 @@ function Tab(props: TabProps) {
onClick: onRevealInList,
isHidden: !onRevealInList
},
- { type: "separator", key: "sep2" },
+ { type: "separator", key: "sep2", isHidden: !onRevealInList },
{
type: "button",
key: "pin",
title: strings.pin(),
onClick: onPin,
- isChecked: isPinned,
- icon: Pin.path
+ isChecked: isPinned
}
]);
}}
@@ -576,7 +576,11 @@ function Tab(props: TabProps) {
data-test-id={`tab-icon${isUnsaved ? "-unsaved" : ""}`}
size={14}
color={
- isUnsaved ? "accent-error" : isActive ? "accent-selected" : "icon"
+ isUnsaved
+ ? "icon-error"
+ : isActive
+ ? "icon-selected"
+ : "icon-secondary"
}
/>
<Text
@@ -588,7 +592,7 @@ function Tab(props: TabProps) {
overflowX: "hidden",
pointerEvents: "none",
maxWidth: 120,
- color: isActive ? "paragraph-selected" : "paragraph"
+ color: isActive ? "paragraph-selected" : "paragraph-secondary"
}}
ml={1}
>
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index 559121e4a..85f9adab5 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -128,17 +128,6 @@ export default function TabsView() {
return (
<>
- <Flex
- className="editor-action-bar"
- sx={{
- zIndex: 2,
- height: TITLE_BAR_HEIGHT,
- borderBottom: "1px solid var(--border)"
- }}
- >
- <EditorActionBar />
- </Flex>
-
<ScopedThemeProvider
scope="editor"
ref={dropRef}
@@ -147,9 +136,21 @@ export default function TabsView() {
flex: 1,
overflow: "hidden",
display: "flex",
- flexDirection: "column"
+ flexDirection: "column",
+ position: "relative"
}}
>
+ <Flex
+ className="editor-action-bar"
+ sx={{
+ zIndex: 2,
+ height: TITLE_BAR_HEIGHT,
+ bg: "background-secondary"
+ // borderBottom: "1px solid var(--border)"
+ }}
+ >
+ <EditorActionBar />
+ </Flex>
<SplitPane direction="vertical" autoSaveId={"editor-panels"}>
<Pane id="editor-panel" className="editor-pane">
{tabs.map((tab) => {
diff --git a/apps/web/src/components/editor/manager.ts b/apps/web/src/components/editor/manager.ts
index 8450ba808..b15124799 100644
--- a/apps/web/src/components/editor/manager.ts
+++ b/apps/web/src/components/editor/manager.ts
@@ -40,7 +40,7 @@ class EditorManager extends BaseStore<EditorManager> {
toolbarConfig?: ToolbarDefinition;
editorConfig: EditorConfig = Config.get("editorConfig", {
fontFamily: "sans-serif",
- fontSize: 16,
+ fontSize: 14,
zoom: EDITOR_ZOOM.DEFAULT
});
editors: Record<string, EditorContext> = {};
diff --git a/apps/web/src/components/field/index.tsx b/apps/web/src/components/field/index.tsx
index 8617c041f..ceb108e88 100644
--- a/apps/web/src/components/field/index.tsx
+++ b/apps/web/src/components/field/index.tsx
@@ -146,7 +146,7 @@ function Field(props: FieldProps) {
</Flex>
)}
- {rightActions.length > 0 ? (
+ {leftActions.length > 0 ? (
<Flex
sx={{
position: "absolute",
@@ -189,6 +189,7 @@ function Field(props: FieldProps) {
) : null}
{rightActions.length > 0 ? (
<Flex
+ className="rightActions"
sx={{
position: "absolute",
top: 0,
@@ -222,7 +223,7 @@ function Field(props: FieldProps) {
{action.component ? (
action.component
) : action.icon ? (
- <action.icon size={20} />
+ <action.icon size={16} />
) : null}
</Button>
))}
diff --git a/apps/web/src/components/group-header/index.tsx b/apps/web/src/components/group-header/index.tsx
index e1be4dc01..6ca99e04b 100644
--- a/apps/web/src/components/group-header/index.tsx
+++ b/apps/web/src/components/group-header/index.tsx
@@ -309,21 +309,20 @@ function GroupHeader(props: GroupHeaderProps) {
}
});
}}
- mx={1}
- my={1}
- py={1}
- pl={1}
- pr={0}
- bg="var(--background-secondary)"
+ // mx={1}
+ // my={1}
+ // py={1}
+ // pl={1}
+ // pr={0}
sx={{
- borderRadius: "default",
cursor: "pointer",
- border: isMenuTarget ? "1px solid" : "none",
- borderColor: isMenuTarget ? "accent" : "transparent",
+ px: 1,
+ py: 1,
+ borderBottom: "1px solid var(--border)",
+ // border: isMenuTarget ? "1px solid" : "none",
+ // borderColor: isMenuTarget ? "accent" : "transparent",
":focus": {
- border: "1px solid",
- borderColor: "accent",
- outline: "none"
+ borderColor: "accent"
},
alignItems: "center",
justifyContent: "space-between"
@@ -335,15 +334,16 @@ function GroupHeader(props: GroupHeaderProps) {
data-test-id="title"
variant="subtitle"
sx={{
- fontSize: "body",
+ fontSize: "subBody",
+ fontWeight: "medium",
color: title === "Conflicted" ? "error" : "accent"
}}
>
- {title}
+ {title.toUpperCase()}
</Text>
{index === 0 && (
- <Flex mr={1}>
+ <Flex>
{groupingKey && (
<IconButton
testId={`${groupingKey}-sort-button`}
diff --git a/apps/web/src/components/icons/index.tsx b/apps/web/src/components/icons/index.tsx
index fc111be05..fc4ed2458 100644
--- a/apps/web/src/components/icons/index.tsx
+++ b/apps/web/src/components/icons/index.tsx
@@ -221,7 +221,12 @@ import {
mdiChatQuestionOutline,
mdiNoteRemoveOutline,
mdiTabPlus,
- mdiRadar
+ mdiRadar,
+ mdiLinkBoxOutline,
+ mdiHistory,
+ mdiArrowCollapseLeft,
+ mdiArrowCollapseRight,
+ mdiHamburger
} from "@mdi/js";
import { useTheme } from "@emotion/react";
import { Theme } from "@notesnook/theme";
@@ -565,3 +570,10 @@ export const Coupon = createIcon(mdiTagOutline);
export const Support = createIcon(mdiChatQuestionOutline);
export const NewTab = createIcon(mdiTabPlus);
export const Radar = createIcon(mdiRadar);
+
+export const LinkedTo = createIcon(mdiVectorLink);
+export const ReferencedIn = createIcon(mdiLink);
+export const SessionHistory = createIcon(mdiHistory);
+export const ColorRemove = createIcon(mdiCloseCircleOutline);
+export const ExpandSidebar = createIcon(mdiArrowCollapseRight);
+export const HamburgerMenu = createIcon(mdiMenu);
diff --git a/apps/web/src/components/list-container/index.tsx b/apps/web/src/components/list-container/index.tsx
index 783be1d27..3a4ca43d4 100644
--- a/apps/web/src/components/list-container/index.tsx
+++ b/apps/web/src/components/list-container/index.tsx
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { forwardRef, useEffect, useRef, useState } from "react";
import { Flex, Button } from "@theme-ui/components";
+import { SxProp } from "@theme-ui/core";
import { Plus } from "../icons";
import {
useStore as useSelectionStore,
@@ -74,9 +75,9 @@ type ListContainerProps = {
button?: {
onClick: () => void;
};
-};
+} & SxProp;
function ListContainer(props: ListContainerProps) {
- const { group, items, context, refresh, header, button, compact } = props;
+ const { group, items, context, refresh, header, button, compact, sx } = props;
const [focusedGroupIndex, setFocusedGroupIndex] = useState(-1);
@@ -180,7 +181,7 @@ function ListContainer(props: ListContainerProps) {
return (
<Flex
variant="columnFill"
- sx={{ overflow: "hidden" }}
+ sx={{ overflow: "hidden", ...sx }}
onDragOver={(e) => e.preventDefault()}
onDrop={props.onDrop}
>
diff --git a/apps/web/src/components/list-container/list-profiles.tsx b/apps/web/src/components/list-container/list-profiles.tsx
index 3cd78320b..4ebe70448 100644
--- a/apps/web/src/components/list-container/list-profiles.tsx
+++ b/apps/web/src/components/list-container/list-profiles.tsx
@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Note from "../note";
-import Notebook from "../notebook";
import Tag from "../tag";
import TrashItem from "../trash-item";
import { db } from "../../common/db";
@@ -28,6 +27,7 @@ import { getSortValue } from "@notesnook/core";
import { GroupingKey, Item } from "@notesnook/core";
import { isNoteResolvedData } from "@notesnook/common";
import { Attachment } from "../attachment";
+import { Notebook } from "../notebook";
const SINGLE_LINE_HEIGHT = 1.4;
const DEFAULT_LINE_HEIGHT =
@@ -57,17 +57,15 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
/>
);
}
+ case "trash":
+ return <TrashItem item={item} date={getDate(item, group)} />;
case "notebook":
return (
<Notebook
item={item}
totalNotes={typeof data === "number" ? data : 0}
- date={getDate(item, group)}
- compact={compact}
/>
);
- case "trash":
- return <TrashItem item={item} date={getDate(item, group)} />;
case "reminder":
return <Reminder item={item} compact={compact} />;
case "tag":
diff --git a/apps/web/src/components/list-item/index.tsx b/apps/web/src/components/list-item/index.tsx
index 50bedbe85..b1a644547 100644
--- a/apps/web/src/components/list-item/index.tsx
+++ b/apps/web/src/components/list-item/index.tsx
@@ -142,11 +142,9 @@ function ListItem<TItem extends Item, TContext>(
}}
tabIndex={-1}
sx={{
- pl: 1,
- pr: 2,
- py: 1,
- mb: "1px",
- height: "inherit",
+ px: 1,
+ py: isCompact ? 0 : 1,
+ height: isCompact ? 25 : "inherit",
cursor: "pointer",
position: "relative",
overflow: "hidden",
@@ -158,8 +156,8 @@ function ListItem<TItem extends Item, TContext>(
opacity: isDisabled ? 0.7 : 1,
- borderLeft: "5px solid",
- borderLeftColor: isFocused ? accent : "transparent",
+ // borderLeft: "5px solid",
+ // borderLeftColor: isFocused ? accent : "transparent",
backgroundColor: selected ? "background-selected" : background,
@@ -201,16 +199,14 @@ function ListItem<TItem extends Item, TContext>(
<Text
dir="auto"
data-test-id={`title`}
- variant={isCompact ? "body" : "subtitle"}
+ variant={"body"}
sx={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
- fontWeight: isCompact ? "body" : "bold",
+ fontWeight: isCompact ? "body" : "medium",
color:
- selected && heading === "heading"
- ? `${heading}-selected`
- : heading,
+ selected && heading === "heading" ? `heading-selected` : heading,
display: "block"
}}
>
@@ -227,6 +223,7 @@ function ListItem<TItem extends Item, TContext>(
dir="auto"
data-test-id={`description`}
sx={{
+ mt: "small",
color: selected ? "paragraph-selected" : "paragraph",
lineHeight: `1.2rem`,
overflow: "hidden",
@@ -241,15 +238,7 @@ function ListItem<TItem extends Item, TContext>(
{props.body}
</Text>
)}
- {props.footer ? (
- <Box
- ml={isCompact ? 1 : 0}
- mt={isCompact ? 0 : 1}
- sx={{ flexShrink: 0 }}
- >
- {props.footer}
- </Box>
- ) : null}
+ {props.footer ? <>{props.footer}</> : null}
</Flex>
);
}
diff --git a/apps/web/src/components/navigation-menu/index.tsx b/apps/web/src/components/navigation-menu/index.tsx
index 173a9a667..22dbd9a34 100644
--- a/apps/web/src/components/navigation-menu/index.tsx
+++ b/apps/web/src/components/navigation-menu/index.tsx
@@ -17,7 +17,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import React, {
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState
+} from "react";
import { Box, Button, Flex, Image, Text } from "@theme-ui/components";
import {
Note,
@@ -40,16 +46,29 @@ import {
Home,
Pro,
Documentation,
- Logout
+ Logout,
+ Plus,
+ SortBy,
+ Reset,
+ Rename,
+ ColorRemove,
+ ExpandSidebar,
+ HamburgerMenu
} from "../icons";
-import NavigationItem, { SortableNavigationItem } from "./navigation-item";
+import { SortableNavigationItem } from "./navigation-item";
import { hardNavigate, hashNavigate, navigate } from "../../navigation";
import { db } from "../../common/db";
-import useMobile from "../../hooks/use-mobile";
+import { isMobile } from "../../hooks/use-mobile";
import { useStore as useAppStore } from "../../stores/app-store";
import { useStore as useUserStore } from "../../stores/user-store";
import { useStore as useThemeStore } from "../../stores/theme-store";
import { useStore as useSettingStore } from "../../stores/setting-store";
+import { useStore as useNoteStore } from "../../stores/note-store";
+import { useStore as useReminderStore } from "../../stores/reminder-store";
+import { useStore as useMonographStore } from "../../stores/monograph-store";
+import { useStore as useTrashStore } from "../../stores/trash-store";
+import { useStore as useNotebookStore } from "../../stores/notebook-store";
+import { useStore as useTagStore } from "../../stores/tag-store";
import useLocation from "../../hooks/use-location";
import { FlexScrollContainer } from "../scroll-container";
import { ScopedThemeProvider } from "../theme-provider";
@@ -71,36 +90,35 @@ import {
} from "@dnd-kit/sortable";
import { usePersistentState } from "../../hooks/use-persistent-state";
import { MenuItem } from "@notesnook/ui";
-import { Notebook, Tag } from "@notesnook/core";
+import { Color, Notebook, Tag } from "@notesnook/core";
import { handleDrop } from "../../common/drop-handler";
import { Menu } from "../../hooks/use-menu";
import { RenameColorDialog } from "../../dialogs/item-dialog";
import { strings } from "@notesnook/intl";
import Tags from "../../views/tags";
-import NotebookTree from "./notebook-tree";
+import { Notebooks } from "../../views/notebooks";
import { UserProfile } from "../../dialogs/settings/components/user-profile";
import { SUBSCRIPTION_STATUS } from "../../common/constants";
import { ConfirmDialog, showLogoutConfirmation } from "../../dialogs/confirm";
-import { CREATE_BUTTON_MAP, createBackup } from "../../common";
+import { CREATE_BUTTON_MAP, createBackup, logout } from "../../common";
import { TaskManager } from "../../common/task-manager";
import { showToast } from "../../utils/toast";
-import { useStore } from "../../stores/note-store";
import { TabItem } from "./tab-item";
+import Notice from "../notice";
+import { usePromise } from "@notesnook/common";
+import { showSortMenu } from "../group-header";
+import { Freeze } from "react-freeze";
+import { logger } from "../../utils/logger";
type Route = {
- id: string;
+ id: "notes" | "favorites" | "reminders" | "monographs" | "trash";
title: string;
path: string;
icon: Icon;
tag?: string;
- count?: number;
};
-function shouldSelectNavItem(route: string, pin: Notebook | Tag) {
- return route.endsWith(pin.id);
-}
-
-const routesInit: Route[] = [
+const routes: Route[] = [
{ id: "notes", title: strings.routes.Notes(), path: "/notes", icon: Note },
{
id: "favorites",
@@ -127,14 +145,49 @@ const tabs = [
{
id: "home",
icon: Home,
- title: strings.routes.Home()
+ title: strings.routes.Home(),
+ actions: []
},
{
id: "notebook",
icon: NotebookIcon,
- title: strings.routes.Notebooks()
+ title: strings.routes.Notebooks(),
+ actions: [
+ {
+ id: "add",
+ title: CREATE_BUTTON_MAP.notebooks.title,
+ icon: Plus,
+ onClick: CREATE_BUTTON_MAP.notebooks.onClick
+ },
+ {
+ id: "sort-by",
+ title: strings.sortBy(),
+ icon: SortBy,
+ onClick: () =>
+ showSortMenu("notebooks", () => useNotebookStore.getState().refresh())
+ }
+ ]
},
- { id: "tag", icon: TagIcon, title: strings.routes.Tags() }
+ {
+ id: "tag",
+ icon: TagIcon,
+ title: strings.routes.Tags(),
+ actions: [
+ {
+ id: "add",
+ title: CREATE_BUTTON_MAP.tags.title,
+ icon: Plus,
+ onClick: CREATE_BUTTON_MAP.tags.onClick
+ },
+ {
+ id: "sort-by",
+ title: strings.sortBy(),
+ icon: SortBy,
+ onClick: () =>
+ showSortMenu("tags", () => useTagStore.getState().refresh())
+ }
+ ]
+ }
] as const;
const settings = {
@@ -144,119 +197,24 @@ const settings = {
icon: Settings
} as const;
-type NavigationMenuProps = {
- toggleNavigationContainer: (toggleState?: boolean) => void;
- isTablet: boolean;
-};
-
-function NavigationMenu(props: NavigationMenuProps) {
- const { toggleNavigationContainer, isTablet } = props;
- const [routes, setRoutes] = useState(routesInit);
- const [location] = useLocation();
+function NavigationMenu({ onExpand }: { onExpand?: () => void }) {
const isFocusMode = useAppStore((store) => store.isFocusMode);
- const colors = useAppStore((store) => store.colors);
- const shortcuts = useAppStore((store) => store.shortcuts);
- const refreshNavItems = useAppStore((store) => store.refreshNavItems);
- const isMobile = useMobile();
- const [hiddenRoutes, setHiddenRoutes] = usePersistentState(
- "sidebarHiddenItems:routes",
- db.settings.getSideBarHiddenItems("routes")
- );
- const [hiddenColors, setHiddenColors] = usePersistentState(
- "sidebarHiddenItems:colors",
- db.settings.getSideBarHiddenItems("colors")
- );
- const [currentTab, setCurrentTab] = useState<(typeof tabs)[number]["id"]>(
- tabs.find((tab) => location.includes(tab.id))?.id || "home"
- );
- const notes = useStore((store) => store.notes);
+ const [currentTab, setCurrentTab] = useState<(typeof tabs)[number]>(tabs[0]);
+ const isNavPaneCollapsed = useAppStore((store) => store.isNavPaneCollapsed);
+ const [expanded, setExpanded] = useState(false);
+ const isCollapsed = isNavPaneCollapsed && !expanded;
+ const mouseHoverTimeout = useRef(0);
useEffect(() => {
- const setCounts = async () => {
- const totalNotes = await db.notes.all.count();
- const totalFavorites = await db.notes.favorites.count();
- const totalReminders = await db.reminders.all.count();
- const totalTrash = (await db.trash.all()).length;
- const totalMonographs = await db.monographs.all.count();
-
- setRoutes((routes) => {
- return routes.map((route) => {
- switch (route.id) {
- case "notes":
- return { ...route, count: totalNotes };
- case "favorites":
- return { ...route, count: totalFavorites };
- case "reminders":
- return { ...route, count: totalReminders };
- case "trash":
- return { ...route, count: totalTrash };
- case "monographs":
- return { ...route, count: totalMonographs };
- default:
- return route;
- }
- });
- });
- };
-
- setCounts();
- }, [notes]);
-
- const dragTimeout = useRef(0);
-
- const _navigate = useCallback(
- (path: string) => {
- toggleNavigationContainer(true);
- navigate(path);
- },
- [location, toggleNavigationContainer]
- );
-
- const getSidebarItems = useCallback(async () => {
- return [
- {
- key: "reset-sidebar",
- type: "button",
- title: strings.resetSidebar(),
- onClick: () => {
- db.settings
- .setSideBarHiddenItems("routes", [])
- .then(() => db.settings.setSideBarHiddenItems("colors", []))
- .then(() => db.settings.setSideBarOrder("colors", []))
- .then(() => db.settings.setSideBarOrder("routes", []))
- .then(() => db.settings.setSideBarOrder("shortcuts", []))
- .then(() => {
- setHiddenRoutes([]);
- setHiddenColors([]);
- });
- }
- },
- { type: "separator", key: "sep" },
- ...toMenuItems(
- orderItems(routes, db.settings.getSideBarOrder("routes")),
- hiddenRoutes,
- (ids) =>
- db.settings
- .setSideBarHiddenItems("routes", ids)
- .then(() => setHiddenRoutes(ids))
- ),
- { type: "separator", key: "sep", isHidden: colors.length <= 0 },
- ...toMenuItems(
- orderItems(colors, db.settings.getSideBarOrder("colors")),
- hiddenColors,
- (ids) =>
- db.settings
- .setSideBarHiddenItems("colors", ids)
- .then(() => setHiddenColors(ids))
- )
- ] as MenuItem[];
- }, [colors, hiddenColors, hiddenRoutes]);
+ if (isNavPaneCollapsed) setExpanded(false);
+ }, [isNavPaneCollapsed]);
return (
<ScopedThemeProvider
scope="navigationMenu"
+ id="navigation-menu"
sx={{
- display: "flex",
+ display: isFocusMode ? "none" : "flex",
zIndex: 1,
position: "relative",
flex: 1,
@@ -264,103 +222,151 @@ function NavigationMenu(props: NavigationMenuProps) {
height: "100%",
overflow: "hidden",
bg: "background",
- borderRight: "1px solid var(--separator)"
+ borderRight: "1px solid var(--separator)",
+ pt: 1,
+ transition: "width 0.1s ease-in",
+ width: isNavPaneCollapsed ? (expanded ? 250 : 40) : "100%"
+ }}
+ onMouseEnter={() => {
+ clearTimeout(mouseHoverTimeout.current);
+ }}
+ onMouseLeave={() => {
+ clearTimeout(mouseHoverTimeout.current);
+ if (!isNavPaneCollapsed) return;
+ mouseHoverTimeout.current = setTimeout(() => {
+ setExpanded(false);
+ }, 500) as unknown as number;
}}
>
- <Flex
- sx={{
- flexDirection: isTablet ? "column" : "row",
- alignItems: "center",
- justifyContent: isTablet ? "center" : "space-between"
- }}
- >
+ {isCollapsed ? (
+ <Button
+ variant="secondary"
+ sx={{ p: 1, px: "small", bg: "transparent", mx: 1 }}
+ onClick={() => setExpanded(true)}
+ >
+ <HamburgerMenu size={16} color="icon" />
+ </Button>
+ ) : (
<Flex
sx={{
- flexDirection: isTablet ? "column" : "row",
+ flexDirection: "row",
alignItems: "center",
- padding: 20,
- gap: 2
+ justifyContent: "space-between",
+ mx: 1
}}
>
- <svg
- style={{
- width: isTablet ? 20 : isMobile ? 30 : 30,
- height: isTablet ? 20 : isMobile ? 30 : 30
- }}
- >
- <use href="#full-logo" />
- </svg>
- <Text
- variant="heading"
+ <Flex
sx={{
- fontSize: 16,
- display: isTablet ? "none" : "block"
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 2
}}
>
- <b>Notesnook</b>
- </Text>
+ <svg
+ style={{
+ width: 25,
+ height: 25
+ }}
+ >
+ <use href="#full-logo" />
+ </svg>
+
+ <Text
+ variant="heading"
+ sx={{
+ fontSize: 18,
+ fontWeight: "medium",
+ display: "block"
+ }}
+ >
+ Notesnook
+ </Text>
+ </Flex>
+ <Flex sx={{ gap: "small", alignItems: "center" }}>
+ {isNavPaneCollapsed ? (
+ <Button
+ variant="secondary"
+ sx={{ p: 1, bg: "transparent" }}
+ onClick={onExpand}
+ >
+ <ExpandSidebar size={13} color="icon" />
+ </Button>
+ ) : null}
+ <NavigationDropdown />
+ </Flex>
</Flex>
- <NavigationDropdown
- toggleNavigationContainer={toggleNavigationContainer}
- />
- </Flex>
+ )}
<Flex
sx={{
- flexDirection: isTablet ? "column" : "row",
- justifyContent: "center"
+ justifyContent: isCollapsed ? "center" : "space-between",
+ alignItems: "center",
+ borderTop: "1px solid var(--border)",
+ borderBottom: "1px solid var(--border)",
+ mt: 1,
+ mb: 1,
+ px: 1,
+ py: 1
}}
>
- {tabs.map((tab) => (
- <TabItem
- key={tab.id}
- id={tab.id}
- title={tab.title}
- icon={tab.icon}
- selected={currentTab === tab.id}
- onClick={() => setCurrentTab(tab.id)}
- />
- ))}
+ <Flex
+ sx={{
+ flexDirection: isCollapsed ? "column" : "row",
+ alignItems: "center",
+ gap: "small"
+ }}
+ >
+ {tabs.map((tab) => (
+ <TabItem
+ key={tab.id}
+ id={tab.id}
+ title={tab.title}
+ icon={tab.icon}
+ selected={currentTab.id === tab.id}
+ onClick={() => {
+ setExpanded(true);
+ setCurrentTab(tab);
+ }}
+ />
+ ))}
+ </Flex>
+ {!isCollapsed && currentTab.actions.length > 0 ? (
+ <Flex sx={{ alignItems: "center" }}>
+ {currentTab.actions.map((action) => (
+ <Button
+ key={action.id}
+ variant="secondary"
+ sx={{ p: 1, bg: "transparent" }}
+ onClick={action.onClick}
+ title={action.title}
+ >
+ <action.icon size={13} color="icon" />
+ </Button>
+ ))}
+ </Flex>
+ ) : null}
</Flex>
- {isTablet && (
- <Box
- bg="separator"
- my={1}
- sx={{ width: "85%", height: "0.8px", alignSelf: "center" }}
- />
- )}
+
<Flex
id="navigation-menu"
data-test-id="navigation-menu"
sx={{
- display: isFocusMode ? "none" : "flex",
flex: 1,
overflow: "hidden",
flexDirection: "column",
- justifyContent: "space-between",
- paddingLeft: isTablet ? 0 : 20,
- paddingRight: isTablet ? 0 : 20
+ justifyContent: "space-between"
}}
- px={0}
onContextMenu={async (e) => {
e.preventDefault();
- Menu.openMenu(await getSidebarItems());
+ Menu.openMenu(await getSidebarItemsAsMenuItems());
}}
>
- {currentTab === "notebook" ? (
- <NotebookTree />
- ) : currentTab === "tag" ? (
- <Flex
- sx={{ height: "100vh", gap: 2, my: 1, flexDirection: "column" }}
- >
- <Button
- onClick={CREATE_BUTTON_MAP.tags.onClick}
- variant="secondary"
- >
- {CREATE_BUTTON_MAP.tags.title}
- </Button>
- <Tags isSidebar />
- </Flex>
- ) : (
+ <Freeze freeze={isCollapsed || currentTab.id !== "notebook"}>
+ <Notebooks />
+ </Freeze>
+ <Freeze freeze={isCollapsed || currentTab.id !== "tag"}>
+ <Tags />
+ </Freeze>
+ <Freeze freeze={currentTab.id !== "home" && !isCollapsed}>
<FlexScrollContainer
style={{
flexDirection: "column",
@@ -372,231 +378,246 @@ function NavigationMenu(props: NavigationMenuProps) {
thumbStyle={() => ({ width: 3 })}
suppressScrollX={true}
>
- <Flex sx={{ flexDirection: "column" }}>
- <ReorderableList
- items={routes.filter((r) => !hiddenRoutes.includes(r.id))}
- orderKey={`sidebarOrder:routes`}
- order={() => db.settings.getSideBarOrder("routes")}
- onOrderChanged={(order) =>
- db.settings.setSideBarOrder("routes", order)
- }
- renderOverlay={({ item }) => (
- <NavigationItem
- count={item.count}
- id={item.id}
- isTablet={isTablet}
- title={item.title}
- icon={item.icon}
- tag={item.tag}
- selected={
- item.path === "/"
- ? location === item.path
- : location.startsWith(item.path)
- }
- />
- )}
- renderItem={({ item }) => (
- <SortableNavigationItem
- key={item.id}
- id={item.id}
- isTablet={isTablet}
- title={item.title}
- icon={item.icon}
- tag={item.tag}
- count={item.count}
- onDragEnter={() => {
- if (["/notebooks", "/tags"].includes(item.path))
- dragTimeout.current = setTimeout(
- () => _navigate(item.path),
- 1000
- ) as unknown as number;
- }}
- onDragLeave={() => clearTimeout(dragTimeout.current)}
- onDrop={async (e) => {
- clearTimeout(dragTimeout.current);
-
- await handleDrop(e.dataTransfer, {
- type:
- item.path === "/trash"
- ? "trash"
- : item.path === "/favorites"
- ? "favorites"
- : item.path === "/notebooks"
- ? "notebooks"
- : undefined
- });
- }}
- selected={
- item.path === "/"
- ? location === item.path
- : location.startsWith(item.path)
- }
- onClick={() => {
- if (!isMobile && location === item.path)
- return toggleNavigationContainer();
- _navigate(item.path);
- }}
- menuItems={[
- {
- type: "lazy-loader",
- key: "sidebar-items-loader",
- items: getSidebarItems
- }
- ]}
- />
- )}
- />
-
- <ReorderableList
- items={colors.filter((c) => !hiddenColors.includes(c.id))}
- orderKey={`sidebarOrder:colors`}
- order={() => db.settings.getSideBarOrder("colors")}
- onOrderChanged={(order) =>
- db.settings.setSideBarOrder("colors", order)
- }
- renderOverlay={({ item }) => (
- <NavigationItem
- id={item.id}
- isTablet={isTablet}
- title={item.title}
- icon={Circle}
- color={item.colorCode}
- count={item.count}
- selected={location === `/colors/${item.id}`}
- />
- )}
- renderItem={({ item: color }) => (
- <SortableNavigationItem
- id={color.id}
- isTablet={isTablet}
- key={color.id}
- title={color.title}
- count={color.count}
- icon={Circle}
- selected={location === `/colors/${color.id}`}
- color={color.colorCode}
- onClick={() => {
- _navigate(`/colors/${color.id}`);
- }}
- onDrop={(e) => handleDrop(e.dataTransfer, color)}
- menuItems={[
- {
- type: "button",
- key: "rename-color",
- title: strings.renameColor(),
- onClick: () => RenameColorDialog.show(color)
- },
- {
- type: "button",
- key: "remove-color",
- title: strings.removeColor(),
- onClick: async () => {
- await db.colors.remove(color.id);
- await refreshNavItems();
- }
- },
- {
- type: "separator",
- key: "sep"
- },
- {
- type: "lazy-loader",
- key: "sidebar-items-loader",
- items: getSidebarItems
- }
- ]}
- />
- )}
- />
+ <Flex sx={{ flexDirection: "column", px: 1, gap: [1, 1, "small"] }}>
+ <Routes isCollapsed={isCollapsed} />
+ <Colors isCollapsed={isCollapsed} />
<Box
bg="separator"
my={1}
- sx={{ width: "85%", height: "0.8px", alignSelf: "center" }}
- />
- <ReorderableList
- items={shortcuts}
- orderKey={`sidebarOrder:shortcuts`}
- order={() => db.settings.getSideBarOrder("shortcuts")}
- onOrderChanged={(order) =>
- db.settings.setSideBarOrder("shortcuts", order)
- }
- renderOverlay={({ item }) => (
- <NavigationItem
- id={item.id}
- isTablet={isTablet}
- key={item.id}
- title={item.title}
- icon={
- item.type === "notebook"
- ? Notebook2
- : item.type === "tag"
- ? Tag2
- : Topic
- }
- isShortcut
- selected={shouldSelectNavItem(location, item)}
- />
- )}
- renderItem={({ item }) => (
- <SortableNavigationItem
- id={item.id}
- isTablet={isTablet}
- key={item.id}
- title={item.title}
- menuItems={[
- {
- type: "button",
- key: "removeshortcut",
- title: strings.doActions.remove.shortcut(1),
- onClick: async () => {
- await db.shortcuts.remove(item.id);
- refreshNavItems();
- }
- }
- ]}
- icon={
- item.type === "notebook"
- ? Notebook2
- : item.type === "tag"
- ? Tag2
- : Topic
- }
- isShortcut
- selected={shouldSelectNavItem(location, item)}
- onDrop={(e) => handleDrop(e.dataTransfer, item)}
- onClick={async () => {
- if (item.type === "notebook") {
- const root = (
- await db.notebooks.breadcrumbs(item.id)
- ).at(0);
- if (root && root.id !== item.id)
- _navigate(`/notebooks/${root.id}/${item.id}`);
- else _navigate(`/notebooks/${item.id}`);
- } else if (item.type === "tag") {
- _navigate(`/tags/${item.id}`);
- }
- }}
- />
- )}
+ sx={{ width: "100%", height: "0.8px", alignSelf: "center" }}
/>
+ <Shortcuts isCollapsed={isCollapsed} />
</Flex>
</FlexScrollContainer>
- )}
+ </Freeze>
</Flex>
+ {currentTab.id === "home" && !isCollapsed ? <Notice /> : null}
</ScopedThemeProvider>
);
}
-export default NavigationMenu;
+export default React.memo(NavigationMenu);
-type NavigationDropdownProps = {
- toggleNavigationContainer: NavigationMenuProps["toggleNavigationContainer"];
-};
+function Routes({ isCollapsed }: { isCollapsed?: boolean }) {
+ const hiddenRoutes = useAppStore((store) => store.hiddenRoutes);
+ return (
+ <ReorderableList
+ items={routes.filter((r) => !hiddenRoutes.includes(r.id))}
+ orderKey={`sidebarOrder:routes`}
+ order={() => db.settings.getSideBarOrder("routes")}
+ onOrderChanged={(order) => db.settings.setSideBarOrder("routes", order)}
+ context={{ isCollapsed }}
+ renderItem={RouteItem}
+ />
+ );
+}
-function NavigationDropdown({
- toggleNavigationContainer
-}: NavigationDropdownProps) {
- const isMobile = useMobile();
+function RouteItem({
+ item,
+ context
+}: {
+ item: Route;
+ context?: { isCollapsed: boolean };
+}) {
const [location] = useLocation();
+
+ return (
+ <SortableNavigationItem
+ key={item.id}
+ id={item.id}
+ title={item.title}
+ icon={item.icon}
+ isCollapsed={context?.isCollapsed}
+ onDrop={async (e) => {
+ await handleDrop(e.dataTransfer, {
+ type:
+ item.path === "/trash"
+ ? "trash"
+ : item.path === "/favorites"
+ ? "favorites"
+ : undefined
+ });
+ }}
+ selected={
+ item.path === "/"
+ ? location === item.path
+ : location.startsWith(item.path)
+ }
+ onClick={() => {
+ if (!isMobile() && location === item.path)
+ return useAppStore.getState().toggleListPane();
+ navigateToRoute(item.path);
+ }}
+ menuItems={[
+ {
+ type: "lazy-loader",
+ key: "sidebar-items-loader",
+ items: getSidebarItemsAsMenuItems
+ }
+ ]}
+ >
+ <ItemCount item={item} />
+ </SortableNavigationItem>
+ );
+}
+
+function Colors({ isCollapsed }: { isCollapsed?: boolean }) {
+ const colors = useAppStore((store) => store.colors);
+ const refreshNavItems = useAppStore((store) => store.refreshNavItems);
+ const context = useNoteStore((store) =>
+ store.context?.type === "color" ? store.context : null
+ );
+ const hiddenColors = useAppStore((store) => store.hiddenColors);
+
+ return (
+ <ReorderableList
+ items={colors.filter((c) => !hiddenColors.includes(c.id))}
+ orderKey={`sidebarOrder:colors`}
+ order={() => db.settings.getSideBarOrder("colors")}
+ onOrderChanged={(order) => db.settings.setSideBarOrder("colors", order)}
+ renderItem={({ item: color }) => (
+ <SortableNavigationItem
+ id={color.id}
+ key={color.id}
+ title={color.title}
+ isCollapsed={isCollapsed}
+ icon={Circle}
+ selected={context?.id === color.id}
+ color={color.colorCode}
+ onClick={() => {
+ navigateToRoute(`/colors/${color.id}`);
+ }}
+ onDrop={(e) => handleDrop(e.dataTransfer, color)}
+ menuItems={[
+ {
+ type: "button",
+ key: "rename-color",
+ title: strings.renameColor(),
+ onClick: () => RenameColorDialog.show(color),
+ icon: Rename.path
+ },
+ {
+ type: "button",
+ key: "remove-color",
+ title: strings.removeColor(),
+ onClick: async () => {
+ await db.colors.remove(color.id);
+ await refreshNavItems();
+ },
+ icon: ColorRemove.path
+ },
+ {
+ type: "separator",
+ key: "sep"
+ },
+ {
+ type: "lazy-loader",
+ key: "sidebar-items-loader",
+ items: getSidebarItemsAsMenuItems
+ }
+ ]}
+ >
+ <ItemCount item={color} />
+ </SortableNavigationItem>
+ )}
+ />
+ );
+}
+
+function Shortcuts({ isCollapsed }: { isCollapsed?: boolean }) {
+ const shortcuts = useAppStore((store) => store.shortcuts);
+ const refreshNavItems = useAppStore((store) => store.refreshNavItems);
+ const context = useNoteStore((store) =>
+ store.context?.type === "tag" || store.context?.type === "notebook"
+ ? store.context
+ : null
+ );
+
+ return (
+ <ReorderableList
+ items={shortcuts}
+ orderKey={`sidebarOrder:shortcuts`}
+ order={() => db.settings.getSideBarOrder("shortcuts")}
+ onOrderChanged={(order) =>
+ db.settings.setSideBarOrder("shortcuts", order)
+ }
+ renderItem={({ item }) => (
+ <SortableNavigationItem
+ id={item.id}
+ key={item.id}
+ title={item.title}
+ isCollapsed={isCollapsed}
+ menuItems={[
+ {
+ type: "button",
+ key: "removeshortcut",
+ title: strings.doActions.remove.shortcut(1),
+ onClick: async () => {
+ await db.shortcuts.remove(item.id);
+ refreshNavItems();
+ }
+ }
+ ]}
+ icon={
+ item.type === "notebook"
+ ? Notebook2
+ : item.type === "tag"
+ ? Tag2
+ : Topic
+ }
+ selected={context?.id === item.id}
+ onDrop={(e) => handleDrop(e.dataTransfer, item)}
+ onClick={async () => {
+ if (item.type === "notebook") {
+ navigateToRoute(`/notebooks/${item.id}`);
+ } else if (item.type === "tag") {
+ navigateToRoute(`/tags/${item.id}`);
+ }
+ }}
+ >
+ <ItemCount item={item} />
+ </SortableNavigationItem>
+ )}
+ />
+ );
+}
+
+function ItemCount({ item }: { item: Route | Color | Notebook | Tag }) {
+ const notes = useNoteStore((store) => store.notes?.length || 0);
+ const reminders = useReminderStore((store) => store.reminders?.length || 0);
+ const trash = useTrashStore((store) => store.trash?.length || 0);
+ const monographs = useMonographStore(
+ (store) => store.monographs?.length || 0
+ );
+ const count = usePromise(() => {
+ if ("type" in item) {
+ if (item.type === "color") return db.colors.count(item.id);
+ else if (item.type === "notebook" || item.type === "tag")
+ return db.relations.from(item, "note").count();
+ } else {
+ switch (item.id) {
+ case "notes":
+ return notes;
+ case "favorites":
+ return db.notes.favorites.count();
+ case "reminders":
+ return reminders;
+ case "trash":
+ return trash;
+ case "monographs":
+ return monographs;
+ default:
+ return 0;
+ }
+ }
+ }, [notes, trash, monographs, reminders]);
+ return (
+ <Text variant="subBody">
+ {count.status === "fulfilled" ? count.value : ""}
+ </Text>
+ );
+}
+
+function NavigationDropdown() {
const user = useUserStore((store) => store.user);
const profile = useSettingStore((store) => store.profile);
const theme = useThemeStore((store) => store.colorScheme);
@@ -637,14 +658,6 @@ function NavigationDropdown({
type: "separator",
key: "sep"
},
- {
- type: "button",
- title: strings.login(),
- icon: Login.path,
- key: "login",
- isHidden: !notLoggedIn,
- onClick: () => hardNavigate("/login")
- },
{
type: "button",
title: strings.toggleDarkLightMode(),
@@ -668,9 +681,6 @@ function NavigationDropdown({
key: settings.id,
icon: settings.icon.path,
onClick: () => {
- if (!isMobile && location === settings.path) {
- return toggleNavigationContainer();
- }
hashNavigate(settings.path);
}
},
@@ -683,41 +693,21 @@ function NavigationDropdown({
window.open("https://help.notesnook.com/", "_blank");
}
},
+ {
+ type: "button",
+ title: strings.login(),
+ icon: Login.path,
+ key: "login",
+ isHidden: !notLoggedIn,
+ onClick: () => hardNavigate("/login")
+ },
{
type: "button",
title: strings.logout(),
icon: Logout.path,
key: "logout",
isHidden: notLoggedIn,
- onClick: async () => {
- const result = await showLogoutConfirmation();
- if (!result) return;
-
- if (result.backup) {
- try {
- await createBackup({ mode: "partial" });
- } catch (e) {
- logger.error(e, "Failed to take backup before logout");
- if (
- !(await ConfirmDialog.show({
- title: strings.failedToTakeBackup(),
- message: strings.failedToTakeBackupMessage(),
- negativeButtonText: strings.no(),
- positiveButtonText: strings.yes()
- }))
- )
- return;
- }
- }
-
- await TaskManager.startTask({
- type: "modal",
- title: strings.loggingOut(),
- subtitle: strings.pleaseWait(),
- action: () => db.user.logout(true)
- });
- showToast("success", strings.loggedOut());
- }
+ onClick: () => logout()
}
],
{
@@ -731,20 +721,17 @@ function NavigationDropdown({
}}
variant="columnCenter"
sx={{
- bg: "shade",
- mr: 2,
- size: 35,
+ bg: "background-secondary",
+ size: 30,
borderRadius: 80,
cursor: "pointer",
position: "relative",
- outline: "1px solid var(--accent)",
- ":hover": {
- outline: "2px solid var(--accent)"
- }
+ border: "1px solid var(--border)",
+ alignItems: "center"
}}
>
{!user || !user.id || !profile?.profilePicture ? (
- <User size={30} />
+ <User size={16} color="icon" />
) : (
<Image
sx={{
@@ -764,8 +751,8 @@ function NavigationDropdown({
type ReorderableListProps<T> = {
orderKey: string;
items: T[];
- renderItem: (props: { item: T }) => JSX.Element;
- renderOverlay: (props: { item: T }) => JSX.Element;
+ context?: any;
+ renderItem: (props: { item: T; context?: any }) => JSX.Element;
onOrderChanged: (newOrder: string[]) => void;
order: () => string[];
};
@@ -777,8 +764,8 @@ function ReorderableList<T extends { id: string }>(
orderKey,
items,
renderItem: Item,
- renderOverlay: Overlay,
onOrderChanged,
+ context,
order: _order
} = props;
const sensors = useSensors(
@@ -839,7 +826,7 @@ function ReorderableList<T extends { id: string }>(
strategy={verticalListSortingStrategy}
>
{orderedItems.map((item) => (
- <Item key={item.id} item={item} />
+ <Item key={item.id} item={item} context={context} />
))}
<DragOverlay
@@ -848,7 +835,7 @@ function ReorderableList<T extends { id: string }>(
easing: "cubic-bezier(0.18, 0.67, 0.6, 1.22)"
}}
>
- {activeItem && <Overlay item={activeItem} />}
+ {activeItem && <Item item={activeItem} context={context} />}
</DragOverlay>
</SortableContext>
</DndContext>
@@ -869,9 +856,11 @@ function orderItems<T extends { id: string }>(items: T[], order: string[]) {
function toMenuItems<T extends { id: string; title: string }>(
items: T[],
hiddenIds: string[],
- onHiddenIdsUpdated: (ids: string[]) => void
+ onHiddenIdsUpdated: (ids: string[]) => void,
+ extraProps?: (item: T) => Partial<MenuItem>
): MenuItem[] {
return items.map((item) => ({
+ ...extraProps?.(item),
type: "button",
key: item.id,
title: item.title,
@@ -885,3 +874,57 @@ function toMenuItems<T extends { id: string; title: string }>(
}
}));
}
+
+async function getSidebarItemsAsMenuItems(): Promise<MenuItem[]> {
+ const colors = useAppStore.getState().colors;
+ const hiddenColors = useAppStore.getState().hiddenColors;
+ const hiddenRoutes = useAppStore.getState().hiddenRoutes;
+ return [
+ {
+ key: "reset-sidebar",
+ type: "button",
+ title: strings.resetSidebar(),
+ onClick: () => {
+ db.settings
+ .setSideBarHiddenItems("routes", [])
+ .then(() => db.settings.setSideBarHiddenItems("colors", []))
+ .then(() => db.settings.setSideBarOrder("colors", []))
+ .then(() => db.settings.setSideBarOrder("routes", []))
+ .then(() => db.settings.setSideBarOrder("shortcuts", []))
+ .then(() => {
+ useAppStore.getState().setHiddenRoutes([]);
+ useAppStore.getState().setHiddenColors([]);
+ });
+ },
+ icon: Reset.path
+ },
+ { type: "separator", key: "sep" },
+ ...toMenuItems(
+ orderItems(routes, db.settings.getSideBarOrder("routes")),
+ hiddenRoutes,
+ (ids) =>
+ db.settings
+ .setSideBarHiddenItems("routes", ids)
+ .then(() => useAppStore.getState().setHiddenRoutes(ids)),
+ (item) => ({ icon: item.icon.path })
+ ),
+ { type: "separator", key: "sep", isHidden: colors.length <= 0 },
+ ...toMenuItems(
+ orderItems(colors, db.settings.getSideBarOrder("colors")),
+ hiddenColors,
+ (ids) =>
+ db.settings
+ .setSideBarHiddenItems("colors", ids)
+ .then(() => useAppStore.getState().setHiddenColors(ids)),
+ (item) => ({
+ icon: Circle.path,
+ styles: { icon: { color: item.colorCode } }
+ })
+ )
+ ] as MenuItem[];
+}
+
+function navigateToRoute(path: string) {
+ useAppStore.getState().toggleListPane(true);
+ navigate(path);
+}
diff --git a/apps/web/src/components/navigation-menu/navigation-item.tsx b/apps/web/src/components/navigation-menu/navigation-item.tsx
index ce9ac41fb..2cddb3380 100644
--- a/apps/web/src/components/navigation-menu/navigation-item.tsx
+++ b/apps/web/src/components/navigation-menu/navigation-item.tsx
@@ -17,11 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { Button, Flex, FlexProps, Image, Text } from "@theme-ui/components";
+import { Button, Flex, FlexProps, Text } from "@theme-ui/components";
import { Menu } from "../../hooks/use-menu";
-import useMobile from "../../hooks/use-mobile";
import { PropsWithChildren } from "react";
-import { Icon, Shortcut } from "../icons";
+import { Icon } from "../icons";
import { SchemeColors, createButtonVariant } from "@notesnook/theme";
import { MenuItem } from "@notesnook/ui";
import { useSortable } from "@dnd-kit/sortable";
@@ -30,16 +29,12 @@ import { AppEventManager, AppEvents } from "../../common/app-events";
type NavigationItemProps = {
icon?: Icon;
- image?: string;
color?: SchemeColors;
title?: string;
- isTablet?: boolean;
+ isCollapsed?: boolean;
isLoading?: boolean;
- isShortcut?: boolean;
- tag?: string;
selected?: boolean;
onClick?: () => void;
- count?: number;
menuItems?: MenuItem[];
};
@@ -50,23 +45,18 @@ function NavigationItem(
) {
const {
icon: Icon,
- image,
color,
title,
isLoading,
- isShortcut,
- tag,
children,
- isTablet,
+ isCollapsed,
selected,
onClick,
menuItems,
- count,
sx,
containerRef,
...restProps
} = props;
- const isMobile = useMobile();
return (
<Flex
@@ -87,118 +77,60 @@ function NavigationItem(
}
),
borderRadius: "default",
- mx: 1,
- p: 0,
- mt: isTablet ? 1 : "3px",
+ px: isCollapsed ? 1 : 2,
+ height: 25,
alignItems: "center",
position: "relative",
- ":first-of-type": { mt: 1 },
- ":last-of-type": { mb: 1 },
":focus": { bg: selected ? "hover-selected" : "hover" },
...sx
- // ":hover:not(:disabled)": {
- // bg: "hover",
- // filter: "brightness(100%)"
- // }
}}
+ onClick={() => {
+ AppEventManager.publish(AppEvents.toggleSideMenu, false);
+ if (onClick) onClick();
+ }}
+ title={title}
>
<Button
data-test-id={`navigation-item`}
sx={{
- px: isTablet ? 1 : 2,
+ p: 0,
flex: 1,
alignItems: "center",
- justifyContent: isTablet ? "center" : "flex-start",
+ justifyContent: "flex-start",
display: "flex"
}}
- title={title}
onContextMenu={(e) => {
if (!menuItems) return;
e.preventDefault();
e.stopPropagation();
Menu.openMenu(menuItems);
}}
- onClick={() => {
- AppEventManager.publish(AppEvents.toggleSideMenu, false);
- if (onClick) onClick();
- }}
>
- {image ? (
- <Image
- src={image}
- sx={{ borderRadius: 50, size: 20, minWidth: 20, flexShrink: 0 }}
- />
- ) : Icon ? (
+ {Icon ? (
<Icon
- size={isTablet ? 16 : 20}
+ size={14}
color={color || (selected ? "icon-selected" : "icon")}
rotate={isLoading}
/>
) : null}
- {isShortcut && (
- <Shortcut
- size={8}
- sx={{ position: "absolute", bottom: "8px", left: "6px" }}
- color={color || "icon"}
- data-test-id="shortcut"
- />
- )}
<Text
variant="body"
sx={{
+ display: isCollapsed ? "none" : "block",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
- fontWeight: selected ? "bold" : "normal",
- color: selected ? "paragraph-selected" : "paragraph",
- display: isTablet ? "none" : "block"
+ fontWeight: "normal",
+ color: selected ? "paragraph-selected" : "paragraph"
}}
ml={1}
data-test-id="title"
>
{title}
- {/* {tag && (
- <Text
- variant="subBody"
- as="span"
- sx={{
- bg: "accent",
- color: "white",
- ml: 1,
- px: "small",
- borderRadius: "default"
- }}
- >
- {tag}
- </Text>
- )} */}
</Text>
</Button>
- {children ? (
- children
- ) : !isTablet && count !== undefined ? (
- <Text
- variant="subBody"
- sx={{
- mr: 1,
- px: "3px",
- borderRadius: "default"
- }}
- >
- {count > 100 ? "100+" : count}
- </Text>
- ) : !isTablet && tag ? (
- <Text
- variant="subBody"
- sx={{
- mr: 1,
- borderRadius: "100px"
- }}
- >
- {tag}
- </Text>
- ) : null}
+ {children && !isCollapsed ? children : null}
</Flex>
);
}
diff --git a/apps/web/src/components/navigation-menu/notebook-tree.tsx b/apps/web/src/components/navigation-menu/notebook-tree.tsx
deleted file mode 100644
index 89a936b68..000000000
--- a/apps/web/src/components/navigation-menu/notebook-tree.tsx
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-This file is part of the Notesnook project (https://notesnook.com/)
-
-Copyright (C) 2023 Streetwriters (Private) Limited
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import { Notebook } from "@notesnook/core";
-import { Button, Flex } from "@theme-ui/components";
-import { useEffect, useRef, useState } from "react";
-import { CREATE_BUTTON_MAP } from "../../common";
-import { db } from "../../common/db";
-import { store, useStore } from "../../stores/notebook-store";
-import { useStore as useSelectionStore } from "../../stores/selection-store";
-import Placeholder from "../placeholders";
-import SubNotebook from "../sub-notebook";
-import {
- TreeNode,
- VirtualizedTree,
- VirtualizedTreeHandle
-} from "../virtualized-tree";
-import { ListLoader } from "../loaders/list-loader";
-
-function NotebookTree() {
- const notebooks = useStore((state) => state.notebooks);
- const createButton = CREATE_BUTTON_MAP.notebooks;
-
- useEffect(() => {
- store.get().refresh();
- }, []);
-
- if (!notebooks) return <ListLoader />;
- if (notebooks.length === 0) {
- return (
- <Flex variant="columnCenterFill" data-test-id="list-placeholder">
- <Placeholder context="notebooks" />
- </Flex>
- );
- }
- return (
- <Flex sx={{ gap: 2, flexDirection: "column", my: 1 }}>
- <Button variant="secondary" onClick={createButton.onClick}>
- {createButton.title}
- </Button>
- <div style={{ height: "100vh" }}>
- <Tree />
- </div>
- </Flex>
- );
-}
-export default NotebookTree;
-
-function Tree() {
- const treeRef =
- useRef<VirtualizedTreeHandle<{ notebook: Notebook; totalNotes: number }>>(
- null
- );
- const setSelectedItems = useSelectionStore((store) => store.setSelectedItems);
- const isSelected = useSelectionStore((store) => store.isSelected);
- const selectItem = useSelectionStore((store) => store.selectItem);
- const deselectItem = useSelectionStore((store) => store.deselectItem);
- const toggleSelection = useSelectionStore(
- (store) => store.toggleSelectionMode
- );
- const notebooks = useStore((store) => store.notebooks);
- const [notebookIds, setNotebookIds] = useState<string[]>([]);
-
- useEffect(() => {
- notebooks?.ids().then((ids) => setNotebookIds(ids));
- treeRef.current?.refresh();
- }, [notebooks]);
-
- return (
- <Flex
- id="notebook-tree"
- variant="columnFill"
- sx={{
- height: "100%"
- }}
- >
- {notebookIds.length > 0 && (
- <VirtualizedTree
- rootId={"root"}
- itemHeight={30}
- treeRef={treeRef}
- deselectAll={() => toggleSelection(false)}
- bulkSelect={setSelectedItems}
- isSelected={isSelected}
- onDeselect={deselectItem}
- onSelect={selectItem}
- saveKey="notebook-tree"
- getChildNodes={async (id, depth) => {
- const nodes: TreeNode<{
- notebook: Notebook;
- totalNotes: number;
- }>[] = [];
- if (id === "root") {
- for (const id of notebookIds) {
- const notebook = (await db.notebooks.notebook(id))!;
- const totalNotes = await db.relations
- .from(notebook, "note")
- .count();
- const children = await db.relations
- .from(notebook, "notebook")
- .count();
- nodes.push({
- data: { notebook, totalNotes },
- depth: depth + 1,
- hasChildren: children > 0,
- id,
- parentId: "root"
- });
- }
- return nodes;
- }
-
- const subNotebooks = await db.relations
- .from({ type: "notebook", id }, "notebook")
- .resolve();
-
- for (const notebook of subNotebooks) {
- const hasChildren =
- (await db.relations.from(notebook, "notebook").count()) > 0;
- const totalNotes = await db.relations
- .from(notebook, "note")
- .count();
- nodes.push({
- parentId: id,
- id: notebook.id,
- data: { notebook, totalNotes },
- depth: depth + 1,
- hasChildren
- });
- }
-
- return nodes;
- }}
- renderItem={({ collapse, expand, expanded, index, item: node }) => (
- <SubNotebook
- depth={node.depth}
- isExpandable={node.hasChildren}
- item={node.data.notebook}
- isExpanded={expanded}
- rootId={node.parentId}
- totalNotes={node.data.totalNotes}
- refresh={async () => {
- const notebook = await db.notebooks.notebook(node.id);
- const totalNotes = await db.relations
- .from(node.data.notebook, "note")
- .count();
- treeRef.current?.refreshItem(
- index,
- notebook ? { notebook, totalNotes } : undefined
- );
- }}
- collapse={collapse}
- expand={expand}
- />
- )}
- />
- )}
- </Flex>
- );
-}
diff --git a/apps/web/src/components/navigation-menu/tab-item.tsx b/apps/web/src/components/navigation-menu/tab-item.tsx
index 32d88b17e..94a8055c7 100644
--- a/apps/web/src/components/navigation-menu/tab-item.tsx
+++ b/apps/web/src/components/navigation-menu/tab-item.tsx
@@ -19,22 +19,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { createButtonVariant } from "@notesnook/theme";
import { Button, Flex, FlexProps } from "@theme-ui/components";
-import { PropsWithChildren } from "react";
import { Icon } from "../icons";
type TabItemProps = {
- icon?: Icon;
+ icon: Icon;
title?: string;
selected?: boolean;
onClick?: () => void;
};
-export function TabItem(props: PropsWithChildren<TabItemProps & FlexProps>) {
+export function TabItem(props: TabItemProps & FlexProps) {
const {
icon: Icon,
color,
title,
- children,
selected,
onClick,
sx,
@@ -55,13 +53,9 @@ export function TabItem(props: PropsWithChildren<TabItemProps & FlexProps>) {
}
),
borderRadius: "default",
- mx: 1,
p: 0,
- mt: "3px",
alignItems: "center",
position: "relative",
- ":first-of-type": { mt: 1 },
- ":last-of-type": { mb: 1 },
":focus": { bg: selected ? "hover-selected" : "hover" },
...sx
}}
@@ -69,7 +63,7 @@ export function TabItem(props: PropsWithChildren<TabItemProps & FlexProps>) {
<Button
data-test-id={`tab-item`}
sx={{
- px: 2,
+ p: 1,
flex: 1,
alignItems: "center",
justifyContent: "flex-start",
@@ -80,12 +74,10 @@ export function TabItem(props: PropsWithChildren<TabItemProps & FlexProps>) {
if (onClick) onClick();
}}
>
- {Icon ? (
- <Icon
- size={20}
- color={color || (selected ? "icon-selected" : "icon")}
- />
- ) : null}
+ <Icon
+ size={16}
+ color={color || (selected ? "icon-selected" : "icon")}
+ />
</Button>
</Flex>
);
diff --git a/apps/web/src/components/note/index.tsx b/apps/web/src/components/note/index.tsx
index 8ab0d70bf..efe4babfb 100644
--- a/apps/web/src/components/note/index.tsx
+++ b/apps/web/src/components/note/index.tsx
@@ -20,13 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import {
NoteResolvedData,
exportContent,
+ getFormattedDate,
getFormattedReminderTime
} from "@notesnook/common";
import {
Color,
Note as NoteType,
Notebook as NotebookItem,
- Tag,
+ Tag as TagType,
createInternalLink,
hosts,
isReminderActive,
@@ -87,6 +88,7 @@ import {
StarOutline,
Sync,
SyncOff,
+ Tag,
Tag2,
Tag as TagIcon,
Trash,
@@ -152,35 +154,8 @@ function Note(props: NoteProps) {
useEditorStore.getState().openSession(note, { openInNewTab: true })
}
header={
- <Flex
- sx={{ alignItems: "center", flexWrap: "wrap", gap: 1, mt: "small" }}
- >
- {context?.type !== "notebook" &&
- notebooks?.items.map((notebook) => (
- <IconTag
- key={notebook.id}
- onClick={() => {
- navigate(`/notebooks/${notebook.id}`);
- }}
- text={notebook.title}
- icon={Notebook}
- />
- ))}
- {reminder && isReminderActive(reminder) ? (
- <IconTag
- icon={Reminder}
- text={getFormattedReminderTime(reminder, true)}
- title={reminder.title}
- styles={
- isReminderToday(reminder)
- ? {
- icon: { color: primary },
- text: { color: primary }
- }
- : {}
- }
- />
- ) : null}
+ <Flex sx={{ alignItems: "center", mb: 1 }}>
+ <Text variant="subBody">{getFormattedDate(date, "date")}</Text>
</Flex>
}
footer={
@@ -189,7 +164,9 @@ function Note(props: NoteProps) {
fontSize: "subBody",
color: "paragraph-secondary",
alignItems: "center",
- gap: 1
+ gap: 1,
+ flexWrap: "wrap",
+ mt: "small"
}}
>
{compact ? (
@@ -206,12 +183,12 @@ function Note(props: NoteProps) {
{note.localOnly && <SyncOff size={13} />}
- <TimeAgo
+ {/* <TimeAgo
sx={{ flexShrink: 0 }}
locale="en_short"
live={true}
datetime={date}
- />
+ /> */}
{attachments?.total ? (
<Flex sx={{ alignItems: "center", justifyContent: "center" }}>
@@ -229,9 +206,7 @@ function Note(props: NoteProps) {
</Flex>
) : null}
- {note.pinned && !props.context && (
- <Pin size={13} color={primary} />
- )}
+ {note.pinned && !props.context && <Pin size={13} />}
{locked && <Lock size={13} data-test-id={`locked`} />}
@@ -243,28 +218,49 @@ function Note(props: NoteProps) {
{tags?.items.map((tag) => {
return (
- <Button
- data-test-id={`tag-item`}
+ <IconTag
+ testId={`tag-item`}
key={tag.id}
- variant="anchor"
- title={strings.goToTag(tag.title)}
onClick={(e) => {
e.stopPropagation();
if (!tag.id)
return showToast("error", strings.tagNotFound());
navigate(`/tags/${tag.id}`);
}}
- sx={{
- maxWidth: `calc(100% / ${tags.items.length})`,
- overflow: "hidden",
- textOverflow: "ellipsis",
- color: "var(--paragraph-secondary)"
- }}
- >
- #{tag.title}
- </Button>
+ text={tag.title}
+ title={strings.goToTag(tag.title)}
+ icon={TagIcon}
+ />
);
})}
+
+ {context?.type !== "notebook" &&
+ notebooks?.items.map((notebook) => (
+ <IconTag
+ key={notebook.id}
+ onClick={() => {
+ navigate(`/notebooks/${notebook.id}`);
+ }}
+ text={notebook.title}
+ icon={Notebook}
+ />
+ ))}
+
+ {reminder && isReminderActive(reminder) ? (
+ <IconTag
+ icon={Reminder}
+ text={getFormattedReminderTime(reminder, true)}
+ title={reminder.title}
+ styles={
+ isReminderToday(reminder)
+ ? {
+ icon: { color: primary },
+ text: { color: primary }
+ }
+ : {}
+ }
+ />
+ ) : null}
</>
)}
</Flex>
@@ -747,8 +743,8 @@ function tagsMenuItems(ids: string[]): MenuItem[] {
type: "lazy-loader",
key: "tags-lazy-loader",
async items() {
- const tags: Map<string, Tag> = new Map();
- const tagShortcuts: Map<string, Tag> = new Map();
+ const tags: Map<string, TagType> = new Map();
+ const tagShortcuts: Map<string, TagType> = new Map();
const linkedTags = await db.relations
.to({ ids, type: "note" }, "tag")
diff --git a/apps/web/src/components/notebook-header.tsx b/apps/web/src/components/notebook-header.tsx
new file mode 100644
index 000000000..39d99c84c
--- /dev/null
+++ b/apps/web/src/components/notebook-header.tsx
@@ -0,0 +1,136 @@
+/*
+This file is part of the Notesnook project (https://notesnook.com/)
+
+Copyright (C) 2023 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+import { useEffect, useState } from "react";
+import { useStore as useAppStore } from "../stores/app-store";
+import { hashNavigate } from "../navigation";
+import { Button, Flex, Text } from "@theme-ui/components";
+import { Edit, RemoveShortcutLink, ShortcutLink } from "./icons";
+import { useStore as useNotebookStore } from "../stores/notebook-store";
+import { db } from "../common/db";
+import { getFormattedDate } from "@notesnook/common";
+import { strings } from "@notesnook/intl";
+import { Notebook } from "@notesnook/core";
+import { TITLE_BAR_HEIGHT } from "./title-bar";
+
+export function NotebookHeader(props: {
+ notebook: Notebook;
+ totalNotes?: number;
+}) {
+ // const moreCrumbsRef = useRef<HTMLButtonElement>(null);
+ const notebooks = useNotebookStore((store) => store.notebooks);
+ const [notebook, setNotebook] = useState<Notebook | undefined>(
+ props.notebook
+ );
+ const [totalNotes, setTotalNotes] = useState(props.totalNotes);
+ // const [crumbs, setCrumbs] = useState<{ id: string; title: string }[]>([]);
+ const [isShortcut, setIsShortcut] = useState(false);
+ const shortcuts = useAppStore((store) => store.shortcuts);
+ const addToShortcuts = useAppStore((store) => store.addToShortcuts);
+
+ useEffect(() => {
+ setIsShortcut(shortcuts.findIndex((p) => p.id === props.notebook.id) > -1);
+ }, [shortcuts, props.notebook.id]);
+
+ useEffect(() => {
+ (async function () {
+ setNotebook(await db.notebooks.notebook(props.notebook.id));
+ })();
+ }, [notebooks, props.notebook]);
+
+ useEffect(() => {
+ if (props.totalNotes === undefined)
+ db.relations
+ .from(props.notebook, "note")
+ .count()
+ .then((count) => setTotalNotes(count));
+ else setTotalNotes(props.totalNotes);
+ }, [props.notebook, props.totalNotes]);
+
+ // useEffect(() => {
+ // (async function () {
+ // setCrumbs(await db.notebooks.breadcrumbs(context.id));
+ // })();
+ // }, [context.id]);
+
+ if (!notebook) return null;
+ const { title, description, dateEdited } = notebook;
+
+ return (
+ <Flex
+ data-test-id="notebook-header"
+ sx={{
+ flexDirection: "column",
+ p: 1,
+ pb: 4,
+ bg: "var(--background-secondary)",
+ borderBottom: "1px solid var(--border)"
+ }}
+ >
+ <Flex sx={{ alignItems: "center", justifyContent: "space-between" }}>
+ <Flex sx={{ alignItems: "center", gap: 2 }}>
+ <Text variant="subBody">{getFormattedDate(dateEdited, "date")}</Text>
+ <Text variant="subBody">{strings.notes(totalNotes || 0)}</Text>
+ </Flex>
+ <Flex sx={{ alignItems: "center", gap: 1 }}>
+ <Button
+ variant="secondary"
+ sx={{
+ borderRadius: 100,
+ p: 1
+ }}
+ title={
+ isShortcut ? strings.removeShortcut() : strings.createShortcut()
+ }
+ onClick={() => addToShortcuts(notebook)}
+ >
+ {isShortcut ? (
+ <RemoveShortcutLink size={16} />
+ ) : (
+ <ShortcutLink size={14} />
+ )}
+ </Button>
+ <Button
+ variant="secondary"
+ sx={{
+ borderRadius: 100,
+ p: 1
+ }}
+ title={strings.editNotebook()}
+ onClick={() => hashNavigate(`/notebooks/${notebook.id}/edit`)}
+ >
+ <Edit size={14} />
+ </Button>
+ </Flex>
+ </Flex>
+ <Text
+ data-test-id="notebook-title"
+ variant="heading"
+ sx={{ fontSize: "title", mt: 2 }}
+ >
+ {title}
+ </Text>
+ {description && (
+ <Text variant="body" sx={{ mt: 1 }}>
+ {description}
+ </Text>
+ )}
+ </Flex>
+ );
+}
diff --git a/apps/web/src/components/notebook/index.tsx b/apps/web/src/components/notebook/index.tsx
index 4fa6c6749..86fea7b20 100644
--- a/apps/web/src/components/notebook/index.tsx
+++ b/apps/web/src/components/notebook/index.tsx
@@ -17,59 +17,75 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import React, { useRef } from "react";
-import { Flex, Text } from "@theme-ui/components";
import ListItem from "../list-item";
-import { store } from "../../stores/notebook-store";
-import { useStore as useNotesStore } from "../../stores/note-store";
-import { store as appStore } from "../../stores/app-store";
-import { db } from "../../common/db";
+import { Button, Flex, Text } from "@theme-ui/components";
+import { store, useStore as useNotesStore } from "../../stores/note-store";
+import { Notebook as NotebookType } from "@notesnook/core";
import {
- Topic as TopicIcon,
- PinFilled,
+ ChevronDown,
+ ChevronRight,
NotebookEdit,
- Notebook as NotebookIcon,
Pin,
+ Plus,
RemoveShortcutLink,
Shortcut,
- Trash
+ Trash,
+ Notebook as NotebookIcon
} from "../icons";
-import { hashNavigate, navigate } from "../../navigation";
-import IconTag from "../icon-tag";
-import { Multiselect } from "../../common/multi-select";
-import { getFormattedDate } from "@notesnook/common";
import { MenuItem } from "@notesnook/ui";
-import { Notebook as NotebookType } from "@notesnook/core";
+import { hashNavigate, navigate } from "../../navigation";
+import { useRef } from "react";
import { handleDrop } from "../../common/drop-handler";
import { useDragHandler } from "../../hooks/use-drag-handler";
+import { AddNotebookDialog } from "../../dialogs/add-notebook-dialog";
import { useStore as useSelectionStore } from "../../stores/selection-store";
+import { store as appStore } from "../../stores/app-store";
+import { Multiselect } from "../../common/multi-select";
import { strings } from "@notesnook/intl";
+import { db } from "../../common/db";
type NotebookProps = {
item: NotebookType;
- totalNotes: number;
- date: number;
- compact?: boolean;
+ totalNotes?: number;
+ isExpandable?: boolean;
+ isExpanded?: boolean;
+ expand?: () => void;
+ collapse?: () => void;
+ refresh?: () => void;
+ depth?: number;
};
-function Notebook(props: NotebookProps) {
- const { item, totalNotes, date, compact } = props;
- const notebook = item;
+export function Notebook(props: NotebookProps) {
+ const {
+ item,
+ totalNotes = 0,
+ isExpandable = false,
+ isExpanded = false,
+ expand = () => {},
+ collapse = () => {},
+ refresh = () => {},
+ depth = 0
+ } = props;
+ const isOpened = useNotesStore(
+ (store) =>
+ store.context?.type === "notebook" && store.context.id === item.id
+ );
const dragTimeout = useRef(0);
- const { isDragEntering, isDragLeaving } = useDragHandler(`id_${notebook.id}`);
+ const { isDragEntering, isDragLeaving } = useDragHandler(`id_${item.id}`);
return (
<ListItem
draggable
- isCompact={compact}
- item={notebook}
- onClick={() => openNotebook(notebook, totalNotes)}
+ isFocused={isOpened}
+ isCompact
+ item={item}
+ onClick={() => navigate(`/notebooks/${item.id}`)}
onDragEnter={(e) => {
if (!isDragEntering(e)) return;
e.currentTarget.focus();
- dragTimeout.current = setTimeout(
- () => openNotebook(notebook, totalNotes),
- 1000
- ) as unknown as number;
+
+ dragTimeout.current = setTimeout(() => {
+ expand();
+ }, 700) as unknown as number;
}}
onDragLeave={(e) => {
if (!isDragLeaving(e)) return;
@@ -77,89 +93,97 @@ function Notebook(props: NotebookProps) {
}}
onDrop={async (e) => {
clearTimeout(dragTimeout.current);
-
- handleDrop(e.dataTransfer, notebook);
+ handleDrop(e.dataTransfer, item);
}}
onKeyPress={async (e) => {
- if (e.key === "Delete") {
+ if (e.code === "Space") {
+ e.stopPropagation();
+ if (isExpandable) isExpanded ? collapse() : expand();
+ else navigate(`/notebooks/${item.id}`);
+ } else if (e.code === "Delete") {
+ e.stopPropagation();
await Multiselect.moveNotebooksToTrash(
useSelectionStore.getState().selectedItems
);
}
}}
- title={notebook.title}
- body={notebook.description as string}
- menuItems={notebookMenuItems}
- footer={
- <>
- {compact ? (
- <>
- <Text variant="subBody">{strings.notes(totalNotes)}</Text>
- </>
- ) : (
- <>
- {notebook?.topics && (
- <Flex mb={1} sx={{ gap: 1 }}>
- {notebook.topics.slice(0, 3).map((topic) => (
- <IconTag
- key={topic.id}
- text={topic.title}
- icon={TopicIcon}
- onClick={() => {
- navigate(`/notebooks/${notebook.id}/${topic.id}`);
- }}
- />
- ))}
- </Flex>
+ title={
+ <Flex
+ sx={{ alignItems: "center", justifyContent: "center", gap: "small" }}
+ >
+ {isExpandable ? (
+ <Button
+ variant="secondary"
+ sx={{ bg: "transparent", p: 0, borderRadius: 100 }}
+ onClick={(e) => {
+ e.stopPropagation();
+ isExpanded ? collapse() : expand();
+ }}
+ >
+ {isExpanded ? (
+ <ChevronDown
+ size={14}
+ color={isOpened ? "icon-selected" : "icon"}
+ />
+ ) : (
+ <ChevronRight
+ size={14}
+ color={isOpened ? "icon-selected" : "icon"}
+ />
)}
- <Flex
- sx={{
- fontSize: "subBody",
- color: "var(--paragraph-secondary)",
- alignItems: "center",
- fontFamily: "body"
- }}
- >
- {notebook.pinned && (
- <PinFilled color="accent" size={13} sx={{ mr: 1 }} />
- )}
-
- {getFormattedDate(date, "date")}
- <Text as="span" mx={1} sx={{ color: "inherit" }}>
- •
- </Text>
- <Text sx={{ color: "inherit" }}>
- {strings.notes(totalNotes)}
- </Text>
- </Flex>
- </>
+ </Button>
+ ) : (
+ <NotebookIcon
+ size={14}
+ color={isOpened ? "icon-selected" : "icon"}
+ />
)}
- </>
+ <Text
+ data-test-id={`title`}
+ variant={"body"}
+ color={isOpened ? "paragraph-selected" : "paragraph"}
+ sx={{
+ whiteSpace: "nowrap",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ fontWeight: "body",
+ display: "block"
+ }}
+ >
+ {item.title}
+ </Text>
+ </Flex>
}
+ footer={<Text variant="subBody">{totalNotes}</Text>}
+ menuItems={notebookMenuItems}
+ context={{ refresh }}
+ sx={{
+ mb: "small",
+ borderRadius: "default",
+ paddingLeft: `${5 + (depth === 0 ? 0 : 15 * depth)}px`
+ }}
/>
);
}
-export default React.memo(Notebook, (prev, next) => {
- const prevItem = prev.item;
- const nextItem = next.item;
-
- return (
- prev.date === next.date &&
- prevItem.pinned === nextItem.pinned &&
- prevItem.title === nextItem.title &&
- prevItem.description === nextItem.description &&
- prev.totalNotes === next.totalNotes &&
- prev.compact === next.compact
- );
-});
-export const notebookMenuItems: (
+const notebookMenuItems: (
notebook: NotebookType,
- ids?: string[]
-) => MenuItem[] = (notebook, ids = []) => {
+ ids?: string[],
+ context?: { refresh?: () => void }
+) => MenuItem[] = (notebook, ids = [], context) => {
const defaultNotebook = db.settings.getDefaultNotebook();
-
return [
+ {
+ type: "button",
+ key: "add",
+ title: strings.newNotebook(),
+ icon: Plus.path,
+ onClick: () =>
+ AddNotebookDialog.show({ parentId: notebook.id }).then((res) =>
+ res ? context?.refresh?.() : null
+ )
+ },
+ { type: "separator", key: "sepep2" },
{
type: "button",
key: "edit",
@@ -213,13 +237,3 @@ export const notebookMenuItems: (
}
];
};
-
-async function openNotebook(notebook: NotebookType, totalNotes?: number) {
- await useNotesStore.getState().setContext({
- type: "notebook",
- id: notebook.id,
- item: notebook,
- totalNotes: totalNotes
- });
- navigate(`/notebooks/${notebook.id}`);
-}
diff --git a/apps/web/src/components/notice/index.tsx b/apps/web/src/components/notice/index.tsx
index 935f16cc5..d2b9240ea 100644
--- a/apps/web/src/components/notice/index.tsx
+++ b/apps/web/src/components/notice/index.tsx
@@ -39,46 +39,45 @@ function Notice() {
<Flex
sx={{
cursor: "pointer",
- borderRadius: "default",
+ borderRadius: "large",
":hover": { bg: "hover" },
- alignItems: "center"
- // minWidth: 250
+ alignItems: "center",
+ bg: "background-secondary",
+ border: "1px solid var(--border)",
+ mx: 1,
+ mb: 1,
+ p: 1,
+ gap: 1
}}
- p={1}
onClick={() => NoticeData.action()}
- mx={1}
>
- <Flex sx={{ flex: 1, alignItems: "center" }}>
- <NoticeData.icon
- size={18}
- color="accent"
- sx={{ bg: "shade", mr: 2, p: 2, borderRadius: 80 }}
- />
+ <Flex sx={{ flex: 1, alignItems: "center", gap: 2 }}>
+ <NoticeData.icon size={20} color="accent" sx={{ ml: 1 }} />
<Flex
variant="columnCenter"
sx={{ alignItems: "flex-start", overflow: "hidden" }}
>
<Text
- variant="body"
+ variant="subBody"
sx={{
- fontSize: "body",
+ display: "block",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis"
}}
>
- {NoticeData.title}
+ {NoticeData.subtitle}
</Text>
<Text
- variant="subBody"
+ variant="body"
sx={{
- display: "block",
+ color: "heading-secondary",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis"
}}
>
- {NoticeData.subtitle}
+ {NoticeData.title}
</Text>
</Flex>
</Flex>
@@ -97,12 +96,11 @@ function Notice() {
sx={{
borderRadius: 50,
p: 1,
- mr: 1,
bg: "transparent"
}}
- variant="accentSecondary"
+ variant="secondary"
>
- <Dismiss size={20} color="accent" />
+ <Dismiss size={20} color="icon" />
</Button>
)}
</Flex>
diff --git a/apps/web/src/components/properties/index.tsx b/apps/web/src/components/properties/index.tsx
index 5b2805b0a..020ada111 100644
--- a/apps/web/src/components/properties/index.tsx
+++ b/apps/web/src/components/properties/index.tsx
@@ -28,9 +28,12 @@ import {
Circle,
Checkmark,
ChevronDown,
- ChevronRight
+ ChevronRight,
+ LinkedTo,
+ ReferencedIn as ReferencedInIcon,
+ Note as NoteIcon
} from "../icons";
-import { Box, Button, Flex, Text } from "@theme-ui/components";
+import { Box, Button, Flex, Text, FlexProps } from "@theme-ui/components";
import {
useEditorStore,
ReadonlyEditorSession,
@@ -45,7 +48,8 @@ import {
getFormattedDate,
usePromise,
ResolvedItem,
- useResolvedItem
+ useResolvedItem,
+ useUnresolvedItem
} from "@notesnook/common";
import { ScopedThemeProvider } from "../theme-provider";
import { ListItemWrapper } from "../list-container/list-profiles";
@@ -53,6 +57,7 @@ import { VirtualizedList } from "../virtualized-list";
import { SessionItem } from "../session-item";
import {
ContentBlock,
+ InternalLink,
Note,
VirtualizedGrouping,
createInternalLink,
@@ -129,7 +134,7 @@ function EditorProperties(props: EditorPropertiesProps) {
animation: "0.1s ease-out 0s 1 slideIn",
display: "flex",
position: "absolute",
- top: TITLE_BAR_HEIGHT,
+ // top: TITLE_BAR_HEIGHT,
right: 0,
zIndex: 999,
height: "100%",
@@ -150,79 +155,83 @@ function EditorProperties(props: EditorPropertiesProps) {
}}
>
<ScrollContainer>
- <Section
- title={strings.properties()}
- button={
- <ArrowLeft
- data-test-id="properties-close"
- onClick={() => toggleProperties(false)}
- size={18}
- sx={{ mr: 1, cursor: "pointer" }}
- />
- }
+ {/* <Flex
+ sx={{
+ alignItems: "center",
+ gap: 1
+ }}
>
- {session.type === "deleted" ? null : (
- <>
- {tools.map((tool) => (
- <Toggle
- {...tool}
- key={tool.key}
- isOn={
- tool.property === "locked"
- ? "locked" in session && !!session.locked
- : !!session.note[tool.property]
- }
- onToggle={() => changeToggleState(tool.key, session)}
- testId={`properties-${tool.key}`}
- />
- ))}
- </>
- )}
+ <ArrowLeft
+ data-test-id="properties-close"
+ onClick={() => toggleProperties(false)}
+ size={18}
+ sx={{ cursor: "pointer" }}
+ />
+ <Text variant="subtitle">{strings.properties()}</Text>
+ </Flex> */}
+ <Flex sx={{ flexDirection: "column", gap: 1 }}>
+ <Section title="Properties">
+ <Flex sx={{ flexDirection: "column", gap: 1, px: 2, pt: 1 }}>
+ {session.type === "deleted" ? null : (
+ <>
+ {tools.map((tool) => (
+ <Toggle
+ {...tool}
+ key={tool.key}
+ isOn={
+ tool.property === "locked"
+ ? "locked" in session && !!session.locked
+ : !!session.note[tool.property]
+ }
+ onToggle={() => changeToggleState(tool.key, session)}
+ testId={`properties-${tool.key}`}
+ />
+ ))}
+ </>
+ )}
- {metadataItems.map((item) => (
- <Flex
- key={item.key}
- py={2}
- px={1}
- sx={{
- borderBottom: "1px solid var(--separator)",
- alignItems: "center",
- justifyContent: "space-between",
- gap: 1
- }}
- >
- <Text
- variant="subBody"
- sx={{
- fontSize: "body",
- overflow: "hidden",
- textOverflow: "ellipsis"
- }}
- >
- {item.label}
- </Text>
- <Text
- className="selectable"
- variant="subBody"
- sx={{ fontSize: "body", flexShrink: 0 }}
- >
- {item.value(session.note[item.key])}
- </Text>
+ {metadataItems.map((item) => (
+ <Flex
+ key={item.key}
+ sx={{
+ alignItems: "center",
+ justifyContent: "space-between",
+ py: "small"
+ }}
+ >
+ <Text
+ variant="body"
+ sx={{
+ overflow: "hidden",
+ textOverflow: "ellipsis"
+ }}
+ >
+ {item.label}
+ </Text>
+ <Text
+ className="selectable"
+ variant="subBody"
+ sx={{ fontSize: "body", flexShrink: 0 }}
+ >
+ {item.value(session.note[item.key])}
+ </Text>
+ </Flex>
+ ))}
+ {session.type === "deleted" ? null : (
+ <Colors noteId={session.note.id} color={session.color} />
+ )}
</Flex>
- ))}
+ </Section>
{session.type === "deleted" ? null : (
- <Colors noteId={session.note.id} color={session.color} />
+ <>
+ <InternalLinks noteId={session.note.id} />
+ <Notebooks noteId={session.note.id} />
+ <Reminders noteId={session.note.id} />
+ <Attachments noteId={session.note.id} />
+ <SessionHistory noteId={session.note.id} />
+ </>
)}
- </Section>
- {session.type === "deleted" ? null : (
- <>
- <InternalLinks noteId={session.note.id} />
- <Notebooks noteId={session.note.id} />
- <Reminders noteId={session.note.id} />
- <Attachments noteId={session.note.id} />
- <SessionHistory noteId={session.note.id} />
- </>
- )}
+ </Flex>
</ScrollContainer>
</ScopedThemeProvider>
</Flex>
@@ -243,46 +252,61 @@ function InternalLinks({ noteId }: { noteId: string }) {
tabIndex === InternalLinksTabs.LINKED_NOTES
? db.relations.from({ id: noteId, type: "note" }, "note")
: db.relations.to({ id: noteId, type: "note" }, "note");
- return links.selector.sorted(db.settings.getGroupOptions("notes"));
+ return links.selector
+ .fields(["notes.id", "notes.title"])
+ .sorted(db.settings.getGroupOptions("notes"));
}, [tabIndex, noteId]);
return (
- <Flex sx={{ flexDirection: "column", mt: 2 }}>
+ <Flex sx={{ flexDirection: "column" }}>
<Flex
sx={{
- justifyContent: "stretch",
- borderRadius: "default",
- overflow: "hidden",
- mx: 1,
+ borderTop: "1px solid var(--border)",
+ borderBottom: "1px solid var(--border)",
+ py: 1,
+ px: 2,
+ justifyContent: "space-between",
+ alignItems: "center",
mb: 1
}}
>
- {[strings.linkedNotes(), strings.referencedIn()].map((title, index) => (
- <Button
- key={title}
- variant="secondary"
- sx={{
- flex: 1,
- borderRadius: 0,
- color: tabIndex === index ? "accent-selected" : "paragraph",
- bg:
- tabIndex === index
- ? "background-selected"
- : "background-secondary"
- }}
- onClick={() => {
- setTabIndex(index);
- setExpandedId(undefined);
- }}
- >
- {title}
- </Button>
- ))}
+ <Flex
+ sx={{
+ gap: 1
+ }}
+ >
+ {[LinkedTo, ReferencedInIcon].map((Icon, index) => (
+ <Button
+ key={index.toString()}
+ variant="secondary"
+ sx={{
+ p: 1,
+ color: tabIndex === index ? "accent-selected" : "paragraph",
+ bg: tabIndex === index ? "background-selected" : "transparent"
+ }}
+ onClick={() => {
+ setTabIndex(index);
+ setExpandedId(undefined);
+ }}
+ >
+ <Icon
+ size={16}
+ color={tabIndex === index ? "icon-selected" : "icon"}
+ />
+ </Button>
+ ))}
+ </Flex>
+ <Text variant="body" color="paragraph-secondary">
+ ({result.status === "fulfilled" ? result.value.length : 0}){" "}
+ {tabIndex === InternalLinksTabs.LINKED_NOTES
+ ? strings.linkedNotes()
+ : strings.referencedIn()}{" "}
+ </Text>
</Flex>
{result.status === "fulfilled" &&
(result.value.length === 0 ? (
- <Text variant="body" mx={1}>
+ <Text variant="body" mx={2}>
{tabIndex === InternalLinksTabs.LINKED_NOTES
? strings.notLinked()
: strings.notReferenced()}
@@ -323,9 +347,9 @@ function InternalLinkItem({
};
}) {
const { items, tabIndex, noteId, isExpanded, toggleExpand } = context;
- const item = useResolvedItem({ items, index });
+ const item = useUnresolvedItem({ items, index, type: "note" });
- if (!item || item.item?.type !== "note") return null;
+ if (!item) return null;
if (tabIndex === InternalLinksTabs.LINKED_NOTES)
return (
@@ -357,90 +381,108 @@ function LinkedNote({
isExpanded: boolean;
}) {
const [blocks, setBlocks] = useState<ContentBlock[]>([]);
+ const linkedBlocks = usePromise(
+ async () =>
+ (await db.notes.internalLinks(noteId)).filter(
+ (l) => l.id === item.id && !!l.params?.blockId
+ ),
+ [item.id]
+ );
return (
<>
- <Button
- variant="menuitem"
- sx={{
- p: 1,
- width: "100%",
- textAlign: "left",
- display: "flex",
- justifyContent: "start",
- alignItems: "center",
- borderBottom: isExpanded ? "none" : "1px solid var(--border)"
- }}
- onClick={() => useEditorStore.getState().openSession(item)}
- >
- <Box
- onClick={async (e) => {
- e.stopPropagation();
- if (isExpanded) return toggleExpand();
-
- const blocks = await db.notes.contentBlocks(item.id);
- const linkedBlocks = (await db.notes.internalLinks(noteId)).filter(
- (l) => l.id === item.id
- );
- setBlocks(
- linkedBlocks.length > 0
- ? blocks.filter((a) =>
- linkedBlocks.some((l) => l.params?.blockId === a.id)
- )
- : []
- );
- toggleExpand();
+ <Flex sx={{ width: "100%", alignItems: "center" }}>
+ <Button
+ variant="menuitem"
+ sx={{
+ flex: 1,
+ p: 1,
+ mx: 2,
+ borderRadius: "default",
+ textAlign: "left",
+ display: "flex",
+ justifyContent: "start",
+ alignItems: "center",
+ gap: "small"
+ // borderBottom: isExpanded ? "none" : "1px solid var(--border)"
}}
+ onClick={() => useEditorStore.getState().openSession(item)}
>
- {isExpanded ? <ChevronDown size={16} /> : <ChevronRight size={16} />}
- </Box>
- <Text>{item.title}</Text>
- </Button>
- {isExpanded
- ? blocks.map((block) => (
+ {linkedBlocks.status === "fulfilled" &&
+ linkedBlocks.value.length > 0 ? (
<Button
- key={block.id}
- variant="menuitem"
- sx={{
- p: 1,
- pl: 4,
- gap: 1,
- width: "100%",
- textAlign: "left",
- display: "flex",
- alignItems: "center",
- borderBottom: "1px solid var(--border)"
+ variant="secondary"
+ sx={{ bg: "transparent", p: 0, borderRadius: 100 }}
+ onClick={async (e) => {
+ e.stopPropagation();
+ if (isExpanded) return toggleExpand();
+ setBlocks(
+ (await db.notes.contentBlocks(item.id)).filter((a) =>
+ linkedBlocks.value.some((l) => l.params?.blockId === a.id)
+ )
+ );
+ toggleExpand();
}}
- onClick={() =>
- useEditorStore
- .getState()
- .openSession(item, { activeBlockId: block.id })
- }
>
- <Text
- variant="subBody"
+ {isExpanded ? (
+ <ChevronDown size={14} />
+ ) : (
+ <ChevronRight size={14} />
+ )}
+ </Button>
+ ) : (
+ <NoteIcon size={14} />
+ )}
+ <Text>{item.title}</Text>
+ </Button>
+ </Flex>
+ {isExpanded
+ ? blocks.map((block) => (
+ <Flex key={block.id} sx={{ width: "100%", alignItems: "center" }}>
+ <Button
+ variant="menuitem"
sx={{
- bg: "background-secondary",
- p: "small",
- flexShrink: 0,
- px: 1,
+ flex: 1,
borderRadius: "default",
- alignSelf: "flex-start"
- }}
- >
- {block.type.toUpperCase()}
- </Text>
- <Text
- variant="body"
- sx={{
- fontSize: "subBody",
- fontFamily: "monospace",
- whiteSpace: "pre-wrap"
+ p: 1,
+ mx: 2,
+ pl: 4,
+ gap: 1,
+ textAlign: "left",
+ display: "flex",
+ alignItems: "center"
}}
+ onClick={() =>
+ useEditorStore
+ .getState()
+ .openSession(item, { activeBlockId: block.id })
+ }
>
- {block.content}
- </Text>
- </Button>
+ <Text
+ variant="subBody"
+ sx={{
+ bg: "background-secondary",
+ p: "small",
+ flexShrink: 0,
+ px: 1,
+ borderRadius: "default",
+ alignSelf: "flex-start"
+ }}
+ >
+ {block.type.toUpperCase()}
+ </Text>
+ <Text
+ variant="body"
+ sx={{
+ fontSize: "subBody",
+ fontFamily: "monospace",
+ whiteSpace: "pre-wrap"
+ }}
+ >
+ {block.content}
+ </Text>
+ </Button>
+ </Flex>
))
: null}
</>
@@ -464,41 +506,51 @@ function ReferencedIn({
return (
<>
- <Button
- variant="menuitem"
- sx={{
- p: 1,
- width: "100%",
- textAlign: "left",
- display: "flex",
- justifyContent: "start",
- alignItems: "center",
- borderBottom: isExpanded ? "none" : "1px solid var(--border)"
- }}
- onClick={() => useEditorStore.getState().openSession(item)}
- >
- <Box
- onClick={async (e) => {
- e.stopPropagation();
- if (isExpanded) return toggleExpand();
- const blocks = await db.notes.contentBlocksWithLinks(item.id);
- setBlocks(
- blocks
- .filter((b) =>
- b.content.includes(createInternalLink("note", noteId))
- )
- .map((block) => ({
- id: block.id,
- links: highlightInternalLinks(block, noteId)
- }))
- );
- toggleExpand();
+ <Flex sx={{ width: "100%", alignItems: "center" }}>
+ <Button
+ variant="menuitem"
+ sx={{
+ flex: 1,
+ p: 1,
+ mx: 2,
+ borderRadius: "default",
+ textAlign: "left",
+ display: "flex",
+ justifyContent: "start",
+ alignItems: "center",
+ gap: "small"
}}
+ onClick={() => useEditorStore.getState().openSession(item)}
>
- {isExpanded ? <ChevronDown size={16} /> : <ChevronRight size={16} />}
- </Box>
- <Text variant="body">{item.title}</Text>
- </Button>
+ <Button
+ variant="secondary"
+ sx={{ bg: "transparent", p: 0, borderRadius: 100 }}
+ onClick={async (e) => {
+ e.stopPropagation();
+ if (isExpanded) return toggleExpand();
+ const blocks = await db.notes.contentBlocksWithLinks(item.id);
+ setBlocks(
+ blocks
+ .filter((b) =>
+ b.content.includes(createInternalLink("note", noteId))
+ )
+ .map((block) => ({
+ id: block.id,
+ links: highlightInternalLinks(block, noteId)
+ }))
+ );
+ toggleExpand();
+ }}
+ >
+ {isExpanded ? (
+ <ChevronDown size={16} />
+ ) : (
+ <ChevronRight size={16} />
+ )}
+ </Button>
+ <Text variant="body">{item.title}</Text>
+ </Button>
+ </Flex>
{isExpanded
? blocks.map((block) => (
<>
@@ -507,13 +559,16 @@ function ReferencedIn({
key={index.toString()}
variant="menuitem"
sx={{
+ flex: 1,
+ borderRadius: "default",
p: 1,
+ mx: 2,
pl: 4,
- pr: 2,
- gap: 1,
- width: "100%",
textAlign: "left",
- borderBottom: "1px solid var(--border)"
+ whiteSpace: "pre-wrap",
+ display: "flex",
+ flexDirection: "row",
+ gap: 2
}}
onClick={() =>
useEditorStore
@@ -521,23 +576,27 @@ function ReferencedIn({
.openSession(item, { activeBlockId: block.id })
}
>
- {link.map((slice) => (
- <Text
- key={slice.text}
- variant="body"
- sx={{
- color: slice.highlighted
- ? "accent-selected"
- : "paragraph",
- fontWeight: slice.highlighted ? "bold" : "normal",
- textDecoration: slice.highlighted
- ? "underline solid var(--accent-selected)"
- : "none"
- }}
- >
- {slice.text}
- </Text>
- ))}
+ <Text variant="subBody">{index + 1}.</Text>
+ <Text as="div" variant="body">
+ {link.map((slice) =>
+ slice.highlighted ? (
+ <Text
+ key={slice.text}
+ as="span"
+ sx={{
+ color: "accent-selected",
+ fontWeight: "bold",
+ textDecoration:
+ "underline solid var(--accent-selected)"
+ }}
+ >
+ {slice.text}
+ </Text>
+ ) : (
+ <>{slice.text}</>
+ )
+ )}
+ </Text>
</Button>
))}
</>
@@ -551,11 +610,10 @@ function Colors({ noteId, color }: { noteId: string; color?: string }) {
const result = usePromise(() => db.colors.all.items(), [color]);
return (
<Flex
- py={2}
- px={1}
sx={{
cursor: "pointer",
- justifyContent: "start"
+ justifyContent: "start",
+ gap: "small"
}}
>
{result.status === "fulfilled" &&
@@ -574,7 +632,7 @@ function Colors({ noteId, color }: { noteId: string; color?: string }) {
data-test-id={`properties-${c.title}`}
>
<Circle
- size={35}
+ size={25}
color={c.colorCode}
data-test-id={`toggle-state-${isChecked ? "on" : "off"}`}
/>
@@ -604,10 +662,14 @@ function Notebooks({ noteId }: { noteId: string }) {
if (result.status !== "fulfilled" || result.value.length <= 0) return null;
return (
- <Section title={strings.notebooks()}>
+ <Section
+ title={strings.notebooks()}
+ sx={{ borderTop: "1px solid var(--border)" }}
+ >
<VirtualizedList
+ style={{ marginTop: 5 }}
mode="fixed"
- estimatedSize={50}
+ estimatedSize={25}
getItemKey={(index) => result.value.key(index)}
items={result.value.placeholders}
renderItem={({ index }) => (
@@ -633,10 +695,14 @@ function Reminders({ noteId }: { noteId: string }) {
if (result.status !== "fulfilled" || result.value.length <= 0) return null;
return (
- <Section title={strings.dataTypesPluralCamelCase.reminder()}>
+ <Section
+ sx={{ borderTop: "1px solid var(--border)" }}
+ title={strings.dataTypesPluralCamelCase.reminder()}
+ >
<VirtualizedList
mode="fixed"
- estimatedSize={54}
+ style={{ marginTop: 5, marginLeft: 10, marginRight: 10 }}
+ estimatedSize={48}
getItemKey={(index) => result.value.key(index)}
items={result.value.placeholders}
renderItem={({ index }) => (
@@ -661,12 +727,19 @@ function Attachments({ noteId }: { noteId: string }) {
if (result.status !== "fulfilled" || result.value.length <= 0) return null;
return (
- <Section title={strings.dataTypesPluralCamelCase.attachment()}>
+ <Section
+ title={strings.dataTypesPluralCamelCase.attachment()}
+ sx={{ borderTop: "1px solid var(--border)" }}
+ >
<VirtualizedTable
- estimatedSize={30}
+ estimatedSize={25}
getItemKey={(index) => result.value.key(index)}
items={result.value.placeholders}
- style={{ tableLayout: "fixed", width: "100%" }}
+ style={{
+ marginTop: 5,
+ tableLayout: "fixed",
+ width: "100%"
+ }}
header={
<tr>
<th style={{ width: "75%" }} />
@@ -695,12 +768,16 @@ function SessionHistory({ noteId }: { noteId: string }) {
return (
<Section
+ sx={{
+ borderTop: "1px solid var(--border)"
+ }}
title={strings.noteHistory()}
subtitle={strings.noteHistoryNotice[0]()}
>
<VirtualizedList
mode="dynamic"
estimatedSize={28}
+ style={{ marginLeft: 10, marginRight: 10, marginTop: 5 }}
getItemKey={(index) => result.value.key(index)}
items={result.value.placeholders}
renderItem={({ index }) => (
@@ -714,43 +791,43 @@ function SessionHistory({ noteId }: { noteId: string }) {
}
type SectionProps = {
- title: string;
+ title?: string;
subtitle?: string;
- button?: JSX.Element;
- buttonPosition?: "left" | "right";
-};
+} & FlexProps;
export function Section({
title,
subtitle,
- button,
- buttonPosition = "left",
- children
+ children,
+ sx,
+ ...otherProps
}: PropsWithChildren<SectionProps>) {
return (
<Flex
sx={{
- borderRadius: "default",
- flexDirection: "column"
+ // borderRadius: "default",
+ flexDirection: "column",
+ // bg: "background-secondary",
+ // border: "1px solid var(--border)",
+ ...sx
}}
+ {...otherProps}
>
- <Flex
- mx={1}
- mt={2}
- sx={{
- alignItems: "center",
- justifyContent:
- buttonPosition === "right" ? "space-between" : "flex-start"
- }}
- >
- {buttonPosition === "left" && button}
- <Text variant="subtitle">{title}</Text>
- {buttonPosition === "right" && button}
- </Flex>
- {subtitle && (
- <Text variant="subBody" mb={1} mx={1}>
- {subtitle}
- </Text>
- )}
+ {title || subtitle ? (
+ <Flex
+ sx={{
+ flexDirection: "column",
+ borderBottom: "1px solid var(--border)",
+ p: 2
+ }}
+ >
+ {title && (
+ <Text variant="subBody" sx={{ fontWeight: "medium" }}>
+ {title.toUpperCase()}
+ </Text>
+ )}
+ {subtitle && <Text variant="subBody">{subtitle}</Text>}
+ </Flex>
+ ) : null}
{children}
</Flex>
);
diff --git a/apps/web/src/components/properties/toggle.tsx b/apps/web/src/components/properties/toggle.tsx
index ee5179fa2..e789112e4 100644
--- a/apps/web/src/components/properties/toggle.tsx
+++ b/apps/web/src/components/properties/toggle.tsx
@@ -32,10 +32,7 @@ function Toggle(props: ToggleProps) {
return (
<Flex
- py={2}
- px={1}
sx={{
- borderBottom: "1px solid var(--separator)",
cursor: "pointer",
alignItems: "center",
justifyContent: "space-between",
@@ -49,7 +46,6 @@ function Toggle(props: ToggleProps) {
<Flex
sx={{
alignItems: "center",
-
display: "flex"
}}
data-test-id={`toggle-state-${isOn ? "on" : "off"}`}
@@ -68,7 +64,12 @@ function Toggle(props: ToggleProps) {
</Text>
</Flex>
<Switch
- sx={{ m: 0, bg: isOn ? "accent" : "icon-secondary", flexShrink: 0 }}
+ sx={{
+ m: 0,
+ bg: isOn ? "accent" : "icon-secondary",
+ flexShrink: 0,
+ scale: 0.75
+ }}
checked={isOn}
onClick={(e) => e.stopPropagation()}
/>
diff --git a/apps/web/src/components/reminder/index.tsx b/apps/web/src/components/reminder/index.tsx
index 6f31ea30d..128edb8ec 100644
--- a/apps/web/src/components/reminder/index.tsx
+++ b/apps/web/src/components/reminder/index.tsx
@@ -71,9 +71,9 @@ function Reminder(props: ReminderProps) {
<ListItem
item={item}
title={reminder.title}
- body={reminder.description}
+ body={compact ? undefined : reminder.description}
isDisabled={reminder.disabled}
- isCompact={compact}
+ isCompact={false}
onClick={() => EditReminderDialog.show({ reminderId: reminder.id })}
onKeyPress={async (e) => {
if (e.key === "Delete") {
@@ -82,11 +82,19 @@ function Reminder(props: ReminderProps) {
);
}
}}
+ sx={
+ compact
+ ? {
+ borderRadius: "default"
+ }
+ : {}
+ }
footer={
<Flex
sx={{
alignItems: "center",
- gap: 1
+ gap: 1,
+ mt: 1
}}
>
{reminder.disabled ? null : <PriorityIcon size={14} />}
diff --git a/apps/web/src/components/route-container/index.tsx b/apps/web/src/components/route-container/index.tsx
index 82eff1d34..9b36053dd 100644
--- a/apps/web/src/components/route-container/index.tsx
+++ b/apps/web/src/components/route-container/index.tsx
@@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { PropsWithChildren } from "react";
-import { Button, Flex, Text } from "@theme-ui/components";
+import { PropsWithChildren, useRef } from "react";
+import { Box, Button, Flex, Text } from "@theme-ui/components";
import { ArrowLeft, Menu, Search, Plus, Close } from "../icons";
import { useStore } from "../../stores/app-store";
import { useStore as useSearchStore } from "../../stores/search-store";
@@ -28,6 +28,7 @@ import Field from "../field";
import { strings } from "@notesnook/intl";
import { TITLE_BAR_HEIGHT } from "../title-bar";
import { AppEventManager, AppEvents } from "../../common/app-events";
+import { RouteResult } from "../../navigation/types";
export type RouteContainerButtons = {
search?: {
@@ -43,16 +44,12 @@ export type RouteContainerButtons = {
};
};
-export type RouteContainerProps = {
- type: string;
- title?: string | (() => Promise<string | undefined>);
- buttons?: RouteContainerButtons;
-};
+export type RouteContainerProps = RouteResult;
function RouteContainer(props: PropsWithChildren<RouteContainerProps>) {
- const { type, title, buttons, children } = props;
+ const { children } = props;
return (
<>
- <Header type={type} title={title} buttons={buttons} />
+ <Header {...props} />
{children}
</>
);
@@ -61,173 +58,230 @@ function RouteContainer(props: PropsWithChildren<RouteContainerProps>) {
export default RouteContainer;
function Header(props: RouteContainerProps) {
- const { buttons, type } = props;
+ const { type } = props;
const titlePromise = usePromise<string | undefined>(
() => (typeof props.title === "string" ? props.title : props.title?.()),
[props.title]
);
const isMobile = useMobile();
- const isSearching = useSearchStore((store) => store.isSearching);
+ // const isSearching = useSearchStore((store) => store.isSearching);
const query = useSearchStore((store) => store.query);
-
- if (isSearching)
- return (
- <Flex
- sx={{
- alignItems: "center",
- justifyContent: "center",
- height: TITLE_BAR_HEIGHT,
- zIndex: 2,
- px: 1
- }}
- className="route-container-header search-container"
- >
- <Field
- data-test-id="search-input"
- autoFocus
- id="search"
- name="search"
- variant="borderless"
- type="text"
- sx={{ m: 0, flex: 1, gap: 0 }}
- styles={{ input: { p: "5px", m: 0 } }}
- defaultValue={query}
- placeholder={strings.typeAKeyword()}
- onChange={debounce(
- (e) => useSearchStore.setState({ query: e.target.value }),
- 250
- )}
- onKeyUp={(e) => {
- if (e.key === "Escape")
- useSearchStore.setState({
- isSearching: false,
- searchType: undefined
- });
- }}
- action={{
- icon: Close,
- testId: "search-button",
- onClick: () =>
- useSearchStore.setState({
- isSearching: false,
- searchType: undefined,
- query: undefined
- })
- }}
- />
- {!isMobile && buttons?.create && (
- <Button
- {...buttons.create}
- data-test-id={`${type}-action-button`}
- sx={{ p: 0 }}
- >
- <Plus
- color="accentForeground"
- size={18}
- sx={{
- height: 24,
- width: 24,
- bg: "accent",
- borderRadius: 100
- }}
- />
- </Button>
- )}
- </Flex>
- );
+ const inputRef = useRef<HTMLInputElement>(null);
return (
- <Flex
- className="route-container-header"
+ <Box
sx={{
- px: 1,
- alignItems: "center",
- justifyContent: "space-between",
- height: TITLE_BAR_HEIGHT,
- zIndex: 2
+ bg: type === "notebook" ? "background-secondary" : "transparent",
+ zIndex: 2,
+ p: 1
}}
+ className="route-container-header search-container"
>
- <Flex
- py={1}
+ <Field
+ inputRef={inputRef}
+ data-test-id="search-input"
+ autoFocus
+ id="search"
+ name="search"
+ variant="clean"
+ type="text"
sx={{
- alignItems: "center",
- justifyContent: "center",
- overflow: "hidden",
- gap: 1
+ bg: "background",
+ m: 0,
+ mr: 0,
+
+ border: "1px solid var(--border)",
+ borderRadius: "large",
+ gap: 0
}}
- >
- {buttons?.back ? (
- <Button
- {...buttons.back}
- data-test-id="route-go-back"
- sx={{ p: 0, flexShrink: 0 }}
- >
- <ArrowLeft size={20} />
- </Button>
- ) : (
- <Button
- onClick={() =>
- AppEventManager.publish(AppEvents.toggleSideMenu, true)
+ styles={{
+ input: {
+ m: 0,
+ p: "7.5px",
+ fontSize: "body",
+ "::placeholder": {
+ textAlign: "center"
+ },
+ "& + .rightActions": {
+ opacity: 0
+ },
+ "&:focus + .rightActions": {
+ opacity: 1
}
- sx={{ p: 0, flexShrink: 0 }}
- >
- <Menu
- sx={{
- display: ["block", "block", "none"],
- size: 23
- }}
- size={24}
- />
- </Button>
- )}
- {titlePromise.status === "fulfilled" && titlePromise.value && (
- <Text
- className="routeHeader"
- variant="heading"
- data-test-id="routeHeader"
- color="heading"
- >
- {titlePromise.value}
- </Text>
- )}
- </Flex>
- <Flex sx={{ flexShrink: 0, gap: 2 }}>
- {buttons?.search && (
- <Button
- title={buttons.search.title}
- onClick={() =>
- useSearchStore.setState({ isSearching: true, searchType: type })
- }
- data-test-id={"open-search"}
- sx={{ p: 0 }}
- >
- <Search
- size={24}
- sx={{
- size: 24
- }}
- />
- </Button>
+ }
+ }}
+ defaultValue={query}
+ placeholder={strings.searchInRoute(
+ titlePromise.status === "fulfilled"
+ ? titlePromise.value || type
+ : type
)}
- {!isMobile && buttons?.create && (
- <Button
- {...buttons.create}
- data-test-id={`${type}-action-button`}
- sx={{ p: 0 }}
- >
- <Plus
- color="accentForeground"
- size={18}
- sx={{
- height: 24,
- width: 24,
- bg: "accent",
- borderRadius: 100
- }}
- />
- </Button>
+ onChange={debounce(
+ (e) => useSearchStore.setState({ query: e.target.value }),
+ 250
)}
- </Flex>
- </Flex>
+ onKeyUp={(e) => {
+ if (e.key === "Escape")
+ useSearchStore.setState({
+ isSearching: false,
+ searchType: undefined
+ });
+ else useSearchStore.setState({ isSearching: true, searchType: type });
+ }}
+ action={{
+ icon: Close,
+ testId: "search-button",
+ onClick: () => {
+ if (inputRef.current) inputRef.current.value = "";
+ useSearchStore.setState({
+ isSearching: false,
+ query: undefined,
+ searchType: undefined
+ });
+ }
+ }}
+ />
+ </Box>
);
+ // if (isSearching)
+ // return (
+ // <Flex
+ // sx={{
+ // alignItems: "center",
+ // justifyContent: "center",
+ // height: TITLE_BAR_HEIGHT,
+ // zIndex: 2,
+ // px: 1
+ // }}
+ // className="route-container-header search-container"
+ // >
+ // <Field
+ // data-test-id="search-input"
+ // autoFocus
+ // id="search"
+ // name="search"
+ // variant="borderless"
+ // type="text"
+ // sx={{ m: 0, flex: 1, gap: 0 }}
+ // styles={{ input: { p: "5px", m: 0 } }}
+ // defaultValue={query}
+ // placeholder={strings.typeAKeyword()}
+ // onChange={debounce(
+ // (e) => useSearchStore.setState({ query: e.target.value }),
+ // 250
+ // )}
+ // onKeyUp={(e) => {
+ // if (e.key === "Escape")
+ // useSearchStore.setState({
+ // isSearching: false,
+ // searchType: undefined
+ // });
+ // }}
+ // action={{
+ // icon: Close,
+ // testId: "search-button",
+ // onClick: () =>
+ // useSearchStore.setState({
+ // isSearching: false,
+ // searchType: undefined
+ // })
+ // }}
+ // />
+ // </Flex>
+ // );
+
+ // return (
+ // <Flex
+ // className="route-container-header"
+ // sx={{
+ // px: 1,
+ // alignItems: "center",
+ // justifyContent: "space-between",
+ // height: TITLE_BAR_HEIGHT,
+ // zIndex: 2
+ // }}
+ // >
+ // <Flex
+ // py={1}
+ // sx={{
+ // alignItems: "center",
+ // justifyContent: "center",
+ // overflow: "hidden",
+ // gap: 1
+ // }}
+ // >
+ // {buttons?.back ? (
+ // <Button
+ // {...buttons.back}
+ // data-test-id="route-go-back"
+ // sx={{ p: 0, flexShrink: 0 }}
+ // >
+ // <ArrowLeft size={20} />
+ // </Button>
+ // ) : (
+ // <Button
+ // onClick={() =>
+ // AppEventManager.publish(AppEvents.toggleSideMenu, true)
+ // }
+ // sx={{ p: 0, flexShrink: 0 }}
+ // >
+ // <Menu
+ // sx={{
+ // display: ["block", "block", "none"],
+ // size: 23
+ // }}
+ // size={24}
+ // />
+ // </Button>
+ // )}
+ // {titlePromise.status === "fulfilled" && titlePromise.value && (
+ // <Text
+ // className="routeHeader"
+ // variant="heading"
+ // data-test-id="routeHeader"
+ // color="heading"
+ // >
+ // {titlePromise.value}
+ // </Text>
+ // )}
+ // </Flex>
+ // <Flex sx={{ flexShrink: 0, gap: 2 }}>
+ // {buttons?.search && (
+ // <Button
+ // title={buttons.search.title}
+ // onClick={() =>
+ // useSearchStore.setState({ isSearching: true, searchType: type })
+ // }
+ // data-test-id={"open-search"}
+ // sx={{ p: 0 }}
+ // >
+ // <Search
+ // size={24}
+ // sx={{
+ // size: 24
+ // }}
+ // />
+ // </Button>
+ // )}
+ // {!isMobile && buttons?.create && (
+ // <Button
+ // {...buttons.create}
+ // data-test-id={`${type}-action-button`}
+ // sx={{ p: 0 }}
+ // >
+ // <Plus
+ // color="accentForeground"
+ // size={18}
+ // sx={{
+ // height: 24,
+ // width: 24,
+ // bg: "accent",
+ // borderRadius: 100
+ // }}
+ // />
+ // </Button>
+ // )}
+ // </Flex>
+ // </Flex>
+ // );
}
diff --git a/apps/web/src/components/session-item/index.tsx b/apps/web/src/components/session-item/index.tsx
index 3e80c5fdd..4670a3015 100644
--- a/apps/web/src/components/session-item/index.tsx
+++ b/apps/web/src/components/session-item/index.tsx
@@ -40,6 +40,7 @@ export function SessionItem(props: SessionItemProps) {
py={1}
px={1}
sx={{
+ borderRadius: "default",
cursor: "pointer",
bg: "transparent",
":hover": {
diff --git a/apps/web/src/components/split-pane/styles.css b/apps/web/src/components/split-pane/styles.css
index cca0277dd..606beb30f 100644
--- a/apps/web/src/components/split-pane/styles.css
+++ b/apps/web/src/components/split-pane/styles.css
@@ -55,5 +55,5 @@ body.react-split--disabled {
}
.split-sash-content.split-sash-content-active {
- background-color: var(--accent);
+ background-color: transparent;
}
diff --git a/apps/web/src/components/status-bar/index.tsx b/apps/web/src/components/status-bar/index.tsx
index 027980eca..d6e24ceff 100644
--- a/apps/web/src/components/status-bar/index.tsx
+++ b/apps/web/src/components/status-bar/index.tsx
@@ -101,22 +101,6 @@ function StatusBar() {
<SyncStatus />
</>
- ) : isLoggedIn === false ? (
- <Button
- variant="statusitem"
- onClick={() => hardNavigate("/login")}
- sx={{
- alignItems: "center",
- justifyContent: "center",
- display: "flex"
- }}
- data-test-id="not-logged-in"
- >
- <Circle size={7} color="var(--icon-error)" />
- <Text variant="subBody" ml={1} sx={{ color: "paragraph" }}>
- {strings.notLoggedIn()}
- </Text>
- </Button>
) : null}
{activeCredentials().length > 0 && (
<Button
diff --git a/apps/web/src/components/sub-notebook/index.tsx b/apps/web/src/components/sub-notebook/index.tsx
deleted file mode 100644
index 9b366e379..000000000
--- a/apps/web/src/components/sub-notebook/index.tsx
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-This file is part of the Notesnook project (https://notesnook.com/)
-
-Copyright (C) 2023 Streetwriters (Private) Limited
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import ListItem from "../list-item";
-import { Flex, Text } from "@theme-ui/components";
-import { useStore as useNotesStore } from "../../stores/note-store";
-import { Notebook } from "@notesnook/core";
-import { notebookMenuItems } from "../notebook";
-import { ChevronDown, ChevronRight, Plus } from "../icons";
-import { MenuItem } from "@notesnook/ui";
-import { navigate } from "../../navigation";
-import { useCallback, useRef } from "react";
-import { handleDrop } from "../../common/drop-handler";
-import { useDragHandler } from "../../hooks/use-drag-handler";
-import { AddNotebookDialog } from "../../dialogs/add-notebook-dialog";
-import { useStore as useSelectionStore } from "../../stores/selection-store";
-import { Multiselect } from "../../common/multi-select";
-import { strings } from "@notesnook/intl";
-
-type SubNotebookProps = {
- item: Notebook;
- totalNotes: number;
- isExpandable: boolean;
- isExpanded: boolean;
- expand: () => void;
- collapse: () => void;
- refresh?: () => void;
- depth: number;
- rootId: string;
-};
-function SubNotebook(props: SubNotebookProps) {
- const {
- item,
- totalNotes,
- isExpandable,
- isExpanded,
- expand,
- collapse,
- refresh,
- depth,
- rootId
- } = props;
- const isOpened = useNotesStore(
- (store) =>
- store.context?.type === "notebook" && store.context.id === item.id
- );
- const dragTimeout = useRef(0);
- const { isDragEntering, isDragLeaving } = useDragHandler(`id_${item.id}`);
-
- const openNotebook = useCallback(async () => {
- if (isOpened) return;
- focus();
- expand();
- await useNotesStore.getState().setContext({
- type: "notebook",
- id: item.id,
- item,
- totalNotes
- });
- if (rootId === "root") {
- navigate(`/notebooks/${item.id}`);
- return;
- }
- navigate(`/notebooks/${rootId}/${item.id}`);
- }, [expand, focus, isOpened, item, rootId, totalNotes]);
-
- return (
- <ListItem
- draggable
- isFocused={isOpened}
- isCompact
- item={item}
- onClick={() => openNotebook()}
- onDragEnter={(e) => {
- if (!isDragEntering(e)) return;
- e.currentTarget.focus();
- focus();
-
- dragTimeout.current = setTimeout(() => {
- openNotebook();
- }, 1000) as unknown as number;
- }}
- onDragLeave={(e) => {
- if (!isDragLeaving(e)) return;
- clearTimeout(dragTimeout.current);
- }}
- onDrop={async (e) => {
- clearTimeout(dragTimeout.current);
- handleDrop(e.dataTransfer, item);
- }}
- onKeyPress={async (e) => {
- if (e.code === "Space") {
- e.stopPropagation();
- if (isExpandable) isExpanded ? collapse() : expand();
- else if (!isOpened) {
- focus();
- await useNotesStore.getState().setContext({
- type: "notebook",
- id: item.id,
- item,
- totalNotes
- });
- navigate(`/notebooks/${rootId}/${item.id}`);
- }
- } else if (e.code === "Delete") {
- e.stopPropagation();
- await Multiselect.moveNotebooksToTrash(
- useSelectionStore.getState().selectedItems
- );
- }
- }}
- title={
- <Flex sx={{ alignItems: "center", justifyContent: "center" }}>
- {isExpandable ? (
- isExpanded ? (
- <ChevronDown
- size={16}
- onClick={(e) => {
- e.stopPropagation();
- collapse();
- }}
- />
- ) : (
- <ChevronRight
- size={16}
- onClick={(e) => {
- e.stopPropagation();
- expand();
- }}
- />
- )
- ) : null}
- <Text
- data-test-id={`title`}
- variant={"body"}
- sx={{
- whiteSpace: "nowrap",
- overflow: "hidden",
- textOverflow: "ellipsis",
- fontWeight: "body",
- display: "block"
- }}
- >
- {item.title}
- </Text>
- </Flex>
- }
- footer={<Text variant="subBody">{totalNotes}</Text>}
- menuItems={subNotebookMenuItems}
- context={{ refresh }}
- sx={{
- paddingLeft:
- depth === 0
- ? isExpandable
- ? 0
- : "5px"
- : `${16 * depth - (isExpandable ? 5 : 0)}px`
- }}
- />
- );
-}
-
-export default SubNotebook;
-
-const subNotebookMenuItems: (
- notebook: Notebook,
- ids?: string[],
- context?: { refresh?: () => void }
-) => MenuItem[] = (notebook, ids = [], context) => {
- const menuItems = notebookMenuItems(notebook, ids);
- return [
- {
- type: "button",
- key: "add",
- title: strings.newNotebook(),
- icon: Plus.path,
- onClick: () =>
- AddNotebookDialog.show({ parentId: notebook.id }).then((res) =>
- res ? context?.refresh?.() : null
- )
- },
- { type: "separator", key: "sepep2" },
- ...menuItems
- ];
-};
diff --git a/apps/web/src/components/tag/index.tsx b/apps/web/src/components/tag/index.tsx
index 3489b38b2..2e8612981 100644
--- a/apps/web/src/components/tag/index.tsx
+++ b/apps/web/src/components/tag/index.tsx
@@ -19,34 +19,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import ListItem from "../list-item";
import { navigate } from "../../navigation";
-import { Text } from "@theme-ui/components";
+import { Flex, Text } from "@theme-ui/components";
import { store as appStore } from "../../stores/app-store";
import { db } from "../../common/db";
-import { Edit, Shortcut, DeleteForver } from "../icons";
+import { Edit, Shortcut, DeleteForver, Tag as TagIcon } from "../icons";
import { MenuItem } from "@notesnook/ui";
import { Tag as TagType } from "@notesnook/core";
import { handleDrop } from "../../common/drop-handler";
import { EditTagDialog } from "../../dialogs/item-dialog";
import { useStore as useSelectionStore } from "../../stores/selection-store";
+import { useStore as useNoteStore } from "../../stores/note-store";
import { Multiselect } from "../../common/multi-select";
import { strings } from "@notesnook/intl";
type TagProps = { item: TagType; totalNotes: number };
function Tag(props: TagProps) {
const { item, totalNotes } = props;
- const { id, title } = item;
+ const { id } = item;
+ const isSelected = useNoteStore(
+ (store) => store.context?.type === "tag" && store.context.id === id
+ );
return (
<ListItem
item={item}
isCompact
+ isFocused={isSelected}
+ sx={{
+ borderRadius: "default",
+ mb: "small"
+ }}
title={
- <Text as="span" variant="body" data-test-id={`title`}>
- <Text as="span" sx={{ color: "accent" }}>
- {"#"}
+ <Flex
+ sx={{ alignItems: "center", justifyContent: "center", gap: "small" }}
+ >
+ <TagIcon size={14} color={isSelected ? "icon-selected" : "icon"} />
+ <Text
+ data-test-id={`title`}
+ variant={"body"}
+ color={isSelected ? "paragraph-selected" : "paragraph"}
+ sx={{
+ whiteSpace: "nowrap",
+ overflow: "hidden",
+ textOverflow: "ellipsis",
+ fontWeight: "body",
+ display: "block"
+ }}
+ >
+ {item.title}
</Text>
- {title}
- </Text>
+ </Flex>
}
footer={
<Text mt={1} variant="subBody">
@@ -58,6 +80,8 @@ function Tag(props: TagProps) {
await Multiselect.deleteTags(
useSelectionStore.getState().selectedItems
);
+ } else if (e.key === "Enter") {
+ navigate(`/tags/${id}`);
}
}}
menuItems={tagMenuItems}
diff --git a/apps/web/src/components/title-bar/index.tsx b/apps/web/src/components/title-bar/index.tsx
index 6665203a9..a7e7798f3 100644
--- a/apps/web/src/components/title-bar/index.tsx
+++ b/apps/web/src/components/title-bar/index.tsx
@@ -86,7 +86,7 @@ export function TitleBar({ isUnderlay = isMac() }: { isUnderlay?: boolean }) {
scope="titleBar"
className="titlebar"
sx={{
- background: "background",
+ // background: "background",
height: TITLE_BAR_HEIGHT,
minHeight: TITLE_BAR_HEIGHT,
maxHeight: TITLE_BAR_HEIGHT,
@@ -95,7 +95,7 @@ export function TitleBar({ isUnderlay = isMac() }: { isUnderlay?: boolean }) {
flexShrink: 0,
width: "100%",
zIndex: 1,
- borderBottom: "1px solid var(--border)",
+ //borderBottom: "1px solid var(--border)",
...(isUnderlay
? {
position: "absolute",
diff --git a/apps/web/src/components/virtualized-tree/index.tsx b/apps/web/src/components/virtualized-tree/index.tsx
index 25cd58893..e045f44a2 100644
--- a/apps/web/src/components/virtualized-tree/index.tsx
+++ b/apps/web/src/components/virtualized-tree/index.tsx
@@ -56,6 +56,7 @@ type TreeViewProps<T> = {
bulkSelect?: (ids: string[]) => void;
deselectAll?: () => void;
isSelected?: (id: string) => boolean;
+ style?: React.CSSProperties;
};
export function VirtualizedTree<T>(props: TreeViewProps<T>) {
const {
@@ -72,7 +73,8 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
onSelect,
deselectAll,
bulkSelect,
- testId
+ testId,
+ style
} = props;
const [nodes, setNodes] = useState<TreeNode<T>[]>([]);
const [expandedIds, setExpandedIds] = usePersistentState<ExpandedIds>(
@@ -85,8 +87,7 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
treeRef,
() => ({
async refresh() {
- // const children = await getChildNodes(rootId, -1);
- // setNodes(children);
+ setNodes([]);
const nodes = await fetchChildren(
rootId,
-1,
@@ -181,14 +182,15 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
useEffect(() => {
fetchChildren(rootId, -1, expandedIds, getChildNodes).then(setNodes);
+ console.log("fetching");
}, [rootId]);
- console.log(expandedIds);
+
return (
<Virtuoso
data-test-id={testId}
ref={list}
- data={nodes}
- computeItemKey={(i, item) => item.id}
+ totalCount={nodes.length}
+ computeItemKey={(i) => nodes[i].id}
fixedItemHeight={itemHeight}
onKeyDown={(e) => onKeyDown(e.nativeEvent)}
context={{
@@ -199,49 +201,52 @@ export function VirtualizedTree<T>(props: TreeViewProps<T>) {
Item: VirtuosoItem,
EmptyPlaceholder: Placeholder
}}
- itemContent={(index, node) => (
- <Node
- item={node}
- index={index}
- expanded={expandedIds[node.id]}
- collapse={() => {
- if (!expandedIds[node.id]) return;
+ itemContent={(index) => {
+ const node = nodes[index];
+ return (
+ <Node
+ item={node}
+ index={index}
+ expanded={expandedIds[node.id]}
+ collapse={() => {
+ if (!expandedIds[node.id]) return;
- const expanded = { ...expandedIds, [node.id]: false };
- setNodes((tree) => {
- const removeIds: string[] = [];
- for (const treeNode of tree) {
- if (
- treeNode.parentId === node.id ||
- removeIds.includes(treeNode.parentId)
- ) {
- expanded[treeNode.id] = false;
- removeIds.push(treeNode.id);
+ const expanded = { ...expandedIds, [node.id]: false };
+ setNodes((tree) => {
+ const removeIds: string[] = [];
+ for (const treeNode of tree) {
+ if (
+ treeNode.parentId === node.id ||
+ removeIds.includes(treeNode.parentId)
+ ) {
+ expanded[treeNode.id] = false;
+ removeIds.push(treeNode.id);
+ }
}
- }
- return tree.filter((n) => !removeIds.includes(n.id));
- });
- setExpandedIds(expanded);
- }}
- expand={async () => {
- if (expandedIds[node.id]) return;
+ return tree.filter((n) => !removeIds.includes(n.id));
+ });
+ setExpandedIds(expanded);
+ }}
+ expand={async () => {
+ if (expandedIds[node.id]) return;
- setExpandedIds({ ...expandedIds, [node.id]: true });
+ setExpandedIds({ ...expandedIds, [node.id]: true });
- const children = await fetchChildren(
- node.id,
- node.depth,
- expandedIds,
- getChildNodes
- );
- setNodes((tree) => {
- const copy = tree.slice();
- copy.splice(index + 1, 0, ...children);
- return copy;
- });
- }}
- />
- )}
+ const children = await fetchChildren(
+ node.id,
+ node.depth,
+ expandedIds,
+ getChildNodes
+ );
+ setNodes((tree) => {
+ const copy = tree.slice();
+ copy.splice(index + 1, 0, ...children);
+ return copy;
+ });
+ }}
+ />
+ );
+ }}
/>
);
}
diff --git a/apps/web/src/dialogs/attachments-dialog.tsx b/apps/web/src/dialogs/attachments-dialog.tsx
index 0a8c17221..c20ebee4e 100644
--- a/apps/web/src/dialogs/attachments-dialog.tsx
+++ b/apps/web/src/dialogs/attachments-dialog.tsx
@@ -457,12 +457,12 @@ const Sidebar = memo(
backgroundColor: "background"
}}
>
- <Flex sx={{ flexDirection: "column" }}>
+ <Flex sx={{ flexDirection: "column", gap: "small", mx: 2, mt: 2 }}>
<Input
id="search"
name="search"
placeholder={strings.search()}
- sx={{ m: 2, mb: 0, width: "auto", bg: "background", py: "7px" }}
+ sx={{ mb: 2, width: "auto", bg: "background", py: "7px" }}
onChange={(e) => {
setRoute(e.target.value ? "none" : "all");
if (e.target.value) filter(e.target.value);
@@ -473,13 +473,14 @@ const Sidebar = memo(
key={item.id}
icon={item.icon}
title={item.title}
- count={counts[item.id]}
onClick={() => {
onRouteChange(item.id);
setRoute(item.id);
}}
selected={route === item.id}
- />
+ >
+ <Text variant="subBody">{counts[item.id]}</Text>
+ </NavigationItem>
))}
</Flex>
<Flex sx={{ flexDirection: "column" }}>
diff --git a/apps/web/src/dialogs/settings/components/user-profile.tsx b/apps/web/src/dialogs/settings/components/user-profile.tsx
index 635aa4c52..dd76c0e72 100644
--- a/apps/web/src/dialogs/settings/components/user-profile.tsx
+++ b/apps/web/src/dialogs/settings/components/user-profile.tsx
@@ -70,23 +70,25 @@ export function UserProfile({ minimal }: Props) {
borderRadius: "default",
alignItems: "center",
bg: "var(--background-secondary)",
- p: 2,
- mb: minimal ? 0 : 4
+ p: 1,
+ mb: minimal ? 0 : 4,
+ gap: 1
}}
>
<Flex
variant="columnCenter"
sx={{
bg: "shade",
- mr: 2,
- size: 60,
+ size: minimal ? 30 : 40,
borderRadius: 80
}}
>
- <User size={30} />
+ <User size={minimal ? 15 : 20} />
</Flex>
<Flex sx={{ flexDirection: "column" }}>
- <Text variant={"title"}>{strings.loginMessage()}</Text>
+ <Text variant={minimal ? "body" : "subtitle"}>
+ {strings.loginMessage()}
+ </Text>
<Text variant={"subBody"}>{strings.loginMessageActionText()}</Text>
</Flex>
</Flex>
@@ -99,7 +101,7 @@ export function UserProfile({ minimal }: Props) {
alignItems: "center",
justifyContent: "space-between",
bg: "var(--background-secondary)",
- p: 2,
+ p: 1,
mb: minimal ? 0 : 4
}}
>
@@ -109,7 +111,7 @@ export function UserProfile({ minimal }: Props) {
sx={{
bg: "shade",
mr: 2,
- size: 60,
+ size: minimal ? 40 : 50,
borderRadius: 80,
overflow: "hidden",
position: "relative",
@@ -124,7 +126,7 @@ export function UserProfile({ minimal }: Props) {
src={profile.profilePicture}
/>
) : (
- <User size={30} />
+ <User size={minimal ? 20 : 24} />
)}
<Flex
id="profile-picture-edit"
@@ -146,7 +148,7 @@ export function UserProfile({ minimal }: Props) {
await EditProfilePictureDialog.show({ profile });
}}
>
- <Text variant="body" sx={{ color: "white" }}>
+ <Text variant="subBody" sx={{ color: "white" }}>
{strings.edit()}
</Text>
</Flex>
@@ -167,7 +169,7 @@ export function UserProfile({ minimal }: Props) {
: "BASIC"}
</Text>
- <Text variant={"title"}>
+ <Text variant={minimal ? "body" : "subtitle"}>
{profile?.fullName || strings.yourFullName()}{" "}
{minimal ? null : (
<Edit
diff --git a/apps/web/src/dialogs/settings/index.tsx b/apps/web/src/dialogs/settings/index.tsx
index 4deef6230..aa592c050 100644
--- a/apps/web/src/dialogs/settings/index.tsx
+++ b/apps/web/src/dialogs/settings/index.tsx
@@ -269,7 +269,8 @@ function SettingsSideBar(props: SettingsSideBarProps) {
sx={{
flexDirection: "column",
display: "flex",
- overflow: "hidden"
+ overflow: "hidden",
+ gap: 2
}}
>
<Input
@@ -279,8 +280,7 @@ function SettingsSideBar(props: SettingsSideBarProps) {
placeholder={strings.search()}
data-test-id="settings-search"
sx={{
- m: 2,
- mb: 2,
+ m: 1,
width: "auto",
bg: "background",
py: "7px"
@@ -326,14 +326,17 @@ function SettingsSideBar(props: SettingsSideBarProps) {
}}
/>
{sectionGroups.map((group) => (
- <Flex key={group.key} sx={{ flexDirection: "column", mb: 2 }}>
+ <Flex
+ key={group.key}
+ sx={{ flexDirection: "column", mx: 1, gap: "small" }}
+ >
<Text
variant={"subBody"}
sx={{
fontWeight: "bold",
- color: "paragraph",
- mx: 3,
+ color: "paragraph-secondary",
mb: 1,
+ ml: 1,
overflow: "hidden",
textOverflow: "ellipsis",
wordSpacing: "nowrap"
@@ -469,7 +472,12 @@ function SettingItem(props: { item: Setting }) {
}}
>
<Flex sx={{ flexDirection: "column", flex: 1 }}>
- <Text variant={"subtitle"}>{item.title}</Text>
+ <Text
+ variant={"body"}
+ sx={{ fontWeight: "medium", color: "heading" }}
+ >
+ {item.title}
+ </Text>
{item.description && (
<Text
as={"div"}
diff --git a/apps/web/src/dialogs/settings/profile-settings.ts b/apps/web/src/dialogs/settings/profile-settings.ts
index 94e36cb8b..41ea73096 100644
--- a/apps/web/src/dialogs/settings/profile-settings.ts
+++ b/apps/web/src/dialogs/settings/profile-settings.ts
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { strings } from "@notesnook/intl";
-import { createBackup, verifyAccount } from "../../common";
+import { createBackup, logout, verifyAccount } from "../../common";
import { db } from "../../common/db";
import { TaskManager } from "../../common/task-manager";
import { showPasswordDialog } from "../../dialogs/password-dialog";
@@ -141,35 +141,7 @@ export const ProfileSettings: SettingsGroup[] = [
type: "button",
variant: "errorSecondary",
title: strings.logout(),
- action: async () => {
- const result = await showLogoutConfirmation();
- if (!result) return;
-
- if (result.backup) {
- try {
- await createBackup({ mode: "partial" });
- } catch (e) {
- logger.error(e, "Failed to take backup before logout");
- if (
- !(await ConfirmDialog.show({
- title: strings.failedToTakeBackup(),
- message: strings.failedToTakeBackupMessage(),
- negativeButtonText: strings.no(),
- positiveButtonText: strings.yes()
- }))
- )
- return;
- }
- }
-
- await TaskManager.startTask({
- type: "modal",
- title: strings.loggingOut(),
- subtitle: strings.pleaseWait(),
- action: () => db.user.logout(true)
- });
- showToast("success", strings.loggedOut());
- }
+ action: () => logout()
}
]
},
diff --git a/apps/web/src/hooks/use-hash-routes.tsx b/apps/web/src/hooks/use-hash-routes.tsx
index 6393fc0b8..eaee3bae9 100644
--- a/apps/web/src/hooks/use-hash-routes.tsx
+++ b/apps/web/src/hooks/use-hash-routes.tsx
@@ -19,10 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import makeMatcher from "wouter/matcher";
import useHashLocation from "./use-hash-location";
-import { Params, Routes } from "../navigation/types";
+import { Params, HashRoutes } from "../navigation/types";
import { useEffect } from "react";
-export default function useHashRoutes<T extends string>(routes: Routes<T>) {
+export default function useHashRoutes<T extends string>(routes: HashRoutes<T>) {
const [{ location, update }] = useHashLocation();
useEffect(() => {
@@ -32,8 +32,7 @@ export default function useHashRoutes<T extends string>(routes: Routes<T>) {
for (const key in routes) {
const [match, params] = matcher(key, location);
if (match) {
- const route = routes[key]((params as Params<typeof key>) || {});
- if (!route) return;
+ routes[key]((params as Params<typeof key>) || {});
}
}
}, [update, location, routes]);
diff --git a/apps/web/src/hooks/use-routes.ts b/apps/web/src/hooks/use-routes.ts
index c5502e389..bb7c6641f 100644
--- a/apps/web/src/hooks/use-routes.ts
+++ b/apps/web/src/hooks/use-routes.ts
@@ -20,34 +20,48 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { useLocation } from "wouter";
import makeMatcher from "wouter/matcher";
import { navigate, getHomeRoute } from "../navigation";
-import { Params, Routes } from "../navigation/types";
+import { Params, RouteResult, Routes } from "../navigation/types";
+import { useEffect, useState } from "react";
export default function useRoutes<T extends string>(
routes: Routes<T>,
options?: {
- hooks?: { beforeNavigate: (location: string) => void };
+ hooks?: { beforeNavigate: (location: string) => boolean };
fallbackRoute?: string;
}
) {
const [location] = useLocation();
- const matcher = makeMatcher();
+ const [result, setResult] = useState<RouteResult>();
- if (location === "/") navigate(getHomeRoute());
+ useEffect(() => {
+ (async function () {
+ const matcher = makeMatcher();
- options?.hooks?.beforeNavigate(location);
+ if (
+ options?.hooks?.beforeNavigate &&
+ !options?.hooks?.beforeNavigate(location)
+ )
+ return;
- for (const key in routes) {
- const [match, params] = matcher(key, location);
- if (match) {
- const result = routes[key]((params as Params<typeof key>) || {});
- if (!result) break;
- return [result, location] as const;
- }
- }
- if (!options) return [] as const;
- const { fallbackRoute } = options;
- if (fallbackRoute) {
- navigate(fallbackRoute);
- }
- return [] as const;
+ for (const key in routes) {
+ const [match, params] = matcher(key, location);
+ if (match) {
+ const result = await routes[key](
+ (params as Params<typeof key>) || {}
+ );
+ if (!result) break;
+ setResult(result);
+ return;
+ }
+ }
+
+ if (!options) return;
+ const { fallbackRoute } = options;
+ if (fallbackRoute) {
+ navigate(fallbackRoute);
+ }
+ })();
+ }, [location]);
+
+ return result ? ([result, location] as const) : [];
}
diff --git a/apps/web/src/index.html b/apps/web/src/index.html
index 499e6659e..717b8d0b1 100644
--- a/apps/web/src/index.html
+++ b/apps/web/src/index.html
@@ -155,7 +155,7 @@
height="1000"
rx="30%"
ry="30%"
- style="fill: var(--paragraph)"
+ style="fill: var(--heading)"
/>
<g transform="translate(275,176.95254)">
<path
@@ -166,7 +166,7 @@
</symbol>
<symbol id="themed-logo" viewBox="0 0 450 646.09491">
<path
- style="fill: var(--paragraph)"
+ style="fill: var(--heading)"
d="M437.985 493.919c-17.255 50.411-51.835 93.065-97.588 120.372-45.752 27.307-99.71 37.496-152.269 28.753-52.56-8.743-100.313999-35.85-134.763-76.498C18.916 525.898.006 474.347 0 421.064v-110.25l79.121001 33.053v77.152c-.007 20.779 4.434 41.318 13.024 60.237C100.735 500.176 113.276 517.037 128.925 530.707c2.97 2.587 6.053 5.107 9.236 7.459 23.357 17.388 51.402 27.352 80.494 28.597.99 0 1.946.079 2.925.101.979.023 2.25 0 3.375 0h3.375c1.125 0 1.935 0 2.925-.101 29.081-1.248 57.116-11.203 80.471-28.575 3.173-2.351 6.255-4.86 9.237-7.447 20.556-17.98 35.656-41.366 43.582-67.5zM450 225v196.065c0 2.531 0 5.074-.158 7.605l-78.963-33.019V225c-.013-37.684-14.607-73.901-40.725-101.066-26.119-27.164003-61.735-43.168003-99.389-44.660003-37.655-1.492-74.426 11.644-102.611 36.657003-28.185999 25.013-45.599999 59.962-48.593999 97.526-.281 3.803-.439 7.662-.439 11.543v48.712L0 240.637V0h225c59.674 0 116.903 23.705 159.099 65.901C426.295 108.097 450 165.326 450 225Z"
/>
</symbol>
diff --git a/apps/web/src/index.ts b/apps/web/src/index.ts
index cfc2c2ddc..741c3f0ad 100644
--- a/apps/web/src/index.ts
+++ b/apps/web/src/index.ts
@@ -44,7 +44,7 @@ if (theme) {
if (stylesheet) stylesheet.innerHTML = css;
} else stylesheet?.remove();
-const locale = import.meta.env.DEV
+const locale = !import.meta.env.DEV
? import("@notesnook/intl/locales/$pseudo-LOCALE.json")
: import("@notesnook/intl/locales/$en.json");
locale.then(({ default: locale }) => {
diff --git a/apps/web/src/navigation/hash-routes.tsx b/apps/web/src/navigation/hash-routes.tsx
index 174c6eeb6..c19b0f1af 100644
--- a/apps/web/src/navigation/hash-routes.tsx
+++ b/apps/web/src/navigation/hash-routes.tsx
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { hashNavigate } from ".";
-import { defineRoutes } from "./types";
+import { defineHashRoutes } from "./types";
import { useEditorStore } from "../stores/editor-store";
import {
AddNotebookDialog,
@@ -35,7 +35,7 @@ import { FeatureDialog } from "../dialogs/feature-dialog";
import { CreateTagDialog } from "../dialogs/item-dialog";
import { OnboardingDialog } from "../dialogs/onboarding-dialog";
-const hashroutes = defineRoutes({
+const hashroutes = defineHashRoutes({
"/": () => {},
"/email/verify": () => {
EmailVerificationDialog.show({}).then(afterAction);
@@ -55,12 +55,6 @@ const hashroutes = defineRoutes({
"/tags/create": () => {
CreateTagDialog.show().then(afterAction);
},
- "/notes/:noteId/create": ({ noteId }) => {
- useEditorStore.getState().openSession(noteId);
- },
- "/notes/:noteId/edit": ({ noteId }) => {
- useEditorStore.getState().openSession(noteId);
- },
"/buy": () => {
BuyDialog.show({}).then(afterAction);
},
diff --git a/apps/web/src/navigation/routes.tsx b/apps/web/src/navigation/routes.tsx
index b9c610f59..01db23154 100644
--- a/apps/web/src/navigation/routes.tsx
+++ b/apps/web/src/navigation/routes.tsx
@@ -19,11 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { db } from "../common/db";
import AllNotes from "../views/all-notes";
-import Notebooks from "../views/notebooks";
import Notes from "../views/notes";
-import Tags from "../views/tags";
-import Notebook from "../views/notebook";
-import { navigate } from ".";
+import { NotebookHeader } from "../components/notebook-header";
import Trash from "../views/trash";
import { store as notestore } from "../stores/note-store";
import Reminders from "../views/reminders";
@@ -35,9 +32,15 @@ function defineRoute(route: RouteResult): RouteResult {
return route;
}
+const NOT_FOUND_ROUTE = defineRoute({
+ key: "notFound",
+ type: "notFound",
+ component: () => <div>Not found</div>
+});
const routes = defineRoutes({
- "/notes": () =>
- defineRoute({
+ "/notes": () => {
+ notestore.setContext();
+ return defineRoute({
key: "home",
type: "notes",
title: strings.routes.Notes(),
@@ -48,155 +51,79 @@ const routes = defineRoutes({
title: strings.searchANote()
}
}
- }),
- "/notebooks": () =>
- defineRoute({
- key: "notebooks",
- type: "notebooks",
- title: strings.routes.Notebooks(),
- component: Notebooks,
- buttons: {
- create: CREATE_BUTTON_MAP.notebooks,
- search: {
- title: strings.searchNotebooks()
- }
- }
- }),
- "/notebooks/:rootId/:notebookId?": ({ rootId, notebookId }) => {
+ });
+ },
+ "/notebooks/:notebookId": async ({ notebookId }) => {
+ const notebook = await db.notebooks.notebook(notebookId);
+ if (!notebook) return NOT_FOUND_ROUTE;
+ const totalNotes = await db.relations.from(notebook, "note").count();
+ notestore.setContext({
+ type: "notebook",
+ id: notebookId,
+ item: notebook,
+ totalNotes
+ });
+
return defineRoute({
key: "notebook",
- type: "notes",
- noCache: true,
- component: Notebook,
+ type: "notebook",
+ component: Notes,
+ title: notebook.title,
props: {
- rootId,
- notebookId
- },
- // () => (
- // <Notebook key={rootId} rootId={rootId} notebookId={notebookId} />
- // ),
- buttons: {
- create: CREATE_BUTTON_MAP.notes,
- search: {
- title: strings.searchANote()
- }
+ header: <NotebookHeader notebook={notebook} totalNotes={totalNotes} />
}
});
},
- // "/notebooks/:rootId/:notebookId": ({ notebookId, rootId }) => {
- // return defineRoute({
- // key: "notebook",
- // type: "notes",
- // // title: topic.title,
- // component: () => (
- // <Notebook key={rootId} rootId={rootId} notebookId={notebookId} />
- // ),
- // buttons: {
- // create: CREATE_BUTTON_MAP.notes,
- // back: {
- // title: `Go back to notebooks`, // ${notebook.title}`,
- // onClick: () => navigate(`/notebooks/${rootId}`)
- // },
- // search: {
- // title: `Search notes`
- // }
- // }
- // });
- // },
"/favorites": () => {
notestore.setContext({ type: "favorite" });
return defineRoute({
key: "notes",
title: strings.routes.Favorites(),
type: "notes",
- component: Notes,
- buttons: {
- search: {
- title: strings.searchANote()
- }
- }
+ component: Notes
});
},
"/reminders": () => {
+ notestore.setContext();
return defineRoute({
key: "reminders",
title: strings.routes.Reminders(),
type: "reminders",
component: Reminders,
buttons: {
- create: CREATE_BUTTON_MAP.reminders,
- search: {
- title: strings.searchInRoute("Reminders")
- }
+ create: CREATE_BUTTON_MAP.reminders
}
});
},
- "/trash": () =>
- defineRoute({
+ "/trash": () => {
+ notestore.setContext();
+ return defineRoute({
key: "trash",
type: "trash",
title: strings.routes.Trash(),
- component: Trash,
- buttons: {
- search: {
- title: strings.searchInRoute("Trash")
- }
- }
- }),
- "/tags": () =>
- defineRoute({
- key: "tags",
- title: strings.routes.Tags(),
- type: "tags",
- component: Tags,
- buttons: {
- create: CREATE_BUTTON_MAP.tags,
- search: {
- title: strings.searchInRoute("Tags")
- }
- }
- }),
- "/tags/:tagId": ({ tagId }) => {
+ component: Trash
+ });
+ },
+ "/tags/:tagId": async ({ tagId }) => {
+ const tag = await db.tags.tag(tagId);
+ if (!tag) return NOT_FOUND_ROUTE;
notestore.setContext({ type: "tag", id: tagId });
return defineRoute({
key: "notes",
type: "notes",
- title: async () => {
- const tag = await db.tags.tag(tagId);
- if (!tag) return;
- notestore.setContext({
- type: "tag",
- id: tagId,
- item: tag
- });
- return `#${tag.title}`;
- },
- component: Notes,
- buttons: {
- create: CREATE_BUTTON_MAP.notes,
- search: {
- title: strings.searchANote()
- }
- }
+ title: `#${tag.title}`,
+ component: Notes
});
},
- "/colors/:colorId": ({ colorId }) => {
+ "/colors/:colorId": async ({ colorId }) => {
+ const color = await db.colors.color(colorId);
+ if (!color) return NOT_FOUND_ROUTE;
notestore.setContext({ type: "color", id: colorId });
return defineRoute({
key: "notes",
type: "notes",
- title: async () => {
- const color = await db.colors.color(colorId);
- if (!color) return;
- return `${color.title}`;
- },
- component: Notes,
- buttons: {
- create: CREATE_BUTTON_MAP.notes,
- search: {
- title: strings.searchANote()
- }
- }
+ title: color.title,
+ component: Notes
});
},
"/monographs": () => {
@@ -205,12 +132,7 @@ const routes = defineRoutes({
key: "notes",
title: strings.routes.Monographs(),
type: "notes",
- component: Notes,
- buttons: {
- search: {
- title: strings.searchInRoute("Monographs")
- }
- }
+ component: Notes
});
}
});
diff --git a/apps/web/src/navigation/types.ts b/apps/web/src/navigation/types.ts
index ddf7ec825..34f115f57 100644
--- a/apps/web/src/navigation/types.ts
+++ b/apps/web/src/navigation/types.ts
@@ -21,7 +21,14 @@ import { RouteContainerButtons } from "../components/route-container";
export type RouteResult = {
key: string;
- type: "notes" | "notebooks" | "reminders" | "trash" | "tags";
+ type:
+ | "notes"
+ | "notebook"
+ | "notebooks"
+ | "reminders"
+ | "trash"
+ | "tags"
+ | "notFound";
title?: string | (() => Promise<string | undefined>);
component:
| ((props?: any) => JSX.Element | null)
@@ -64,11 +71,19 @@ export type Params<Path> = {
};
export type Routes<T extends string> = {
- [Path in T]: (
- params: Params<Path>
- ) => boolean | React.ReactNode | RouteResult | void;
+ [Path in T]: (params: Params<Path>) => Promise<RouteResult> | RouteResult;
+};
+
+export type HashRoutes<T extends string> = {
+ [Path in T]: (params: Params<Path>) => void;
};
export function defineRoutes<T extends string>(routes: Routes<T>): Routes<T> {
return routes;
}
+
+export function defineHashRoutes<T extends string>(
+ routes: HashRoutes<T>
+): HashRoutes<T> {
+ return routes;
+}
diff --git a/apps/web/src/stores/app-store.ts b/apps/web/src/stores/app-store.ts
index 8fd3a070e..063bf4308 100644
--- a/apps/web/src/stores/app-store.ts
+++ b/apps/web/src/stores/app-store.ts
@@ -65,6 +65,8 @@ let pendingSync: SyncOptions | undefined = undefined;
class AppStore extends BaseStore<AppStore> {
isFocusMode = false;
+ isListPaneVisible = true;
+ isNavPaneCollapsed = false;
isVaultCreated = false;
isAutoSyncEnabled = Config.get("autoSyncEnabled", true);
isSyncEnabled = Config.get("syncEnabled", true);
@@ -74,7 +76,9 @@ class AppStore extends BaseStore<AppStore> {
progress: null,
type: undefined
};
- colors: (Color & { count: number })[] = [];
+ colors: Color[] = [];
+ hiddenColors: string[] = Config.get("sidebarHiddenItems:colors", []);
+ hiddenRoutes: string[] = Config.get("sidebarHiddenItems:routes", []);
notices: Notice[] = [];
shortcuts: (Notebook | Tag)[] = [];
lastSynced = 0;
@@ -84,6 +88,10 @@ class AppStore extends BaseStore<AppStore> {
// this needs to happen here so reminders can be set on app load.
reminderStore.refresh();
announcementStore.refresh();
+ this.set({
+ hiddenColors: db.settings.getSideBarHiddenItems("colors"),
+ hiddenRoutes: db.settings.getSideBarHiddenItems("routes")
+ });
this.get().sync({ type: "full" });
EV.subscribe(EVENTS.appRefreshRequested, () => this.refresh());
@@ -144,6 +152,25 @@ class AppStore extends BaseStore<AppStore> {
});
};
+ setHiddenColors = (ids: string[]) => {
+ Config.set("sidebarHiddenItems:colors", ids);
+ db.settings.setSideBarHiddenItems("colors", ids);
+ this.set({ hiddenColors: ids });
+ };
+
+ setHiddenRoutes = (ids: string[]) => {
+ Config.set("sidebarHiddenItems:routes", ids);
+ db.settings.setSideBarHiddenItems("routes", ids);
+ this.set({ hiddenRoutes: ids });
+ };
+
+ toggleListPane = (booleanState?: boolean) => {
+ this.set(
+ (state) =>
+ (state.isListPaneVisible = booleanState ?? !state.isListPaneVisible)
+ );
+ };
+
refresh = async () => {
logger.measure("refreshing app");
@@ -166,16 +193,9 @@ class AppStore extends BaseStore<AppStore> {
refreshNavItems = async () => {
const shortcuts = await db.shortcuts.resolved();
const colors = await db.colors.all.items();
-
- let newColors: (Color & { count: number })[] = [];
- for (const color of colors) {
- const count = await db.colors.count(color.id);
- newColors.push({ ...color, count: count ?? 0 });
- }
-
this.set((state) => {
state.shortcuts = shortcuts;
- state.colors = newColors;
+ state.colors = colors;
});
};
diff --git a/apps/web/src/stores/attachment-store.ts b/apps/web/src/stores/attachment-store.ts
index e011861b9..e56053509 100644
--- a/apps/web/src/stores/attachment-store.ts
+++ b/apps/web/src/stores/attachment-store.ts
@@ -135,10 +135,7 @@ class AttachmentStore extends BaseStore<AttachmentStore> {
if (await db.attachments.remove(attachment.hash, false)) {
await this.get().refresh();
await useNoteStore.getState().refresh();
- const sessions = linkedNotes
- .map((id) => useEditorStore.getState().getSessionsForNote(id))
- .flat();
- useEditorStore.getState().closeTabs(...sessions.map((s) => s.id));
+ useEditorStore.getState().closeNotes(...linkedNotes);
}
} catch (e) {
console.error(e);
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts
index 284cfcd49..5d01f4ce2 100644
--- a/apps/web/src/stores/editor-store.ts
+++ b/apps/web/src/stores/editor-store.ts
@@ -48,7 +48,6 @@ import {
TabSessionHistory
} from "@notesnook/common";
import { isCipher } from "@notesnook/core";
-import { hashNavigate } from "../navigation";
import { AppEventManager, AppEvents } from "../common/app-events";
import Vault from "../common/vault";
import { Mutex } from "async-mutex";
@@ -547,8 +546,6 @@ class EditorStore extends BaseStore<EditorStore> {
};
activateSession = (id?: string, activeBlockId?: string, silent?: boolean) => {
- if (!id) hashNavigate(`/`, { replace: true, notify: false });
-
const session = this.get().sessions.find((s) => s.id === id);
if (!session) id = undefined;
@@ -568,12 +565,6 @@ class EditorStore extends BaseStore<EditorStore> {
AppEventManager.publish(AppEvents.toggleEditor, true);
- if (id) {
- if (session?.type === "new")
- hashNavigate(`/notes/${id}/create`, { replace: true, notify: false });
- else hashNavigate(`/notes/${id}/edit`, { replace: true, notify: false });
- }
-
if (activeBlockId && session)
this.updateSession(session.id, [session.type], {
activeBlockId
@@ -1110,6 +1101,15 @@ class EditorStore extends BaseStore<EditorStore> {
const { tabs } = this.get();
this.closeTabs(...tabs.map((t) => t.id));
};
+
+ closeNotes = (...noteIds: string[]) => {
+ const { getTabsForNote, closeTabs } = this.get();
+ const tabs = noteIds
+ .map((id) => getTabsForNote(id))
+ .flat()
+ .map((t) => t.id);
+ closeTabs(...tabs);
+ };
closeTabs = (...ids: string[]) => {
this.set((state) => {
diff --git a/apps/web/src/stores/note-store.ts b/apps/web/src/stores/note-store.ts
index 4498417d1..db61d56e8 100644
--- a/apps/web/src/stores/note-store.ts
+++ b/apps/web/src/stores/note-store.ts
@@ -52,7 +52,7 @@ class NoteStore extends BaseStore<NoteStore> {
refreshContext = async () => {
const context = this.get().context;
if (!context) return;
- await this.setContext(context);
+ await this.setContext({ ...context });
};
setContext = async (context?: Context) => {
diff --git a/apps/web/src/stores/notebook-store.ts b/apps/web/src/stores/notebook-store.ts
index 8aedb3519..712fadbb8 100644
--- a/apps/web/src/stores/notebook-store.ts
+++ b/apps/web/src/stores/notebook-store.ts
@@ -36,7 +36,7 @@ class NotebookStore extends BaseStore<NotebookStore> {
};
refresh = async () => {
- const notebooks = await db.notebooks.roots.grouped(
+ const notebooks = await db.notebooks.roots.sorted(
db.settings.getGroupOptions("notebooks")
);
this.set({ notebooks });
diff --git a/apps/web/src/stores/theme-store.ts b/apps/web/src/stores/theme-store.ts
index 2f435a928..fe39d83ce 100644
--- a/apps/web/src/stores/theme-store.ts
+++ b/apps/web/src/stores/theme-store.ts
@@ -32,8 +32,8 @@ import { ThemesRouter } from "../common/themes-router";
type ColorScheme = "dark" | "light";
class ThemeStore extends BaseStore<ThemeStore> {
colorScheme: "dark" | "light" = Config.get("colorScheme", "light");
- darkTheme = getTheme("dark");
- lightTheme = getTheme("light");
+ darkTheme = ThemeDark; // getTheme("dark");
+ lightTheme = ThemeLight; // getTheme("light");
followSystemTheme = Config.get("followSystemTheme", false);
init = async () => {
@@ -42,10 +42,11 @@ class ThemeStore extends BaseStore<ThemeStore> {
colorScheme === "dark" ? darkTheme : lightTheme,
this.get().followSystemTheme
);
- this.set({
- darkTheme: await updateTheme(darkTheme),
- lightTheme: await updateTheme(lightTheme)
- });
+ // this.set({
+ // darkTheme: await updateTheme(darkTheme),
+ // lightTheme: await updateTheme(lightTheme)
+ // });
+ console.log(darkTheme, lightTheme);
};
setTheme = (theme: ThemeDefinition) => {
diff --git a/apps/web/src/views/notebook.tsx b/apps/web/src/views/notebook.tsx
deleted file mode 100644
index 5c9b899ab..000000000
--- a/apps/web/src/views/notebook.tsx
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
-This file is part of the Notesnook project (https://notesnook.com/)
-
-Copyright (C) 2023 Streetwriters (Private) Limited
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-import { useEffect, useLayoutEffect, useRef, useState } from "react";
-import { useStore as useAppStore } from "../stores/app-store";
-import { hashNavigate, navigate } from "../navigation";
-import { Button, Flex, Text } from "@theme-ui/components";
-import {
- ChevronDown,
- ChevronRight,
- Edit,
- MoreHorizontal,
- Notebook2,
- RemoveShortcutLink,
- ShortcutLink
-} from "../components/icons";
-import { Plus } from "../components/icons";
-import { useStore as useNotesStore } from "../stores/note-store";
-import { useStore as useNotebookStore } from "../stores/notebook-store";
-import { db } from "../common/db";
-import { getFormattedDate, usePromise } from "@notesnook/common";
-import SubNotebook from "../components/sub-notebook";
-import { NotebookContext } from "../components/list-container/types";
-import { Menu } from "../hooks/use-menu";
-import Notes from "./notes";
-import { AddNotebookDialog } from "../dialogs/add-notebook-dialog";
-import { strings } from "@notesnook/intl";
-import { Notebook as NotebookType } from "@notesnook/core";
-import { useStore as useSelectionStore } from "../stores/selection-store";
-import {
- TreeNode,
- VirtualizedTree,
- VirtualizedTreeHandle
-} from "../components/virtualized-tree";
-import {
- Pane,
- SplitPane,
- SplitPaneImperativeHandle
-} from "../components/split-pane";
-
-type NotebookProps = {
- rootId: string;
- notebookId?: string;
-};
-function Notebook(props: NotebookProps) {
- const { rootId, notebookId } = props;
- const [isCollapsed, setIsCollapsed] = useState(false);
-
- const pane = useRef<SplitPaneImperativeHandle>(null);
-
- const context = useNotesStore((store) => store.context);
- const notes = useNotesStore((store) => store.contextNotes);
-
- useLayoutEffect(() => {
- const { context, setContext } = useNotesStore.getState();
- if (
- context &&
- context.type === "notebook" &&
- context.id &&
- (context.id === rootId || context.id === notebookId)
- )
- return;
- if (!notebookId && !rootId) return;
-
- Promise.all([
- !!notebookId && db.notebooks.exists(notebookId),
- db.notebooks.exists(rootId)
- ]).then(async (exists) => {
- if (exists.every((e) => !e)) {
- navigate(`/notebooks`, { replace: true });
- return;
- }
- const notebook = await db.notebooks.notebook(notebookId || rootId);
- setContext({
- type: "notebook",
- id: notebookId || rootId,
- item: notebook
- });
- });
- }, [rootId, notebookId]);
-
- if (!context || !notes || context.type !== "notebook") return null;
- return (
- <SplitPane
- ref={pane}
- direction="horizontal"
- autoSaveId={`notebook-panel-sizes:${rootId}`}
- onChange={([_, subnotebooksPane]) => {
- setIsCollapsed((isCollapsed) => {
- if (subnotebooksPane <= 34 && !isCollapsed) return true;
- else if (subnotebooksPane >= 35 && isCollapsed) return false;
- return isCollapsed;
- });
- }}
- >
- <Pane id="notes-pane" style={{ display: "flex" }}>
- <Notes
- header={
- <NotebookHeader
- key={context.id}
- rootId={rootId}
- context={context}
- />
- }
- />
- </Pane>
- </SplitPane>
- );
-}
-export default Notebook;
-
-function NotebookHeader({
- rootId,
- context
-}: {
- rootId: string;
- context: NotebookContext;
-}) {
- const moreCrumbsRef = useRef<HTMLButtonElement>(null);
- const notebooks = useNotebookStore((store) => store.notebooks);
- const [notebook, setNotebook] = useState(context.item);
- const [totalNotes, setTotalNotes] = useState(context.totalNotes);
- const [crumbs, setCrumbs] = useState<{ id: string; title: string }[]>([]);
- const [isShortcut, setIsShortcut] = useState(false);
- const shortcuts = useAppStore((store) => store.shortcuts);
- const addToShortcuts = useAppStore((store) => store.addToShortcuts);
-
- useEffect(() => {
- setIsShortcut(shortcuts.findIndex((p) => p.id === context.id) > -1);
- }, [shortcuts, context.id]);
-
- useEffect(() => {
- (async function () {
- setNotebook(await db.notebooks.notebook(context.id));
- })();
- }, [notebooks]);
-
- useEffect(() => {
- (async function () {
- if (!notebook) setNotebook(await db.notebooks.notebook(context.id));
- if (totalNotes === undefined)
- setTotalNotes(
- await db.relations
- .from({ type: "notebook", id: context.id }, "note")
- .count()
- );
- })();
- }, [context.id, totalNotes, notebook]);
-
- useEffect(() => {
- (async function () {
- setCrumbs(await db.notebooks.breadcrumbs(context.id));
- })();
- }, [context.id]);
-
- if (!notebook) return null;
- const { title, description, dateEdited } = notebook;
-
- return (
- <Flex
- data-test-id="notebook-header"
- mx={2}
- mb={2}
- sx={{ flexDirection: "column", minWidth: 200 }}
- >
- <Flex sx={{ alignItems: "center", mb: 1 }}>
- <Button
- ref={moreCrumbsRef}
- variant="icon"
- sx={{ p: 0, flexShrink: 0 }}
- title={strings.notebooks()}
- >
- <Notebook2 size={14} />
- </Button>
- <ChevronRight as="span" size={14} />
- {crumbs.length > 2 ? (
- <>
- <Button
- ref={moreCrumbsRef}
- variant="icon"
- sx={{ p: 0, flexShrink: 0 }}
- onClick={() => {
- if (!moreCrumbsRef.current) return;
- Menu.openMenu(
- crumbs
- .slice(0, -2)
- .reverse()
- .map((c) => ({
- type: "button",
- title: c.title,
- key: c.id,
- icon: Notebook2.path,
- onClick: () => navigateCrumb(c.id, rootId)
- })),
- {
- position: {
- target: moreCrumbsRef.current,
- location: "below",
- isTargetAbsolute: true,
- align: "start",
- yOffset: 10
- }
- }
- );
- }}
- >
- <MoreHorizontal size={14} />
- </Button>
- <ChevronRight as="span" size={14} />
- </>
- ) : null}
- <Text
- as="p"
- sx={{
- whiteSpace: "nowrap",
- textOverflow: "ellipsis",
- overflow: "hidden"
- }}
- >
- {crumbs.slice(-2).map((crumb, index, array) => (
- <>
- <Text
- as="span"
- sx={{
- fontSize: "subBody",
- textDecoration: "none",
- color: "var(--paragraph-secondary)",
- whiteSpace: "nowrap",
- textOverflow: "ellipsis",
- overflow: "hidden",
- cursor: "pointer",
- ":hover": { color: "paragraph-hover" }
- }}
- onClick={() => navigateCrumb(crumb.id, rootId)}
- >
- {crumb.title}
- </Text>
- {index === array.length - 1 ? null : (
- <ChevronRight
- as="span"
- sx={{ display: "inline", verticalAlign: "middle" }}
- size={14}
- />
- )}
- </>
- ))}
- </Text>
- </Flex>
- <Text variant="subBody">{getFormattedDate(dateEdited, "date")}</Text>
- <Flex sx={{ alignItems: "center", justifyContent: "space-between" }}>
- <Text
- data-test-id="notebook-title"
- variant="heading"
- sx={{ fontSize: "subheading" }}
- >
- {title}
- </Text>
- <Flex>
- <Button
- variant="secondary"
- sx={{ borderRadius: 100, width: 30, height: 30 }}
- mr={1}
- p={0}
- title={
- isShortcut ? strings.removeShortcut() : strings.createShortcut()
- }
- onClick={() => addToShortcuts(notebook)}
- >
- {isShortcut ? (
- <RemoveShortcutLink size={16} />
- ) : (
- <ShortcutLink size={16} />
- )}
- </Button>
- <Button
- variant="secondary"
- sx={{ borderRadius: 100, width: 30, height: 30 }}
- p={0}
- title={strings.editNotebook()}
- onClick={() => hashNavigate(`/notebooks/${notebook.id}/edit`)}
- >
- <Edit size={16} />
- </Button>
- </Flex>
- </Flex>
-
- {description && (
- <Text variant="body" sx={{ fontSize: "subtitle" }}>
- {description}
- </Text>
- )}
- <Text as="em" variant="subBody" mt={2}>
- {/* {pluralize(topics.length, "topic")}, */}
- {strings.notes(totalNotes || 0)}
- </Text>
- </Flex>
- );
-}
-
-function navigateCrumb(notebookId: string, rootId?: string) {
- if (notebookId === "notebooks") navigate("/notebooks");
- else if (rootId && notebookId === rootId) {
- navigate(`/notebooks/${rootId}`);
- } else if (rootId && notebookId) {
- navigate(`/notebooks/${rootId}/${notebookId}`);
- }
-}
-
-type SubNotebookTreeItem = {
- notebook: NotebookType;
- totalNotes: number;
-};
-async function fetchChildren(
- id: string,
- depth: number
-): Promise<TreeNode<SubNotebookTreeItem>[]> {
- const subNotebooks = await db.relations
- .from({ type: "notebook", id }, "notebook")
- .resolve();
-
- const nodes: TreeNode<SubNotebookTreeItem>[] = [];
- for (const notebook of subNotebooks) {
- const hasChildren =
- (await db.relations.from(notebook, "notebook").count()) > 0;
- const totalNotes = await db.relations.from(notebook, "note").count();
- nodes.push({
- parentId: id,
- id: notebook.id,
- data: { notebook, totalNotes },
- depth: depth + 1,
- hasChildren
- });
- }
-
- return nodes;
-}
diff --git a/apps/web/src/views/notebooks.tsx b/apps/web/src/views/notebooks.tsx
index 125edfb91..5d9d1d12f 100644
--- a/apps/web/src/views/notebooks.tsx
+++ b/apps/web/src/views/notebooks.tsx
@@ -17,41 +17,147 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { useStore, store } from "../stores/notebook-store";
-import { navigate } from "../navigation";
+import { Notebook as NotebookType, VirtualizedGrouping } from "@notesnook/core";
+import { Box, Flex, Input } from "@theme-ui/components";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
+import { db } from "../common/db";
+import { store, useStore } from "../stores/notebook-store";
+import { useStore as useSelectionStore } from "../stores/selection-store";
import Placeholder from "../components/placeholders";
-import { useEffect } from "react";
+import { Notebook } from "../components/notebook";
+import {
+ TreeNode,
+ VirtualizedTree,
+ VirtualizedTreeHandle
+} from "../components/virtualized-tree";
import { ListLoader } from "../components/loaders/list-loader";
-import { Flex } from "@theme-ui/components";
+import { debounce } from "@notesnook/common";
-function Notebooks() {
- const notebooks = useStore((state) => state.notebooks);
+export function Notebooks() {
+ const roots = useStore((store) => store.notebooks);
+ const [filteredNotebooks, setFilteredNotebooks] =
+ useState<VirtualizedGrouping<NotebookType>>();
+ const treeRef =
+ useRef<
+ VirtualizedTreeHandle<{ notebook: NotebookType; totalNotes: number }>
+ >(null);
+ const setSelectedItems = useSelectionStore((store) => store.setSelectedItems);
+ const isSelected = useSelectionStore((store) => store.isSelected);
+ const selectItem = useSelectionStore((store) => store.selectItem);
+ const deselectItem = useSelectionStore((store) => store.deselectItem);
+ const toggleSelection = useSelectionStore(
+ (store) => store.toggleSelectionMode
+ );
+ const notebooks = filteredNotebooks || roots;
useEffect(() => {
store.get().refresh();
+ }, []);
- if (notebooks && notebooks.length > 0) {
- notebooks.item(0).then((item) => {
- if (item && item?.item) {
- navigate(`/notebooks/${item.item.id}`);
- }
- });
- }
+ useEffect(() => {
+ treeRef.current?.refresh();
}, [notebooks]);
- if (!notebooks) return <ListLoader />;
-
+ if (!notebooks)
+ return (
+ <Flex sx={{ flexDirection: "column" }}>
+ <ListLoader />
+ </Flex>
+ );
if (notebooks.length === 0) {
return (
- <Flex variant="columnFill" sx={{ overflow: "hidden" }}>
- <Flex variant="columnCenterFill">
- <Placeholder context="notebooks" />
- </Flex>
+ <Flex variant="columnCenterFill" data-test-id="list-placeholder">
+ <Placeholder context="notebooks" />
</Flex>
);
}
- return null;
+ return (
+ <>
+ <Box sx={{ mx: 1, flex: 1 }}>
+ <VirtualizedTree
+ rootId={"root"}
+ itemHeight={26}
+ treeRef={treeRef}
+ deselectAll={() => toggleSelection(false)}
+ bulkSelect={setSelectedItems}
+ isSelected={isSelected}
+ onDeselect={deselectItem}
+ onSelect={selectItem}
+ saveKey="notebook-tree"
+ getChildNodes={async (parentId, depth) => {
+ const nodes: TreeNode<{
+ notebook: NotebookType;
+ totalNotes: number;
+ }>[] = [];
+ const grouping =
+ parentId === "root"
+ ? notebooks
+ : await db.relations
+ .from({ type: "notebook", id: parentId }, "notebook")
+ .selector.sorted(db.settings.getGroupOptions("notebooks"));
+ for (let i = 0; i < grouping.length; ++i) {
+ const notebook = await grouping.item(i);
+ if (!notebook.item) continue;
+ nodes.push({
+ data: { notebook: notebook.item, totalNotes: 0 },
+ depth: depth + 1,
+ hasChildren: false,
+ id: notebook.item.id,
+ parentId
+ });
+ }
+ const allRelations = await db.relations
+ .from({ type: "notebook", ids: nodes.map((n) => n.id) }, [
+ "notebook",
+ "note"
+ ])
+ .get();
+ for (const node of nodes) {
+ node.hasChildren = allRelations.some(
+ (nb) => nb.fromId === node.id && nb.toType === "notebook"
+ );
+ node.data.totalNotes = allRelations.filter(
+ (nb) => nb.fromId === node.id && nb.toType === "note"
+ ).length;
+ }
+ return nodes;
+ }}
+ renderItem={({ collapse, expand, expanded, index, item: node }) => (
+ <Notebook
+ key={node.id}
+ depth={node.depth}
+ isExpandable={node.hasChildren}
+ item={node.data.notebook}
+ isExpanded={expanded}
+ totalNotes={node.data.totalNotes}
+ refresh={async () => {
+ const notebook = await db.notebooks.notebook(node.id);
+ const totalNotes = await db.relations
+ .from(node.data.notebook, "note")
+ .count();
+ treeRef.current?.refreshItem(
+ index,
+ notebook ? { notebook, totalNotes } : undefined
+ );
+ }}
+ collapse={collapse}
+ expand={expand}
+ />
+ )}
+ />
+ </Box>
+ <Input
+ variant="clean"
+ placeholder="Filter notebooks..."
+ sx={{ borderTop: "1px solid var(--border)", mx: 0 }}
+ onChange={debounce(async (e) => {
+ const query = e.target.value.trim();
+ setFilteredNotebooks(
+ await (query ? db.lookup.notebooks(query).sorted() : undefined)
+ );
+ }, 300)}
+ />
+ </>
+ );
}
-
-export default Notebooks;
diff --git a/apps/web/src/views/tags.tsx b/apps/web/src/views/tags.tsx
index 28cbdec54..a88ecbae0 100644
--- a/apps/web/src/views/tags.tsx
+++ b/apps/web/src/views/tags.tsx
@@ -19,42 +19,46 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import ListContainer from "../components/list-container";
import { useStore, store } from "../stores/tag-store";
-import useNavigate from "../hooks/use-navigate";
import Placeholder from "../components/placeholders";
-import { useSearch } from "../hooks/use-search";
import { db } from "../common/db";
import { ListLoader } from "../components/loaders/list-loader";
-import { useEffect } from "react";
-import { navigate } from "../navigation";
+import { Flex, Input } from "@theme-ui/components";
+import { useEffect, useState } from "react";
+import { debounce } from "@notesnook/common";
+import { Tag, VirtualizedGrouping } from "@notesnook/core";
-type Props = {
- isSidebar?: boolean;
-};
-
-function Tags({ isSidebar }: Props) {
- useNavigate("tags", () => store.refresh());
+function Tags() {
const tags = useStore((store) => store.tags);
const refresh = useStore((store) => store.refresh);
- const filteredItems = useSearch("tags", (query) =>
- db.lookup.tags(query).sorted()
- );
+ const [filteredTags, setFilteredTags] = useState<VirtualizedGrouping<Tag>>();
+ const items = filteredTags || tags;
useEffect(() => {
- if (isSidebar) return;
- tags?.item(0).then((item) => {
- if (item && item?.item) {
- navigate(`/tags/${item.item.id}`);
- }
- });
- }, [tags, location]);
-
- if (!tags) return <ListLoader />;
+ store.refresh();
+ }, []);
+
+ if (!items) return <ListLoader />;
return (
- <ListContainer
- refresh={refresh}
- items={filteredItems || tags}
- placeholder={<Placeholder context="tags" />}
- />
+ <Flex variant="columnFill">
+ <ListContainer
+ sx={{ mx: 1 }}
+ refresh={refresh}
+ items={items}
+ placeholder={<Placeholder context="tags" />}
+ header={<></>}
+ />
+ <Input
+ variant="clean"
+ placeholder="Filter tags..."
+ sx={{ borderTop: "1px solid var(--border)", mx: 0 }}
+ onChange={debounce(async (e) => {
+ const query = e.target.value.trim();
+ setFilteredTags(
+ query ? await db.lookup.tags(query).sorted() : undefined
+ );
+ }, 300)}
+ />
+ </Flex>
);
}
diff --git a/packages/common/src/hooks/use-promise.ts b/packages/common/src/hooks/use-promise.ts
index b60dc74e1..fe9494be6 100644
--- a/packages/common/src/hooks/use-promise.ts
+++ b/packages/common/src/hooks/use-promise.ts
@@ -61,29 +61,32 @@ export function usePromise<T>(
): PromiseResult<T> {
const [result, setResult] = useState<PromiseResult<T>>({ status: "pending" });
- useEffect(function effect() {
- if (result.status !== "pending") {
- setResult((s) => ({
- ...s,
- status: "pending"
- }));
- }
-
- const controller = new AbortController();
- const { signal } = controller;
-
- async function handlePromise() {
- const [promiseResult] = await Promise.allSettled([factory(signal)]);
-
- if (!signal.aborted) {
- setResult({ ...promiseResult, refresh: effect });
+ useEffect(
+ function effect() {
+ if (result.status !== "pending") {
+ setResult((s) => ({
+ ...s,
+ status: "pending"
+ }));
}
- }
- handlePromise();
+ const controller = new AbortController();
+ const { signal } = controller;
- return () => controller.abort();
- }, deps);
+ async function handlePromise() {
+ const [promiseResult] = await Promise.allSettled([factory(signal)]);
+
+ if (!signal.aborted) {
+ setResult({ ...promiseResult, refresh: effect });
+ }
+ }
+
+ handlePromise();
+
+ return () => controller.abort();
+ },
+ [...deps]
+ );
return result;
}
diff --git a/packages/core/src/collections/trash.ts b/packages/core/src/collections/trash.ts
index 4df913971..752154e61 100644
--- a/packages/core/src/collections/trash.ts
+++ b/packages/core/src/collections/trash.ts
@@ -241,6 +241,10 @@ export default class Trash {
] as TrashItem[];
}
+ count() {
+ return this.cache.notes.length + this.cache.notebooks.length;
+ }
+
private async trashedNotes(
ids: string[],
deletedBy?: TrashItem["deletedBy"]
diff --git a/packages/editor/src/extensions/font-size/font-size.ts b/packages/editor/src/extensions/font-size/font-size.ts
index c6ee04163..81a6cfd2d 100644
--- a/packages/editor/src/extensions/font-size/font-size.ts
+++ b/packages/editor/src/extensions/font-size/font-size.ts
@@ -110,6 +110,6 @@ function getFontSize(editor: Editor) {
const defaultFontSize = useToolbarStore.getState().fontSize;
const { fontSize } = editor.getAttributes("textStyle");
return fontSize
- ? parseInt(fontSize.replace("px", "")) || 16
+ ? parseInt(fontSize.replace("px", "")) || 14
: defaultFontSize;
}
diff --git a/packages/editor/src/toolbar/stores/toolbar-store.ts b/packages/editor/src/toolbar/stores/toolbar-store.ts
index 997d2aa6f..76ac940ac 100644
--- a/packages/editor/src/toolbar/stores/toolbar-store.ts
+++ b/packages/editor/src/toolbar/stores/toolbar-store.ts
@@ -98,7 +98,7 @@ export const useToolbarStore = create<ToolbarState>((set, get) => ({
}),
fontFamily: "sans-serif",
setFontFamily: (fontFamily) => set({ fontFamily }),
- fontSize: 16,
+ fontSize: 14,
setFontSize: (fontSize) => set({ fontSize })
}));
diff --git a/packages/editor/src/toolbar/tools/font.tsx b/packages/editor/src/toolbar/tools/font.tsx
index dc39c8136..4377f6edf 100644
--- a/packages/editor/src/toolbar/tools/font.tsx
+++ b/packages/editor/src/toolbar/tools/font.tsx
@@ -34,7 +34,7 @@ export function FontSize(props: ToolProps) {
const defaultFontSize = useToolbarStore((store) => store.fontSize);
const { fontSize } = editor.getAttributes("textStyle");
const fontSizeAsNumber = useRefValue(
- fontSize ? parseInt(fontSize.replace("px", "")) || 16 : defaultFontSize
+ fontSize ? parseInt(fontSize.replace("px", "")) || 14 : defaultFontSize
);
const decreaseFontSize = useCallback(() => {
diff --git a/packages/editor/styles/styles.css b/packages/editor/styles/styles.css
index c7cd580a5..264f188c2 100644
--- a/packages/editor/styles/styles.css
+++ b/packages/editor/styles/styles.css
@@ -17,6 +17,7 @@
.ProseMirror {
font-family: inherit;
+ line-height: 20px;
}
.ProseMirror p.is-editor-empty::before {
diff --git a/packages/theme/src/theme/font/fontsize.ts b/packages/theme/src/theme/font/fontsize.ts
index 12444e283..2e10ed61d 100644
--- a/packages/theme/src/theme/font/fontsize.ts
+++ b/packages/theme/src/theme/font/fontsize.ts
@@ -19,15 +19,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
export function getFontSizes(): FontSizes {
return {
- heading: "1.5rem",
- subheading: "1.2rem",
- input: "0.875rem",
- title: "0.95rem",
- subtitle: "0.85rem",
- body: "0.8rem",
- menu: "0.8rem",
- subBody: "0.750rem",
- code: "0.9rem"
+ heading: "24px",
+ subheading: "20px",
+ input: "12px",
+ title: "16px",
+ subtitle: "14px",
+ body: "12px",
+ subBody: "10px",
+ menu: "12px",
+ code: "14px"
};
}
diff --git a/packages/theme/src/theme/font/index.ts b/packages/theme/src/theme/font/index.ts
index 5490035ae..296bacbc5 100644
--- a/packages/theme/src/theme/font/index.ts
+++ b/packages/theme/src/theme/font/index.ts
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { FontSizes, getFontSizes } from "./fontsize.js";
const SANS_FONT_STACK = [
- `"Open Sans"`,
+ `"Inter"`,
`"Noto Sans"`,
"Frutiger",
"Calibri",
@@ -50,6 +50,7 @@ export type FontConfig = {
body: number;
heading: number;
bold: number;
+ medium: number;
};
fonts: { body: string; monospace: string; heading: string };
};
@@ -60,7 +61,8 @@ export function getFontConfig(): FontConfig {
normal: 400,
body: 400,
heading: 600,
- bold: 600
+ bold: 600,
+ medium: 500
},
fonts: {
body: SANS_FONT_STACK.join(","),
diff --git a/packages/theme/src/theme/index.ts b/packages/theme/src/theme/index.ts
index 434df06a2..dc8c040a2 100644
--- a/packages/theme/src/theme/index.ts
+++ b/packages/theme/src/theme/index.ts
@@ -27,12 +27,13 @@ export { createButtonVariant } from "./variants/button.js";
export { getFontConfig } from "./font/index.js";
export type Theme = {
breakpoints: string[];
- space: number[] & { small?: number | string };
+ space: (number | string)[] & { small?: number | string };
sizes: { full: "100%"; half: "50%" };
radii: {
none: number;
default: number;
dialog: number;
+ large: number;
small: number;
};
shadows: { menu: string };
@@ -50,10 +51,10 @@ export class ThemeFactory {
static construct(config: ThemeConfig): Theme {
const theme: Theme = {
breakpoints: ["480px", "1000px", "1000px"],
- space: [0, 5, 10, 15, 20, 25, 30, 35],
+ space: [0, "6px", 10, 15, 20, 25, 30, 35],
sizes: { full: "100%", half: "50%" },
- radii: { none: 0, default: 5, dialog: 10, small: 2.5 },
- iconSizes: { big: 18, medium: 16, small: 14 },
+ radii: { none: 0, default: 5, large: 7, dialog: 10, small: 2.5 },
+ iconSizes: { big: 16, medium: 14, small: 12 },
colors: flattenVariants(config.scope),
shadows:
config.colorScheme === "dark"
diff --git a/packages/theme/src/theme/variants/button.ts b/packages/theme/src/theme/variants/button.ts
index 6795fac0c..db2ff7ccd 100644
--- a/packages/theme/src/theme/variants/button.ts
+++ b/packages/theme/src/theme/variants/button.ts
@@ -42,7 +42,7 @@ export const createButtonVariant = (
height: "min-content",
px: 2,
- py: "7.5px",
+ py: 1,
overflow: "hidden",
textOverflow: "ellipsis",
@@ -124,6 +124,7 @@ const menuItem: ThemeUIStyleObject = {
...createButtonVariant("transparent", "paragraph", {
hover: { bg: "hover" }
}),
+ px: 1,
borderRadius: 0
};
diff --git a/packages/ui/src/components/menu/menu-button.tsx b/packages/ui/src/components/menu/menu-button.tsx
index fdb9c5045..c6c677755 100644
--- a/packages/ui/src/components/menu/menu-button.tsx
+++ b/packages/ui/src/components/menu/menu-button.tsx
@@ -77,7 +77,7 @@ export function MenuButton(props: MenuButtonProps) {
<Icon
path={icon}
size={"medium"}
- sx={{ mr: 2 }}
+ sx={{ mr: 1 }}
color={
(styles?.icon?.color as string) ||
(variant === "dangerous" ? "icon-error" : "icon")