From acd99318b3d8eddaaa2a9b100ef55968e0f6bb80 Mon Sep 17 00:00:00 2001 From: Victor Thomas <10986371+vthomas13@users.noreply.github.com> Date: Tue, 13 Jun 2023 17:49:53 -0400 Subject: [PATCH] Icon changes, add badgewrapped icons to smart tx --- .../app/transaction-icon/transaction-icon.js | 75 +++++++++++------- .../app/transaction-list-item/index.scss | 5 -- .../smart-transaction-list-item.component.js | 46 +++++++++-- .../transaction-list-item.component.js | 77 +++++++++++++------ .../activity-list-item/activity-list-item.js | 5 +- 5 files changed, 146 insertions(+), 62 deletions(-) diff --git a/ui/components/app/transaction-icon/transaction-icon.js b/ui/components/app/transaction-icon/transaction-icon.js index bb42a71b9589..820c4969dd12 100644 --- a/ui/components/app/transaction-icon/transaction-icon.js +++ b/ui/components/app/transaction-icon/transaction-icon.js @@ -1,47 +1,56 @@ import React from 'react'; import { useDispatch } from 'react-redux'; import PropTypes from 'prop-types'; -import Approve from '../../ui/icon/approve-icon.component'; -import Interaction from '../../ui/icon/interaction-icon.component'; -import Receive from '../../ui/icon/receive-icon.component'; -import Send from '../../ui/icon/send-icon.component'; -import Sign from '../../ui/icon/sign-icon.component'; -import Swap from '../../ui/icon/swap-icon-for-list.component'; import { TransactionGroupCategory, TransactionGroupStatus, TransactionStatus, } from '../../../../shared/constants/transaction'; import { captureSingleException } from '../../../store/actions'; +import { AvatarIcon, IconName } from '../../component-library'; +import { + BackgroundColor, + IconColor, + Size, +} from '../../../helpers/constants/design-system'; const ICON_MAP = { - [TransactionGroupCategory.approval]: Approve, - [TransactionGroupCategory.interaction]: Interaction, - [TransactionGroupCategory.receive]: Receive, - [TransactionGroupCategory.send]: Send, - [TransactionGroupCategory.signatureRequest]: Sign, - [TransactionGroupCategory.swap]: Swap, + [TransactionGroupCategory.approval]: IconName.Check, + [TransactionGroupCategory.interaction]: IconName.ProgrammingArrows, + [TransactionGroupCategory.receive]: IconName.Received, + [TransactionGroupCategory.send]: IconName.Arrow2UpRight, + [TransactionGroupCategory.signatureRequest]: IconName.SecurityTick, + [TransactionGroupCategory.swap]: IconName.SwapHorizontal, }; -const FAIL_COLOR = 'var(--color-error-default)'; -const PENDING_COLOR = 'var(--color-icon-default)'; -const OK_COLOR = 'var(--color-primary-default)'; - const COLOR_MAP = { - [TransactionGroupStatus.pending]: PENDING_COLOR, - [TransactionGroupStatus.cancelled]: FAIL_COLOR, - [TransactionStatus.approved]: PENDING_COLOR, - [TransactionStatus.dropped]: FAIL_COLOR, - [TransactionStatus.failed]: FAIL_COLOR, - [TransactionStatus.rejected]: FAIL_COLOR, - [TransactionStatus.submitted]: PENDING_COLOR, - [TransactionStatus.unapproved]: PENDING_COLOR, + [TransactionGroupStatus.pending]: IconColor.primaryDefault, + [TransactionGroupStatus.cancelled]: IconColor.errorDefault, + [TransactionStatus.approved]: IconColor.primaryDefault, + [TransactionStatus.dropped]: IconColor.errorDefault, + [TransactionStatus.failed]: IconColor.errorDefault, + [TransactionStatus.rejected]: IconColor.errorDefault, + [TransactionStatus.submitted]: IconColor.primaryDefault, + [TransactionStatus.unapproved]: IconColor.primaryDefault, +}; + +const BACKGROUND_COLOR_MAP = { + [TransactionGroupStatus.pending]: BackgroundColor.primaryMuted, + [TransactionGroupStatus.cancelled]: BackgroundColor.errorMuted, + [TransactionStatus.approved]: BackgroundColor.primaryMuted, + [TransactionStatus.dropped]: BackgroundColor.errorMuted, + [TransactionStatus.failed]: BackgroundColor.errorMuted, + [TransactionStatus.rejected]: BackgroundColor.errorMuted, + [TransactionStatus.submitted]: BackgroundColor.primaryMuted, + [TransactionStatus.unapproved]: BackgroundColor.primaryMuted, }; export default function TransactionIcon({ status, category }) { const dispatch = useDispatch(); - const color = COLOR_MAP[status] || OK_COLOR; + const color = COLOR_MAP[status] || IconColor.primaryDefault; + const backgroundColor = + BACKGROUND_COLOR_MAP[status] || BackgroundColor.primaryMuted; const Icon = ICON_MAP[category]; if (!Icon) { @@ -50,10 +59,22 @@ export default function TransactionIcon({ status, category }) { `The category prop passed to TransactionIcon is not supported. The prop is: ${category}`, ), ); - return
; + return ( + + ); } - return ; + return ( + + ); } TransactionIcon.propTypes = { diff --git a/ui/components/app/transaction-list-item/index.scss b/ui/components/app/transaction-list-item/index.scss index 069510062a1c..d4aa3f1c387e 100644 --- a/ui/components/app/transaction-list-item/index.scss +++ b/ui/components/app/transaction-list-item/index.scss @@ -57,11 +57,6 @@ text-overflow: initial; } - .transaction-status-label::after { - content: "ยท"; - margin: 0 4px; - } - &__address { overflow: hidden; text-overflow: ellipsis; diff --git a/ui/components/app/transaction-list-item/smart-transaction-list-item.component.js b/ui/components/app/transaction-list-item/smart-transaction-list-item.component.js index 7c71e3a442d6..af01c63217a8 100644 --- a/ui/components/app/transaction-list-item/smart-transaction-list-item.component.js +++ b/ui/components/app/transaction-list-item/smart-transaction-list-item.component.js @@ -1,7 +1,6 @@ import React, { useState, useCallback } from 'react'; import PropTypes from 'prop-types'; -import { useDispatch } from 'react-redux'; -import ListItem from '../../ui/list-item'; +import { useDispatch, useSelector } from 'react-redux'; import TransactionStatusLabel from '../transaction-status-label/transaction-status-label'; import TransactionIcon from '../transaction-icon'; import { useI18nContext } from '../../../hooks/useI18nContext'; @@ -17,6 +16,18 @@ import CancelButton from '../cancel-button'; import { cancelSwapsSmartTransaction } from '../../../ducks/swaps/swaps'; import SiteOrigin from '../../ui/site-origin'; import TransactionListItemDetails from '../transaction-list-item-details'; +import { ActivityListItem } from '../../multichain/activity-list-item'; +import { + AvatarNetwork, + BadgeWrapper, + BadgeWrapperAnchorElementShape, +} from '../../component-library'; +import { + BackgroundColor, + Display, + Size, +} from '../../../helpers/constants/design-system'; +import { getCurrentNetwork } from '../../../selectors'; export default function SmartTransactionListItem({ smartTransaction, @@ -29,6 +40,8 @@ export default function SmartTransactionListItem({ const [showDetails, setShowDetails] = useState(false); const { primaryCurrency, recipientAddress, isPending, senderAddress } = useTransactionDisplayData(transactionGroup); + const currentChain = useSelector(getCurrentNetwork); + const { sourceTokenSymbol, destinationTokenSymbol, time, status } = smartTransaction; const category = TransactionGroupCategory.swap; @@ -37,7 +50,11 @@ export default function SmartTransactionListItem({ destinationTokenSymbol, ]); const subtitle = 'metamask'; - const date = formatDateWithYearContext(time); + const date = formatDateWithYearContext( + time, + "MMM d 'at' h:mm a", + "MMM d, y 'at' h:mm a", + ); let displayedStatusKey; if (status === SmartTransactionStatus.pending) { displayedStatusKey = TransactionGroupStatus.pending; @@ -52,12 +69,29 @@ export default function SmartTransactionListItem({ }, []); return ( <> - + + } + > + + } subtitle={

@@ -88,7 +122,7 @@ export default function SmartTransactionListItem({ />

)} - + {showDetails && ( - + - + ) : ( ///: END:ONLY_INCLUDE_IN - + + } + > + + ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) ) ///: END:ONLY_INCLUDE_IN } subtitle={ -

+ - {subtitleContainsOrigin ? ( - - ) : ( - - {subtitle} - - )} -

+ } rightContent={ !isSignatureReq && @@ -300,7 +333,7 @@ function TransactionListItemInner({ ///: END:ONLY_INCLUDE_IN } -
+ {showDetails && (