From c38c15f63fd2b2aa637e823c36d0247b931a4a98 Mon Sep 17 00:00:00 2001 From: subnub Date: Sat, 12 Oct 2024 12:53:19 -0400 Subject: [PATCH] renamed some files --- ...Account.tsx => SettingsAccountSection.tsx} | 4 +- ...General.tsx => SettingsGeneralSection.tsx} | 62 ++++++++++++++++++- src/components/SettingsPage/SettingsPage.tsx | 47 +++++++++++--- 3 files changed, 100 insertions(+), 13 deletions(-) rename src/components/SettingsPage/{SettingsPageAccount.tsx => SettingsAccountSection.tsx} (94%) rename src/components/SettingsPage/{SettingsPageGeneral.tsx => SettingsGeneralSection.tsx} (59%) diff --git a/src/components/SettingsPage/SettingsPageAccount.tsx b/src/components/SettingsPage/SettingsAccountSection.tsx similarity index 94% rename from src/components/SettingsPage/SettingsPageAccount.tsx rename to src/components/SettingsPage/SettingsAccountSection.tsx index 6efb06e..4b05aa6 100644 --- a/src/components/SettingsPage/SettingsPageAccount.tsx +++ b/src/components/SettingsPage/SettingsAccountSection.tsx @@ -10,7 +10,7 @@ interface SettingsPageAccountProps { const SettingsPageAccount: React.FC = ({ user }) => { return (
-
+

Account

@@ -31,7 +31,7 @@ const SettingsPageAccount: React.FC = ({ user }) => {

-

Logout all account

+

Logout all accounts

Logout all

diff --git a/src/components/SettingsPage/SettingsPageGeneral.tsx b/src/components/SettingsPage/SettingsGeneralSection.tsx similarity index 59% rename from src/components/SettingsPage/SettingsPageGeneral.tsx rename to src/components/SettingsPage/SettingsGeneralSection.tsx index 91ae8d0..f22a44b 100644 --- a/src/components/SettingsPage/SettingsPageGeneral.tsx +++ b/src/components/SettingsPage/SettingsGeneralSection.tsx @@ -4,6 +4,8 @@ const SettingsPageGeneral = () => { const [listViewStyle, setListViewStyle] = useState("list"); const [sortBy, setSortBy] = useState("date"); const [orderBy, setOrderBy] = useState("descending"); + const [doubleClickFolders, setDoubleClickFolders] = useState("disabled"); + const [loadThumbnails, setLoadThumbnails] = useState("enabled"); const fileListStyleChange = (e: React.ChangeEvent) => { const value = e.target.value; @@ -36,6 +38,30 @@ const SettingsPageGeneral = () => { } }; + const doubleClickFoldersChange = ( + e: React.ChangeEvent + ) => { + const value = e.target.value; + setDoubleClickFolders(value); + + if (value === "enabled") { + window.localStorage.setItem("double-click-folders", "true"); + } else { + window.localStorage.removeItem("double-click-folders"); + } + }; + + const loadThumbnailsChange = (e: React.ChangeEvent) => { + const value = e.target.value; + setLoadThumbnails(value); + + if (value === "disabled") { + window.localStorage.setItem("not-load-thumbnails", "true"); + } else { + window.localStorage.removeItem("not-load-thumbnails"); + } + }; + useEffect(() => { const gridModeLocalStorage = window.localStorage.getItem("grid-mode"); const gridModeEnabled = gridModeLocalStorage === "true"; @@ -46,14 +72,26 @@ const SettingsPageGeneral = () => { const orderByLocalStorage = window.localStorage.getItem("order-asc"); const orderByAscendingEnabled = orderByLocalStorage === "true"; + const doubleClickFoldersLocalStorage = window.localStorage.getItem( + "double-click-folders" + ); + const doubleClickFoldersEnabled = doubleClickFoldersLocalStorage === "true"; + + const loadThumbnailsLocalStorage = window.localStorage.getItem( + "not-load-thumbnails" + ); + const loadThumbnailsDisabled = loadThumbnailsLocalStorage === "true"; + setListViewStyle(gridModeEnabled ? "grid" : "list"); setSortBy(sortByNameEnabled ? "name" : "date"); setOrderBy(orderByAscendingEnabled ? "ascending" : "descending"); + setDoubleClickFolders(doubleClickFoldersEnabled ? "enabled" : "disabled"); + setLoadThumbnails(loadThumbnailsDisabled ? "disabled" : "enabled"); }, []); return (
-
+

General settings

@@ -90,6 +128,28 @@ const SettingsPageGeneral = () => {
+
+

Double click to enter folders

+ +
+
+

Load thumbnails

+ +
); diff --git a/src/components/SettingsPage/SettingsPage.tsx b/src/components/SettingsPage/SettingsPage.tsx index 8585b6c..4c16c2d 100644 --- a/src/components/SettingsPage/SettingsPage.tsx +++ b/src/components/SettingsPage/SettingsPage.tsx @@ -5,15 +5,18 @@ import classNames from "classnames"; import AccountIcon from "../../icons/AccountIcon"; import TuneIcon from "../../icons/TuneIcon"; import { useNavigate } from "react-router-dom"; -import SettingsPageAccount from "./SettingsPageAccount"; +import SettingsAccountSection from "./SettingsAccountSection"; import { getUserDetailedAPI } from "../../api/user"; import Spinner from "../Spinner/Spinner"; import Swal from "sweetalert2"; -import SettingsPageGeneral from "./SettingsPageGeneral"; +import SettingsGeneralSection from "./SettingsGeneralSection"; +import { useClickOutOfBounds } from "../../hooks/utils"; +import MenuIcon from "../../icons/MenuIcon"; const SettingsPage = () => { const [user, setUser] = useState(null); const [tab, setTab] = useState("account"); + const [showSidebarMobile, setShowSidebarMobile] = useState(false); const navigate = useNavigate(); const goHome = () => { @@ -46,6 +49,13 @@ const SettingsPage = () => { getUser(); }, []); + const { wrapperRef } = useClickOutOfBounds(() => setShowSidebarMobile(false)); + + const changeTab = (tab: string) => { + setTab(tab); + setShowSidebarMobile(false); + }; + if (!user) { return (