From 6743b6a2a555d5c00832ce65a27cf5931b085008 Mon Sep 17 00:00:00 2001 From: Akmal Isomadinov Date: Wed, 25 Oct 2023 18:01:39 +0500 Subject: [PATCH] Web:Client:Article: Fixed catalog icons --- .../components/Article/Body/AccountsItem.js | 8 +- .../components/Article/Body/Items.helper.ts | 74 +++++++++++++++++++ .../src/components/Article/Body/Items.js | 63 +++------------- packages/common/constants/index.js | 1 + .../icons/20/catalog.accounts.react.svg | 3 + .../images/icons/20/catalog.archive.react.svg | 3 + .../icons/20/catalog.favorites.react.svg | 3 + .../images/icons/20/catalog.folder.react.svg | 3 + .../icons/20/catalog.portfolio.react.svg | 3 + .../images/icons/20/catalog.private.react.svg | 10 +++ .../images/icons/20/catalog.recent.react.svg | 10 +++ .../images/icons/20/catalog.rooms.react.svg | 3 + .../images/icons/20/catalog.shared.react.svg | 3 + .../images/icons/20/catalog.trash.react.svg | 3 + public/images/icons/20/catalog.user.react.svg | 10 +++ 15 files changed, 146 insertions(+), 54 deletions(-) create mode 100644 packages/client/src/components/Article/Body/Items.helper.ts create mode 100644 public/images/icons/20/catalog.accounts.react.svg create mode 100644 public/images/icons/20/catalog.archive.react.svg create mode 100644 public/images/icons/20/catalog.favorites.react.svg create mode 100644 public/images/icons/20/catalog.folder.react.svg create mode 100644 public/images/icons/20/catalog.portfolio.react.svg create mode 100644 public/images/icons/20/catalog.private.react.svg create mode 100644 public/images/icons/20/catalog.recent.react.svg create mode 100644 public/images/icons/20/catalog.rooms.react.svg create mode 100644 public/images/icons/20/catalog.shared.react.svg create mode 100644 public/images/icons/20/catalog.trash.react.svg create mode 100644 public/images/icons/20/catalog.user.react.svg diff --git a/packages/client/src/components/Article/Body/AccountsItem.js b/packages/client/src/components/Article/Body/AccountsItem.js index cd11b04202..334884a7f7 100644 --- a/packages/client/src/components/Article/Body/AccountsItem.js +++ b/packages/client/src/components/Article/Body/AccountsItem.js @@ -2,20 +2,24 @@ import { inject, observer } from "mobx-react"; import { withTranslation } from "react-i18next"; +import { FolderType } from "@docspace/common/constants"; + import CatalogItem from "@docspace/components/catalog-item"; -import CatalogAccountsReactSvgUrl from "PUBLIC_DIR/images/catalog.accounts.react.svg?url"; +import { getCatalogIconByFolderType } from "./Items.helper"; const PureAccountsItem = ({ showText, isActive, onClick, t }) => { const onClickAction = React.useCallback(() => { onClick && onClick("accounts"); }, [onClick]); + const icon = getCatalogIconByFolderType(FolderType.Account); + return ( = { + 16: CatalogFolderReactSvgUrl, + 20: CatalogFolder20ReactSvgUrl, +}; + +const icons: Record>> = { + 16: { + [FolderType.USER]: CatalogUserReactSvgUrl, + [FolderType.Rooms]: CatalogRoomsReactSvgUrl, + [FolderType.Archive]: CatalogArchiveReactSvgUrl, + [FolderType.SHARE]: CatalogSharedReactSvgUrl, + [FolderType.COMMON]: CatalogPortfolioReactSvgUrl, + [FolderType.Favorites]: CatalogFavoritesReactSvgUrl, + [FolderType.Recent]: CatalogRecentReactSvgUrl, + [FolderType.Privacy]: CatalogPrivateReactSvgUrl, + [FolderType.TRASH]: CatalogTrashReactSvgUrl, + [FolderType.Account]: CatalogAccountsReactSvgUrl, + }, + 20: { + [FolderType.USER]: CatalogUser20ReactSvgUrl, + [FolderType.Rooms]: CatalogRooms20ReactSvgUrl, + [FolderType.Archive]: CatalogArchive20ReactSvgUrl, + [FolderType.SHARE]: CatalogShared20ReactSvgUrl, + [FolderType.COMMON]: CatalogPortfolio20ReactSvgUrl, + [FolderType.Favorites]: CatalogFavorites20ReactSvgUrl, + [FolderType.Recent]: CatalogRecent20ReactSvgUrl, + [FolderType.Privacy]: CatalogPrivate20ReactSvgUrl, + [FolderType.TRASH]: CatalogTrash20ReactSvgUrl, + [FolderType.Account]: CatalogAccounts20ReactSvgUrl, + }, +}; + +const MobileIconSize = 20; +const DesktopIconSize = 16; + +export const getCatalogIconByFolderType = ( + folderType: FolderUnionType +): string => { + const size: SizeType = + isMobile() || isTablet() ? MobileIconSize : DesktopIconSize; + + return icons[size]?.[folderType] ?? defaultIcon[size]; +}; diff --git a/packages/client/src/components/Article/Body/Items.js b/packages/client/src/components/Article/Body/Items.js index 1ab3adc4e6..40c05f28bf 100644 --- a/packages/client/src/components/Article/Body/Items.js +++ b/packages/client/src/components/Article/Body/Items.js @@ -1,31 +1,24 @@ -import CatalogFolderReactSvgUrl from "PUBLIC_DIR/images/catalog.folder.react.svg?url"; -import ClearTrashReactSvgUrl from "PUBLIC_DIR/images/clear.trash.react.svg?url"; -import CatalogUserReactSvgUrl from "PUBLIC_DIR/images/catalog.user.react.svg?url"; -import CatalogRoomsReactSvgUrl from "PUBLIC_DIR/images/catalog.rooms.react.svg?url"; -import CatalogArchiveReactSvgUrl from "PUBLIC_DIR/images/catalog.archive.react.svg?url"; -import CatalogSharedReactSvgUrl from "PUBLIC_DIR/images/catalog.shared.react.svg?url"; -import CatalogPortfolioReactSvgUrl from "PUBLIC_DIR/images/catalog.portfolio.react.svg?url"; -import CatalogFavoritesReactSvgUrl from "PUBLIC_DIR/images/catalog.favorites.react.svg?url"; -import CatalogRecentReactSvgUrl from "PUBLIC_DIR/images/catalog.recent.react.svg?url"; -import CatalogPrivateReactSvgUrl from "PUBLIC_DIR/images/catalog.private.react.svg?url"; -import CatalogTrashReactSvgUrl from "PUBLIC_DIR/images/catalog.trash.react.svg?url"; -import React, { useState } from "react"; +import PropTypes from "prop-types"; import styled from "styled-components"; -import PropTypes from "prop-types"; +import React, { useState } from "react"; import { inject, observer } from "mobx-react"; -import CatalogItem from "@docspace/components/catalog-item"; +import { withTranslation } from "react-i18next"; + import { FolderType, ShareAccessRights, FolderNames, DeviceType, } from "@docspace/common/constants"; -import { withTranslation } from "react-i18next"; + +import CatalogItem from "@docspace/components/catalog-item"; import DragAndDrop from "@docspace/components/drag-and-drop"; -import SettingsItem from "./SettingsItem"; -import AccountsItem from "./AccountsItem"; import BonusItem from "./BonusItem"; +import AccountsItem from "./AccountsItem"; +import { getCatalogIconByFolderType } from "./Items.helper"; + +import ClearTrashReactSvgUrl from "PUBLIC_DIR/images/clear.trash.react.svg?url"; const StyledDragAndDrop = styled(DragAndDrop)` display: contents; @@ -204,41 +197,7 @@ const Items = ({ ); const getFolderIcon = React.useCallback((item) => { - let iconUrl = CatalogFolderReactSvgUrl; - - switch (item.rootFolderType) { - case FolderType.USER: - iconUrl = CatalogUserReactSvgUrl; - break; - case FolderType.Rooms: - iconUrl = CatalogRoomsReactSvgUrl; - break; - case FolderType.Archive: - iconUrl = CatalogArchiveReactSvgUrl; - break; - case FolderType.SHARE: - iconUrl = CatalogSharedReactSvgUrl; - break; - case FolderType.COMMON: - iconUrl = CatalogPortfolioReactSvgUrl; - break; - case FolderType.Favorites: - iconUrl = CatalogFavoritesReactSvgUrl; - break; - case FolderType.Recent: - iconUrl = CatalogRecentReactSvgUrl; - break; - case FolderType.Privacy: - iconUrl = CatalogPrivateReactSvgUrl; - break; - case FolderType.TRASH: - iconUrl = CatalogTrashReactSvgUrl; - break; - default: - break; - } - - return iconUrl; + return getCatalogIconByFolderType(item.rootFolderType); }, []); const showDragItems = React.useCallback( diff --git a/packages/common/constants/index.js b/packages/common/constants/index.js index 420d572e21..93c8c586de 100644 --- a/packages/common/constants/index.js +++ b/packages/common/constants/index.js @@ -215,6 +215,7 @@ export const FolderType = Object.freeze({ Privacy: 13, Rooms: 14, Archive: 20, + Account: 30, }); // extends FolderType keys diff --git a/public/images/icons/20/catalog.accounts.react.svg b/public/images/icons/20/catalog.accounts.react.svg new file mode 100644 index 0000000000..f4a12bd169 --- /dev/null +++ b/public/images/icons/20/catalog.accounts.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.archive.react.svg b/public/images/icons/20/catalog.archive.react.svg new file mode 100644 index 0000000000..07bfbe04e7 --- /dev/null +++ b/public/images/icons/20/catalog.archive.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.favorites.react.svg b/public/images/icons/20/catalog.favorites.react.svg new file mode 100644 index 0000000000..98c9a79e1c --- /dev/null +++ b/public/images/icons/20/catalog.favorites.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.folder.react.svg b/public/images/icons/20/catalog.folder.react.svg new file mode 100644 index 0000000000..f9492506d8 --- /dev/null +++ b/public/images/icons/20/catalog.folder.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.portfolio.react.svg b/public/images/icons/20/catalog.portfolio.react.svg new file mode 100644 index 0000000000..34836194dc --- /dev/null +++ b/public/images/icons/20/catalog.portfolio.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.private.react.svg b/public/images/icons/20/catalog.private.react.svg new file mode 100644 index 0000000000..2f43649691 --- /dev/null +++ b/public/images/icons/20/catalog.private.react.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/public/images/icons/20/catalog.recent.react.svg b/public/images/icons/20/catalog.recent.react.svg new file mode 100644 index 0000000000..f58d038a5f --- /dev/null +++ b/public/images/icons/20/catalog.recent.react.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/public/images/icons/20/catalog.rooms.react.svg b/public/images/icons/20/catalog.rooms.react.svg new file mode 100644 index 0000000000..f1e47a8b5a --- /dev/null +++ b/public/images/icons/20/catalog.rooms.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.shared.react.svg b/public/images/icons/20/catalog.shared.react.svg new file mode 100644 index 0000000000..18c896ad22 --- /dev/null +++ b/public/images/icons/20/catalog.shared.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.trash.react.svg b/public/images/icons/20/catalog.trash.react.svg new file mode 100644 index 0000000000..aced764b82 --- /dev/null +++ b/public/images/icons/20/catalog.trash.react.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icons/20/catalog.user.react.svg b/public/images/icons/20/catalog.user.react.svg new file mode 100644 index 0000000000..37fd747262 --- /dev/null +++ b/public/images/icons/20/catalog.user.react.svg @@ -0,0 +1,10 @@ + + + + + + + + + +