A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: use settings scroller for themes
Abdullah Atta5da30faf710a
diff --git a/apps/web/package-lock.json b/apps/web/package-lock.jsonindex 9b9e9d436..1bceacf23 100644--- a/apps/web/package-lock.json+++ b/apps/web/package-lock.json@@ -65,7 +65,7 @@"react-modal": "3.13.1","react-qrcode-logo": "^2.2.1","react-scroll-sync": "^0.9.0",- "react-virtuoso": "^3.0.0",+ "react-virtuoso": "^4.4.2","timeago.js": "4.0.2","tinycolor2": "^1.6.0","w3c-keyname": "^2.2.6",@@ -42376,23 +42376,6 @@"dev": true,"license": "MIT"},- "node_modules/@virtuoso.dev/react-urx": {- "version": "0.2.13",- "license": "MIT",- "dependencies": {- "@virtuoso.dev/urx": "^0.2.13"- },- "engines": {- "node": ">=10"- },- "peerDependencies": {- "react": ">=16"- }- },- "node_modules/@virtuoso.dev/urx": {- "version": "0.2.13",- "license": "MIT"- },"node_modules/@vitejs/plugin-react-swc": {"version": "3.3.2","dev": true,@@ -46164,12 +46147,9 @@}},"node_modules/react-virtuoso": {- "version": "3.1.5",- "license": "MIT",- "dependencies": {- "@virtuoso.dev/react-urx": "^0.2.12",- "@virtuoso.dev/urx": "^0.2.12"- },+ "version": "4.4.2",+ "resolved": "https://registry.npmjs.org/react-virtuoso/-/react-virtuoso-4.4.2.tgz",+ "integrity": "sha512-9uChSRSK5bTbKTxzuta4RqhfrlZSVHI/v8fHwmv3jmImS8FjdZ4Mzgqz9JKUp/yQo3dIHkR2QwidQeqxgYzPhQ==","engines": {"node": ">=10"},diff --git a/apps/web/package.json b/apps/web/package.jsonindex 1fe8a5242..1eb160ca4 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -64,7 +64,7 @@"react-modal": "3.13.1","react-qrcode-logo": "^2.2.1","react-scroll-sync": "^0.9.0",- "react-virtuoso": "^3.0.0",+ "react-virtuoso": "^4.4.2","timeago.js": "4.0.2","tinycolor2": "^1.6.0","w3c-keyname": "^2.2.6",diff --git a/apps/web/src/dialogs/settings/components/themes-selector.tsx b/apps/web/src/dialogs/settings/components/themes-selector.tsxindex 206f85219..64e8bf74a 100644--- a/apps/web/src/dialogs/settings/components/themes-selector.tsx+++ b/apps/web/src/dialogs/settings/components/themes-selector.tsx@@ -18,11 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/import { httpBatchLink } from "@trpc/client";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { useCallback, useState } from "react";+import { useCallback, useRef, useState } from "react";import { Box, Button, Flex, Input, Text } from "@theme-ui/components";import { CheckCircleOutline, Loading } from "../../../components/icons";import {THEME_COMPATIBILITY_VERSION,+ ThemeDefinition,getPreviewColors,validateTheme} from "@notesnook/theme";@@ -74,6 +75,7 @@ function ThemesList() {);const [isApplying, setIsApplying] = useState(false);+ const parentScrollRef = useRef<HTMLElement>();const setCurrentTheme = useThemeStore((store) => store.setTheme);const user = useUserStore((store) => store.user);const darkTheme = useThemeStore((store) => store.darkTheme);@@ -197,6 +199,11 @@ function ThemesList() {</Flex><Box+ ref={(ref) => {+ if (ref && ref instanceof HTMLElement)+ parentScrollRef.current =+ (ref.closest(".ms-container") as HTMLElement) || undefined;+ }}sx={{".virtuoso-grid-list": {display: "grid",@@ -210,35 +217,15 @@ function ThemesList() {<Loader title={"Loading themes..."} />) : (<VirtuosoGrid- style={{ height: 700 }}+ customScrollParent={parentScrollRef.current || undefined}data={themes.data?.pages.flatMap((a) => a.themes) || []}endReached={() =>themes.hasNextPage ? themes.fetchNextPage() : null}components={{- Header: () => (- <div className="virtuoso-grid-list">- <ThemeItem- theme={{- ...darkTheme,- previewColors: getPreviewColors(darkTheme)- }}- isApplied={true}- isApplying={isApplying}- setTheme={setTheme}- />- <ThemeItem- theme={{- ...lightTheme,- previewColors: getPreviewColors(lightTheme)- }}- isApplied={true}- isApplying={isApplying}- setTheme={setTheme}- />- </div>- )+ Header: GridHeader}}+ context={{ darkTheme, lightTheme, setTheme }}computeItemKey={(_index, item) => item.id}itemContent={(_index, theme) => (<ThemeItem@@ -256,6 +243,39 @@ function ThemesList() {);}+const GridHeader = (props: {+ context?: {+ darkTheme: ThemeDefinition;+ lightTheme: ThemeDefinition;+ setTheme: (theme: ThemeMetadata) => Promise<void>;+ };+}) => {+ const { darkTheme, lightTheme, setTheme } = props.context || {};+ if (!darkTheme || !lightTheme || !setTheme) return null;+ return (+ <div className="virtuoso-grid-list">+ <ThemeItem+ theme={{+ ...darkTheme,+ previewColors: getPreviewColors(darkTheme)+ }}+ isApplied={true}+ isApplying={false}+ setTheme={setTheme}+ />+ <ThemeItem+ theme={{+ ...lightTheme,+ previewColors: getPreviewColors(lightTheme)+ }}+ isApplied={true}+ isApplying={false}+ setTheme={setTheme}+ />+ </div>+ );+};+type ThemeItemProps = {theme: ThemeMetadata;isApplied: boolean;