From 279c8072edfc01adee7eb8c038536e24ef6cfa20 Mon Sep 17 00:00:00 2001 From: ryanml Date: Fri, 26 Nov 2021 11:59:46 -0700 Subject: [PATCH] Adding collectibles items overview (#12506) * Adding collectibles items overview * addressing feedback Co-authored-by: Alex --- app/_locales/en/messages.json | 3 + .../collectibles-items.component.js | 148 ++++++++++++++++++ ui/components/app/collectibles-items/index.js | 1 + ui/components/app/collectibles-list/index.js | 1 - .../collectibles-tab.component.js} | 16 +- ui/components/app/collectibles-tab/index.js | 1 + ui/pages/home/home.component.js | 4 +- 7 files changed, 166 insertions(+), 8 deletions(-) create mode 100644 ui/components/app/collectibles-items/collectibles-items.component.js create mode 100644 ui/components/app/collectibles-items/index.js delete mode 100644 ui/components/app/collectibles-list/index.js rename ui/components/app/{collectibles-list/collectibles-list.component.js => collectibles-tab/collectibles-tab.component.js} (85%) create mode 100644 ui/components/app/collectibles-tab/index.js diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4838bc54f..e4133cd8a 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -139,6 +139,9 @@ "addNFT": { "message": "Add NFT" }, + "addNFTLowerCase": { + "message": "add NFT" + }, "addNetwork": { "message": "Add Network" }, diff --git a/ui/components/app/collectibles-items/collectibles-items.component.js b/ui/components/app/collectibles-items/collectibles-items.component.js new file mode 100644 index 000000000..887653658 --- /dev/null +++ b/ui/components/app/collectibles-items/collectibles-items.component.js @@ -0,0 +1,148 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import Box from '../../ui/box'; +import Button from '../../ui/button'; +import Typography from '../../ui/typography/typography'; +import { + COLORS, + TYPOGRAPHY, + TEXT_ALIGN, + JUSTIFY_CONTENT, + FLEX_DIRECTION, + ALIGN_ITEMS, + DISPLAY, + BLOCK_SIZES, + SIZES, + FLEX_WRAP, +} from '../../../helpers/constants/design-system'; +import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; +import { useI18nContext } from '../../../hooks/useI18nContext'; +import { getEnvironmentType } from '../../../../app/scripts/lib/util'; + +export default function CollectiblesItems({ onAddNFT, onRefreshList }) { + const t = useI18nContext(); + const collections = {}; + const defaultDropdownState = {}; + + Object.keys(collections).forEach((key) => { + defaultDropdownState[key] = true; + }); + + const [dropdownState, setDropdownState] = useState(defaultDropdownState); + const width = + getEnvironmentType() === ENVIRONMENT_TYPE_POPUP + ? BLOCK_SIZES.ONE_THIRD + : BLOCK_SIZES.ONE_SIXTH; + return ( +
+ + <> + {Object.keys(collections).map((key, index) => { + const { icon, collectibles } = collections[key]; + const isExpanded = dropdownState[key]; + + return ( +
+ + + + + {`${key} (${collectibles.length})`} + + + + { + setDropdownState((_dropdownState) => ({ + ..._dropdownState, + [key]: !isExpanded, + })); + }} + /> + + + {isExpanded ? ( + + {collectibles.map((collectible, i) => { + return ( + + + + + + ); + })} + + ) : null} +
+ ); + })} + + + {t('missingNFT')} + + + + + + + {t('or')} + + + + + + + +
+
+ ); +} + +CollectiblesItems.propTypes = { + onAddNFT: PropTypes.func.isRequired, + onRefreshList: PropTypes.func.isRequired, +}; diff --git a/ui/components/app/collectibles-items/index.js b/ui/components/app/collectibles-items/index.js new file mode 100644 index 000000000..b8b286c20 --- /dev/null +++ b/ui/components/app/collectibles-items/index.js @@ -0,0 +1 @@ +export { default } from './collectibles-items.component'; diff --git a/ui/components/app/collectibles-list/index.js b/ui/components/app/collectibles-list/index.js deleted file mode 100644 index ab3fb9b56..000000000 --- a/ui/components/app/collectibles-list/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './collectibles-list.component'; diff --git a/ui/components/app/collectibles-list/collectibles-list.component.js b/ui/components/app/collectibles-tab/collectibles-tab.component.js similarity index 85% rename from ui/components/app/collectibles-list/collectibles-list.component.js rename to ui/components/app/collectibles-tab/collectibles-tab.component.js index 9620caa42..42c85d17a 100644 --- a/ui/components/app/collectibles-list/collectibles-list.component.js +++ b/ui/components/app/collectibles-tab/collectibles-tab.component.js @@ -4,6 +4,7 @@ import Box from '../../ui/box'; import Button from '../../ui/button'; import Typography from '../../ui/typography/typography'; import NewCollectiblesNotice from '../new-collectibles-notice'; +import CollectiblesItems from '../collectibles-items'; import { COLORS, TYPOGRAPHY, @@ -14,15 +15,20 @@ import { } from '../../../helpers/constants/design-system'; import { useI18nContext } from '../../../hooks/useI18nContext'; -export default function CollectiblesList({ onAddNFT }) { +export default function CollectiblesTab({ onAddNFT }) { const collectibles = []; - const newNFTsDetected = true; + const newNFTsDetected = false; const t = useI18nContext(); return ( -
+
{collectibles.length > 0 ? ( - {JSON.stringify(collectibles)} + { + console.log('refreshing collectibles'); + }} + /> ) : ( {newNFTsDetected ? : null} @@ -79,6 +85,6 @@ export default function CollectiblesList({ onAddNFT }) { ); } -CollectiblesList.propTypes = { +CollectiblesTab.propTypes = { onAddNFT: PropTypes.func.isRequired, }; diff --git a/ui/components/app/collectibles-tab/index.js b/ui/components/app/collectibles-tab/index.js new file mode 100644 index 000000000..a69b09579 --- /dev/null +++ b/ui/components/app/collectibles-tab/index.js @@ -0,0 +1 @@ +export { default } from './collectibles-tab.component'; diff --git a/ui/pages/home/home.component.js b/ui/pages/home/home.component.js index dc0f9b74b..94a0e16cb 100644 --- a/ui/pages/home/home.component.js +++ b/ui/pages/home/home.component.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { Redirect, Route } from 'react-router-dom'; import { formatDate } from '../../helpers/utils/util'; import AssetList from '../../components/app/asset-list'; -import CollectiblesList from '../../components/app/collectibles-list'; +import CollectiblesTab from '../../components/app/collectibles-tab'; import HomeNotification from '../../components/app/home-notification'; import MultipleNotifications from '../../components/app/multiple-notifications'; import TransactionList from '../../components/app/transaction-list'; @@ -454,7 +454,7 @@ export default class Home extends PureComponent { data-testid="home__nfts-tab" name={t('nfts')} > - { history.push(ADD_COLLECTIBLE_ROUTE); }}