Skip to content

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

fix: use custom scrollbar for properties

thecodrr194b2758342f
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index e3879f4d2..817274a1e 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -54,6 +54,7 @@ function App() {
variant="rowFill"
overflowX={["auto", "hidden"]}
sx={{
+ overflowY: "hidden",
scrollSnapType: "x mandatory",
scrollBehavior: "smooth",
WebkitOverflowScrolling: "touch",
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 25cb607ce..6e7c56aa5 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -6,18 +6,11 @@ import { Virtuoso } from "react-virtuoso";
import { useStore as useSelectionStore } from "../../stores/selection-store";
import GroupHeader from "../group-header";
import ListProfiles from "../../common/list-profiles";
-import ScrollContainer from "../scroll-container";
+import { CustomScrollbarsVirtualList } from "../scroll-container";
import ReminderBar from "../reminder-bar";
import Announcements from "../announcements";
import useAnnouncements from "../../utils/use-announcements";
-const CustomScrollbarsVirtualList = React.forwardRef((props, ref) => (
- <ScrollContainer
- {...props}
- forwardedRef={(scrollbarsRef) => (ref.current = scrollbarsRef)}
- />
-));
-
function ListContainer(props) {
const { type, groupType, items, context, refresh } = props;
const [announcements, removeAnnouncement] = useAnnouncements();
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index f6ee483b8..c902ee771 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -11,6 +11,7 @@ import { navigate } from "../../navigation";
import IconTag from "../icon-tag";
import FS from "../../interfaces/fs";
import { formatBytes, truncateFilename } from "../../utils/filename";
+import ScrollContainer from "../scroll-container";
const tools = [
{ key: "pinned", icon: Icon.Pin, label: "Pin" },
@@ -97,237 +98,239 @@ function Properties({ noteId }) {
width: "300px",
borderLeft: "1px solid",
borderLeftColor: "border",
- overflowY: "auto",
+ overflowY: "hidden",
overflowX: "hidden",
}}
flexDirection="column"
bg="background"
// px={2}
>
- <Card
- title="Properties"
- button={
- <Icon.ArrowLeft
- data-test-id="properties-close"
- onClick={() => toggleProperties(false)}
- size={18}
- sx={{ mr: 1 }}
- />
- }
- >
- {tools.map((tool, _) => (
- <Toggle
- {...tool}
- key={tool.key}
- toggleKey={tool.key}
- onToggle={(state) => changeState(tool.key, state)}
- testId={`properties-${tool.key}`}
- />
- ))}
- <Flex
- py={2}
- px={2}
- sx={{
- cursor: "pointer",
- }}
- justifyContent="center"
+ <ScrollContainer>
+ <Card
+ title="Properties"
+ button={
+ <Icon.ArrowLeft
+ data-test-id="properties-close"
+ onClick={() => toggleProperties(false)}
+ size={18}
+ sx={{ mr: 1 }}
+ />
+ }
>
- {COLORS.map((label) => (
- <Flex
- key={label}
- justifyContent="space-between"
- alignItems="center"
- onClick={() => setColor(label)}
- sx={{
- cursor: "pointer",
- position: "relative",
- }}
- data-test-id={`properties-${label}`}
- >
- <Icon.Circle size={35} color={label.toLowerCase()} />
- {label.toLowerCase() === color?.toLowerCase() && (
- <Icon.Checkmark
- color="static"
- size={18}
- sx={{ position: "absolute", left: "8px" }}
- data-test-id={`properties-${label}-check`}
- />
- )}
- </Flex>
+ {tools.map((tool, _) => (
+ <Toggle
+ {...tool}
+ key={tool.key}
+ toggleKey={tool.key}
+ onToggle={(state) => changeState(tool.key, state)}
+ testId={`properties-${tool.key}`}
+ />
))}
- </Flex>
- </Card>
- {notebooks?.length && (
- <Card title="Referenced In">
- {notebooks.map((ref) => {
- const notebook = db.notebooks.notebook(ref.id);
- if (!notebook) return null;
- const topics = ref.topics.reduce((topics, topicId) => {
- const topic = notebook.topics.topic(topicId);
- if (!!topic && !!topic._topic) topics.push(topic._topic);
- return topics;
- }, []);
-
- return (
+ <Flex
+ py={2}
+ px={2}
+ sx={{
+ cursor: "pointer",
+ }}
+ justifyContent="center"
+ >
+ {COLORS.map((label) => (
<Flex
- key={notebook.id}
- py={2}
- px={2}
+ key={label}
+ justifyContent="space-between"
+ alignItems="center"
+ onClick={() => setColor(label)}
sx={{
- borderBottom: "1px solid var(--border)",
- ":last-of-type": { borderBottom: "none" },
cursor: "pointer",
- ":hover": {
- bg: "hover",
- },
- }}
- flexDirection="column"
- onClick={() => {
- navigate(`/notebooks/${notebook.data.id}`);
+ position: "relative",
}}
+ data-test-id={`properties-${label}`}
>
- <Text variant="body" display="flex" alignItems="center">
- <Icon.Notebook size={13} sx={{ flexShrink: 0, mr: 1 }} />
- {notebook.title}
- </Text>
+ <Icon.Circle size={35} color={label.toLowerCase()} />
+ {label.toLowerCase() === color?.toLowerCase() && (
+ <Icon.Checkmark
+ color="static"
+ size={18}
+ sx={{ position: "absolute", left: "8px" }}
+ data-test-id={`properties-${label}-check`}
+ />
+ )}
+ </Flex>
+ ))}
+ </Flex>
+ </Card>
+ {notebooks?.length && (
+ <Card title="Referenced In">
+ {notebooks.map((ref) => {
+ const notebook = db.notebooks.notebook(ref.id);
+ if (!notebook) return null;
+ const topics = ref.topics.reduce((topics, topicId) => {
+ const topic = notebook.topics.topic(topicId);
+ if (!!topic && !!topic._topic) topics.push(topic._topic);
+ return topics;
+ }, []);
+ return (
<Flex
+ key={notebook.id}
+ py={2}
+ px={2}
sx={{
- flexWrap: "wrap",
+ borderBottom: "1px solid var(--border)",
+ ":last-of-type": { borderBottom: "none" },
+ cursor: "pointer",
+ ":hover": {
+ bg: "hover",
+ },
+ }}
+ flexDirection="column"
+ onClick={() => {
+ navigate(`/notebooks/${notebook.data.id}`);
}}
- mt="2.5px"
>
- {topics.map((topic) => (
- <IconTag
- title={topic.title}
- text={topic.title}
- key={topic.id}
- icon={Icon.Topic}
- onClick={(e) => {
- e.stopPropagation();
- navigate(
- `/notebooks/${notebook.data.id}/${topic.id}`
- );
- }}
- />
- ))}
- </Flex>
- </Flex>
- );
- })}
- </Card>
- )}
- {attachments.length > 0 && (
- <Card title="Attachments">
- {attachments.map((attachment) => {
- const attachmentStatus =
- attachmentsStatus[attachment.metadata.hash];
- return (
- <Flex
- key={attachment.id}
- py={1}
- px={2}
- sx={{
- borderBottom: "1px solid var(--border)",
- ":last-of-type": { borderBottom: "none" },
- ":hover .attachment-download-btn": {
- opacity: 1,
- },
- }}
- title={attachment.metadata.filename}
- alignItems="center"
- justifyContent="space-between"
- >
- <Flex flexDirection="column" flex={1}>
- <Text
- variant="body"
- fontSize="subtitle"
+ <Text variant="body" display="flex" alignItems="center">
+ <Icon.Notebook size={13} sx={{ flexShrink: 0, mr: 1 }} />
+ {notebook.title}
+ </Text>
+
+ <Flex
sx={{
- whiteSpace: "nowrap",
- textOverflow: "ellipsis",
- overflow: "hidden",
+ flexWrap: "wrap",
}}
+ mt="2.5px"
>
- {truncateFilename(attachment.metadata.filename)}
- </Text>
- {attachmentStatus && (
- <Box
+ {topics.map((topic) => (
+ <IconTag
+ title={topic.title}
+ text={topic.title}
+ key={topic.id}
+ icon={Icon.Topic}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate(
+ `/notebooks/${notebook.data.id}/${topic.id}`
+ );
+ }}
+ />
+ ))}
+ </Flex>
+ </Flex>
+ );
+ })}
+ </Card>
+ )}
+ {attachments.length > 0 && (
+ <Card title="Attachments">
+ {attachments.map((attachment) => {
+ const attachmentStatus =
+ attachmentsStatus[attachment.metadata.hash];
+ return (
+ <Flex
+ key={attachment.id}
+ py={1}
+ px={2}
+ sx={{
+ borderBottom: "1px solid var(--border)",
+ ":last-of-type": { borderBottom: "none" },
+ ":hover .attachment-download-btn": {
+ opacity: 1,
+ },
+ }}
+ title={attachment.metadata.filename}
+ alignItems="center"
+ justifyContent="space-between"
+ >
+ <Flex flexDirection="column" flex={1}>
+ <Text
+ variant="body"
+ fontSize="subtitle"
sx={{
- my: 1,
- bg: "primary",
- height: "2px",
- width: `${attachmentStatus.progress}%`,
+ whiteSpace: "nowrap",
+ textOverflow: "ellipsis",
+ overflow: "hidden",
}}
- />
- )}
- <Flex mt={1}>
- {attachmentStatus ? (
- <Text variant="subBody">
- {formatBytes(attachmentStatus.loaded, 1)} of{" "}
- {formatBytes(attachment.length, 1)} (
- {attachmentStatus.type}ing)
- </Text>
- ) : (
- <Text variant="subBody">
- {formatBytes(attachment.length, 1)}
- </Text>
+ >
+ {truncateFilename(attachment.metadata.filename)}
+ </Text>
+ {attachmentStatus && (
+ <Box
+ sx={{
+ my: 1,
+ bg: "primary",
+ height: "2px",
+ width: `${attachmentStatus.progress}%`,
+ }}
+ />
)}
+ <Flex mt={1}>
+ {attachmentStatus ? (
+ <Text variant="subBody">
+ {formatBytes(attachmentStatus.loaded, 1)} of{" "}
+ {formatBytes(attachment.length, 1)} (
+ {attachmentStatus.type}ing)
+ </Text>
+ ) : (
+ <Text variant="subBody">
+ {formatBytes(attachment.length, 1)}
+ </Text>
+ )}
+ </Flex>
</Flex>
- </Flex>
- <Box>
- {attachmentStatus ? (
- <Button
- title="Cancel download"
- variant="tool"
- p={1}
- m={1}
- sx={{ ":hover": { bg: "hover" } }}
- onClick={async () => {
- await db.fs.cancel(
- attachment.metadata.hash,
- "download"
- );
- }}
- >
- <Icon.Close size={16} />
- </Button>
- ) : (
- <Button
- className="attachment-download-btn"
- title="Download attachment"
- variant="tool"
- p={1}
- m={1}
- sx={{ ":hover": { bg: "hover" }, opacity: 0 }}
- onClick={async () => {
- if (
- await db.fs.downloadFile(
+ <Box>
+ {attachmentStatus ? (
+ <Button
+ title="Cancel download"
+ variant="tool"
+ p={1}
+ m={1}
+ sx={{ ":hover": { bg: "hover" } }}
+ onClick={async () => {
+ await db.fs.cancel(
attachment.metadata.hash,
- attachment.metadata.hash
- )
- ) {
- const key = await db.attachments.decryptKey(
- attachment.key
+ "download"
);
- await FS.saveFile(attachment.metadata.hash, {
- key,
- iv: attachment.iv,
- name: attachment.metadata.filename,
- type: attachment.metadata.type,
- });
- }
- }}
- >
- <Icon.Download size={16} />
- </Button>
- )}
- </Box>
- </Flex>
- );
- })}
- </Card>
- )}
+ }}
+ >
+ <Icon.Close size={16} />
+ </Button>
+ ) : (
+ <Button
+ className="attachment-download-btn"
+ title="Download attachment"
+ variant="tool"
+ p={1}
+ m={1}
+ sx={{ ":hover": { bg: "hover" }, opacity: 0 }}
+ onClick={async () => {
+ if (
+ await db.fs.downloadFile(
+ attachment.metadata.hash,
+ attachment.metadata.hash
+ )
+ ) {
+ const key = await db.attachments.decryptKey(
+ attachment.key
+ );
+ await FS.saveFile(attachment.metadata.hash, {
+ key,
+ iv: attachment.iv,
+ name: attachment.metadata.filename,
+ type: attachment.metadata.type,
+ });
+ }
+ }}
+ >
+ <Icon.Download size={16} />
+ </Button>
+ )}
+ </Box>
+ </Flex>
+ );
+ })}
+ </Card>
+ )}
+ </ScrollContainer>
</AnimatedFlex>
</>
);
diff --git a/apps/web/src/components/scroll-container/index.js b/apps/web/src/components/scroll-container/index.js
index 04510caa1..eaf148170 100644
--- a/apps/web/src/components/scroll-container/index.js
+++ b/apps/web/src/components/scroll-container/index.js
@@ -1,3 +1,4 @@
+import React from "react";
import RSC from "react-scrollbars-custom";
import { Text } from "rebass";
import "./style.css";
@@ -68,3 +69,10 @@ const ScrollContainer = ({
);
};
export default ScrollContainer;
+
+export const CustomScrollbarsVirtualList = React.forwardRef((props, ref) => (
+ <ScrollContainer
+ {...props}
+ forwardedRef={(scrollbarsRef) => (ref.current = scrollbarsRef)}
+ />
+));
diff --git a/apps/web/src/components/scroll-container/style.css b/apps/web/src/components/scroll-container/style.css
index 0df4391b5..92344fdca 100644
--- a/apps/web/src/components/scroll-container/style.css
+++ b/apps/web/src/components/scroll-container/style.css
@@ -14,5 +14,5 @@
}
.ScrollbarsCustom-Thumb.ScrollbarsCustom-ThumbY {
- background-color: var(--bgSecondary) !important;
+ background-color: var(--bgSecondaryText) !important;
}