Skip to content

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

feat: add custom scroll bars

thecodrr4a41a915ed33
diff --git a/apps/web/package.json b/apps/web/package.json
index 9ae2383f3..21fc644a4 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -28,6 +28,7 @@
"react-modal": "^3.11.2",
"react-qrcode-logo": "^2.2.1",
"react-scripts": "3.4.1",
+ "react-scrollbars-custom": "^4.0.25",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "^1.8.6",
"rebass": "^4.0.7",
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 2c2fc1c7b..0ef35ada5 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -7,6 +7,11 @@ import AutoSizer from "react-virtualized-auto-sizer";
import { useStore as useSelectionStore } from "../../stores/selection-store";
import GroupHeader from "../group-header";
import ListProfiles from "../../common/list-profiles";
+import ScrollContainer from "../scroll-container";
+
+const CustomScrollbarsVirtualList = React.forwardRef((props, ref) => (
+ <ScrollContainer {...props} forwardedRef={ref} />
+));
function ListContainer(props) {
const { type, context } = props;
@@ -54,6 +59,7 @@ function ListContainer(props) {
return item.id || item.title;
}
}}
+ outerElementType={CustomScrollbarsVirtualList}
overscanCount={3}
estimatedItemSize={profile.estimatedItemHeight}
itemSize={(index) => {
diff --git a/apps/web/src/components/scroll-container/index.js b/apps/web/src/components/scroll-container/index.js
new file mode 100644
index 000000000..889a24369
--- /dev/null
+++ b/apps/web/src/components/scroll-container/index.js
@@ -0,0 +1,62 @@
+import React from "react";
+import RSC from "react-scrollbars-custom";
+
+const ScrollContainer = ({
+ children,
+ forwardedRef,
+ onScroll,
+ style,
+ className,
+}) => {
+ return (
+ <RSC
+ className={className}
+ style={style}
+ trackClickBehavior="step"
+ onMouseEnter={() => {
+ const scrollTrackY = document.querySelector(".scrollTrackY");
+ if (scrollTrackY) scrollTrackY.style.opacity = 1;
+ }}
+ onMouseLeave={(e) => {
+ if (e.nativeEvent.buttons > 0) return;
+ const scrollTrackY = document.querySelector(".scrollTrackY");
+ if (scrollTrackY) scrollTrackY.style.opacity = 0;
+ }}
+ wrapperProps={{
+ style: { right: 0, inset: "0px 0px 0px 0px" },
+ }}
+ trackYProps={{
+ className: "scrollTrackY",
+ style: {
+ height: "100%",
+ width: 8,
+ top: 0,
+ opacity: 0,
+ transition: "opacity 150ms linear",
+ },
+ }}
+ scrollerProps={{
+ renderer: (props) => {
+ const { elementRef, onScroll: rscOnScroll, ...restProps } = props;
+
+ return (
+ <span
+ {...restProps}
+ onScroll={(e) => {
+ if (onScroll) onScroll(e);
+ rscOnScroll(e);
+ }}
+ ref={(ref) => {
+ if (forwardedRef) forwardedRef(ref);
+ elementRef(ref);
+ }}
+ />
+ );
+ },
+ }}
+ >
+ {children}
+ </RSC>
+ );
+};
+export default ScrollContainer;
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 14ae17070..9cb906c69 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -16,6 +16,7 @@ import dayjs from "dayjs";
import { showRecoveryKeyDialog } from "../components/dialogs/recoverykeydialog";
import { showBuyDialog } from "../components/dialogs/buy-dialog";
import Vault from "../common/vault";
+import ScrollContainer from "../components/scroll-container";
function importBackup() {
return new Promise((resolve, reject) => {
@@ -91,253 +92,261 @@ function Settings(props) {
}, [isVaultCreated]);
return (
- <Flex variant="columnFill" px={2} sx={{ overflowY: "auto" }}>
- {isLoggedIn ? (
- <Flex
- bg="shade"
- flexDirection="column"
- p={2}
- sx={{ borderRadius: "default" }}
- >
- <Flex flex="1" justifyContent="space-between">
- <Flex>
- <Icon.User size={15} color="primary" />
- <Text variant="body" color="text" ml={1}>
- {user.username}
+ <ScrollContainer>
+ <Flex variant="columnFill" px={2}>
+ {isLoggedIn ? (
+ <Flex
+ bg="shade"
+ flexDirection="column"
+ p={2}
+ sx={{ borderRadius: "default" }}
+ >
+ <Flex flex="1" justifyContent="space-between">
+ <Flex>
+ <Icon.User size={15} color="primary" />
+ <Text variant="body" color="text" ml={1}>
+ {user.username}
+ </Text>
+ </Flex>
+ <Text
+ variant="subBody"
+ px={"2px"}
+ py={"1px"}
+ sx={{ borderRadius: "default" }}
+ bg="static"
+ color="primary"
+ >
+ {isTrial ? "Trial" : "Pro"}
</Text>
</Flex>
<Text
- variant="subBody"
- px={"2px"}
- py={"1px"}
- sx={{ borderRadius: "default" }}
- bg="static"
- color="primary"
+ color={subscriptionDaysRemaining <= 5 ? "error" : "primary"}
+ variant="body"
+ fontSize={26}
+ mt={2}
>
- {isTrial ? "Trial" : "Pro"}
+ {subscriptionDaysRemaining} Days Remaining
+ </Text>
+ <Text variant="subBody">
+ Your trial period started on{" "}
+ {dayjs(user.subscription.start).format("MMMM D, YYYY")}
</Text>
+ {isTrial && (
+ <Button mt={2} onClick={showBuyDialog}>
+ Upgrade to Notesnook Pro
+ </Button>
+ )}
</Flex>
- <Text
- color={subscriptionDaysRemaining <= 5 ? "error" : "primary"}
- variant="body"
- fontSize={26}
- mt={2}
- >
- {subscriptionDaysRemaining} Days Remaining
- </Text>
- <Text variant="subBody">
- Your trial period started on{" "}
- {dayjs(user.subscription.start).format("MMMM D, YYYY")}
- </Text>
- {isTrial && (
- <Button mt={2} onClick={showBuyDialog}>
- Upgrade to Notesnook Pro
- </Button>
- )}
- </Flex>
- ) : (
- <Flex
- bg="shade"
- p={2}
- sx={{ borderRadius: "default", cursor: "pointer" }}
- onClick={async () => {
- await showLogInDialog();
- }}
- >
+ ) : (
<Flex
- flex="1 1 auto"
- justifyContent="space-between"
- alignItems="center"
+ bg="shade"
+ p={2}
+ sx={{ borderRadius: "default", cursor: "pointer" }}
+ onClick={async () => {
+ await showLogInDialog();
+ }}
>
- <Flex>
- <Flex
- variant="columnCenter"
- bg="primary"
- mr={2}
- size={35}
- sx={{
- borderRadius: 80,
- }}
- >
- <Icon.User size={20} color="static" />
- </Flex>
- <Flex variant="columnCenter" alignItems="flex-start">
- <Text variant="subBody">You are not logged in</Text>
- <Text variant="body" color="primary" fontSize={"body"}>
- Login to sync your notes
- </Text>
+ <Flex
+ flex="1 1 auto"
+ justifyContent="space-between"
+ alignItems="center"
+ >
+ <Flex>
+ <Flex
+ variant="columnCenter"
+ bg="primary"
+ mr={2}
+ size={35}
+ sx={{
+ borderRadius: 80,
+ }}
+ >
+ <Icon.User size={20} color="static" />
+ </Flex>
+ <Flex variant="columnCenter" alignItems="flex-start">
+ <Text variant="subBody">You are not logged in</Text>
+ <Text variant="body" color="primary" fontSize={"body"}>
+ Login to sync your notes
+ </Text>
+ </Flex>
</Flex>
+ <Icon.ChevronRight size={20} color="primary" />
</Flex>
- <Icon.ChevronRight size={20} color="primary" />
</Flex>
- </Flex>
- )}
- {isLoggedIn && (
- <>
- <Button variant="list" onClick={showRecoveryKeyDialog}>
- <TextWithTip
- text="Backup data recovery key"
- tip="In case you lose your password, you can recover your data using your recovery key."
- />
- </Button>
- <Button
- variant="list"
- onClick={async () => {
- if (await showLogoutConfirmation()) await logout();
- }}
- >
- <TextWithTip
- text="Logout"
- tip="Log out of your account and clear all data."
- />
- </Button>
- </>
- )}
- <Text
- variant="subtitle"
- color="primary"
- py={1}
- sx={{ borderBottom: "1px solid", borderBottomColor: "border" }}
- >
- Appearance
- </Text>
- <TextWithTip
- text="Accent color"
- tip="Choose a color to use as accent color"
- sx={{ py: 2 }}
- />
- <Flex
- flexWrap="wrap"
- justifyContent="left"
- sx={{
- borderRadius: "default",
- }}
- >
- {accents.map((color) => (
- <AccentItem key={color.code} code={color.code} label={color.label} />
- ))}
- </Flex>
- <ToggleItem
- title="Dark mode"
- onTip="Dark mode is on"
- offTip="Dark mode is off"
- onToggled={toggleNightMode}
- isToggled={theme === "dark"}
- onlyIf={!followSystemTheme}
- />
- <ToggleItem
- title="Follow system theme"
- onTip="Switch app theme according to system"
- offTip="Keep app theme independent"
- onToggled={toggleFollowSystemTheme}
- isToggled={followSystemTheme}
- />
-
- <Text
- variant="subtitle"
- color="primary"
- sx={{ py: 1, borderBottom: "1px solid", borderBottomColor: "border" }}
- >
- {"Backup & Restore"}
- </Text>
- <Button
- variant="list"
- onClick={async () => {
- download(
- `notesnook-backup-${new Date().toLocaleString("en")}`,
- await db.backup.export("web", encryptBackups),
- "nnbackup"
- );
- }}
- >
+ )}
+ {isLoggedIn && (
+ <>
+ <Button variant="list" onClick={showRecoveryKeyDialog}>
+ <TextWithTip
+ text="Backup data recovery key"
+ tip="In case you lose your password, you can recover your data using your recovery key."
+ />
+ </Button>
+ <Button
+ variant="list"
+ onClick={async () => {
+ if (await showLogoutConfirmation()) await logout();
+ }}
+ >
+ <TextWithTip
+ text="Logout"
+ tip="Log out of your account and clear all data."
+ />
+ </Button>
+ </>
+ )}
+ <Text
+ variant="subtitle"
+ color="primary"
+ py={1}
+ sx={{ borderBottom: "1px solid", borderBottomColor: "border" }}
+ >
+ Appearance
+ </Text>
<TextWithTip
- text="Backup data"
- tip="Backup and download all your data"
+ text="Accent color"
+ tip="Choose a color to use as accent color"
+ sx={{ py: 2 }}
/>
- </Button>
- <input
- type="file"
- id="restore-backup"
- hidden
- accept=".nnbackup,text/plain,application/json"
- />
- <Button
- variant="list"
- onClick={async () => {
- await db.backup.import(JSON.stringify(await importBackup()));
- }}
- >
- <TextWithTip
- text="Restore backup"
- tip="Restore data from a backup file"
+ <Flex
+ flexWrap="wrap"
+ justifyContent="left"
+ sx={{
+ borderRadius: "default",
+ }}
+ >
+ {accents.map((color) => (
+ <AccentItem
+ key={color.code}
+ code={color.code}
+ label={color.label}
+ />
+ ))}
+ </Flex>
+ <ToggleItem
+ title="Dark mode"
+ onTip="Dark mode is on"
+ offTip="Dark mode is off"
+ onToggled={toggleNightMode}
+ isToggled={theme === "dark"}
+ onlyIf={!followSystemTheme}
+ />
+ <ToggleItem
+ title="Follow system theme"
+ onTip="Switch app theme according to system"
+ offTip="Keep app theme independent"
+ onToggled={toggleFollowSystemTheme}
+ isToggled={followSystemTheme}
/>
- </Button>
-
- <ToggleItem
- title="Encrypt backups"
- onTip="All backups will be encrypted"
- offTip="Backups will not be encrypted"
- onToggled={toggleEncryptBackups}
- isToggled={encryptBackups}
- />
-
- <OptionsItem
- title="Backup reminders"
- tip="Remind me to backup my data"
- options={["Never", "Daily", "Weekly", "Monthly"]}
- selectedOption={backupReminderOffset}
- onSelectionChanged={(_option, index) => setBackupReminderOffset(index)}
- />
-
- <Text
- variant="subtitle"
- color="primary"
- sx={{ py: 1, borderBottom: "1px solid", borderBottomColor: "border" }}
- >
- Vault
- </Text>
- {isVaultCreated ? (
- <>
- <Button variant="list" onClick={Vault.changeVaultPassword}>
- <TextWithTip text="Change vault password" />
- </Button>
- </>
- ) : (
+ <Text
+ variant="subtitle"
+ color="primary"
+ sx={{ py: 1, borderBottom: "1px solid", borderBottomColor: "border" }}
+ >
+ {"Backup & Restore"}
+ </Text>
<Button
variant="list"
onClick={async () => {
- setIsVaultCreated(await Vault.createVault());
+ download(
+ `notesnook-backup-${new Date().toLocaleString("en")}`,
+ await db.backup.export("web", encryptBackups),
+ "nnbackup"
+ );
}}
>
<TextWithTip
- text="Create vault"
- tip="Create a password-encrypted vault for your notes"
+ text="Backup data"
+ tip="Backup and download all your data"
/>
</Button>
- )}
-
- <Text
- variant="subtitle"
- color="primary"
- sx={{ py: 1, borderBottom: "1px solid", borderBottomColor: "border" }}
- >
- Other
- </Text>
- {["Terms of Service", "Privacy Policy", "About"].map((title) => (
+ <input
+ type="file"
+ id="restore-backup"
+ hidden
+ accept=".nnbackup,text/plain,application/json"
+ />
<Button
- key={title}
variant="list"
- onClick={() =>
- props.navigator.navigate("TOS", {
- title,
- })
- }
+ onClick={async () => {
+ await db.backup.import(JSON.stringify(await importBackup()));
+ }}
>
- {title}
+ <TextWithTip
+ text="Restore backup"
+ tip="Restore data from a backup file"
+ />
</Button>
- ))}
- </Flex>
+
+ <ToggleItem
+ title="Encrypt backups"
+ onTip="All backups will be encrypted"
+ offTip="Backups will not be encrypted"
+ onToggled={toggleEncryptBackups}
+ isToggled={encryptBackups}
+ />
+
+ <OptionsItem
+ title="Backup reminders"
+ tip="Remind me to backup my data"
+ options={["Never", "Daily", "Weekly", "Monthly"]}
+ selectedOption={backupReminderOffset}
+ onSelectionChanged={(_option, index) =>
+ setBackupReminderOffset(index)
+ }
+ />
+
+ <Text
+ variant="subtitle"
+ color="primary"
+ sx={{ py: 1, borderBottom: "1px solid", borderBottomColor: "border" }}
+ >
+ Vault
+ </Text>
+
+ {isVaultCreated ? (
+ <>
+ <Button variant="list" onClick={Vault.changeVaultPassword}>
+ <TextWithTip text="Change vault password" />
+ </Button>
+ </>
+ ) : (
+ <Button
+ variant="list"
+ onClick={async () => {
+ setIsVaultCreated(await Vault.createVault());
+ }}
+ >
+ <TextWithTip
+ text="Create vault"
+ tip="Create a password-encrypted vault for your notes"
+ />
+ </Button>
+ )}
+
+ <Text
+ variant="subtitle"
+ color="primary"
+ sx={{ py: 1, borderBottom: "1px solid", borderBottomColor: "border" }}
+ >
+ Other
+ </Text>
+ {["Terms of Service", "Privacy Policy", "About"].map((title) => (
+ <Button
+ key={title}
+ variant="list"
+ onClick={() =>
+ props.navigator.navigate("TOS", {
+ title,
+ })
+ }
+ >
+ {title}
+ </Button>
+ ))}
+ </Flex>
+ </ScrollContainer>
);
}
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index 7674c05d6..e0f08cf54 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -3613,6 +3613,11 @@ class-utils@^0.3.5:
isobject "^3.0.0"
static-extend "^0.1.1"
+classnames@^2.2.5:
+ version "2.2.6"
+ resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
+ integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
+
clean-css@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.3.tgz#507b5de7d97b48ee53d84adb0160ff6216380f78"
@@ -3694,6 +3699,11 @@ clone@^2.1.1:
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=
+cnbuilder@^2.5.0:
+ version "2.6.0"
+ resolved "https://registry.yarnpkg.com/cnbuilder/-/cnbuilder-2.6.0.tgz#309b4f34371be80ad5452f983b7bac1af4f09ac8"
+ integrity sha512-SA2gBDcU6B9T1uMhA3m13dVffdaA8RC9TIz7zQygYwbdwOf6l8IGem5UbDc661W2YcQ0aiwt6FqDhDpAE7YUqA==
+
co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
@@ -10464,7 +10474,7 @@ prompts@^2.0.1, prompts@^2.3.2:
kleur "^3.0.3"
sisteransi "^1.0.5"
-prop-types@^15.5.10, prop-types@^15.6.2, prop-types@^15.7.2:
+prop-types@^15.5.10, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -10744,6 +10754,14 @@ react-dom@^16.13.1, react-dom@^16.4.1:
prop-types "^15.6.2"
scheduler "^0.19.1"
+react-draggable@^4.4.2:
+ version "4.4.3"
+ resolved "https://registry.yarnpkg.com/react-draggable/-/react-draggable-4.4.3.tgz#0727f2cae5813e36b0e4962bf11b2f9ef2b406f3"
+ integrity sha512-jV4TE59MBuWm7gb6Ns3Q1mxX8Azffb7oTtDtBgFkxRvhDp38YAARmRplrj0+XGkhOJB5XziArX+4HUUABtyZ0w==
+ dependencies:
+ classnames "^2.2.5"
+ prop-types "^15.6.0"
+
react-error-overlay@^6.0.7:
version "6.0.8"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.8.tgz#474ed11d04fc6bda3af643447d85e9127ed6b5de"
@@ -10844,6 +10862,15 @@ [email protected]:
optionalDependencies:
fsevents "2.1.2"
+react-scrollbars-custom@^4.0.25:
+ version "4.0.25"
+ resolved "https://registry.yarnpkg.com/react-scrollbars-custom/-/react-scrollbars-custom-4.0.25.tgz#64c1390fc04fe2b90373d5d142bd129a3d46e394"
+ integrity sha512-kipJK49fwvHsDgumIGiTmrJkxw5QD9urN7f4o2VvSrsHNOWMrDppNf+IjgobT5w+ZjbaaHfLk5NmZ/n1zgKtcw==
+ dependencies:
+ cnbuilder "^2.5.0"
+ react-draggable "^4.4.2"
+ zoom-level "^2.5.0"
+
react-virtualized-auto-sizer@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.2.tgz#a61dd4f756458bbf63bd895a92379f9b70f803bd"
@@ -13461,6 +13488,11 @@ yauzl@^2.10.0:
buffer-crc32 "~0.2.3"
fd-slicer "~1.1.0"
+zoom-level@^2.5.0:
+ version "2.5.0"
+ resolved "https://registry.yarnpkg.com/zoom-level/-/zoom-level-2.5.0.tgz#286ec16f247b8bb7a900df6612567688eeef498a"
+ integrity sha512-7UlRWU4Q3uCMCeDVMOm7eBrIu145OqsIJ3p6zq58l8UsSYwKWxc6zEapC5YA9tIeh0oheb4cT9Kk2Wq353loFg==
+
zustand@^2.2.3:
version "2.2.4"
resolved "https://registry.yarnpkg.com/zustand/-/zustand-2.2.4.tgz#3b38f9192ae06e6a737ce2d78cbdc321b1c7f185"