From b5fc0120fc2ea9f3ffabb616af109bd1bc939bca Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Thu, 20 Feb 2025 22:11:27 +0100 Subject: [PATCH] feat: account selection fixes and improvements (#8902) --- .../AccountDropdown/AccountChildOption.tsx | 5 +-- .../AccountDropdown/AccountDropdown.tsx | 16 +++++---- .../AccountDropdown/AccountSegement.tsx | 3 +- src/components/InlineCopyButton.tsx | 35 +++++++++---------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/components/AccountDropdown/AccountChildOption.tsx b/src/components/AccountDropdown/AccountChildOption.tsx index 79675fbb513..c805128db30 100644 --- a/src/components/AccountDropdown/AccountChildOption.tsx +++ b/src/components/AccountDropdown/AccountChildOption.tsx @@ -17,10 +17,11 @@ export const AccountChildOption = forwardRef( ({ accountId, title, cryptoBalance, symbol, children, onOptionClick, ...props }, ref) => { const color = useColorModeValue('black', 'white') const handleClick = useCallback(() => onOptionClick(accountId), [accountId, onOptionClick]) + return ( - - + + {title} { const { assetId, chainId } = asset - const translate = useTranslate() const accountBalances = useSelector(selectPortfolioAccountBalancesBaseUnit) const accountMetadata = useSelector(selectPortfolioAccountMetadata) @@ -149,14 +150,17 @@ const MenuOptions = ({ // the account sub title uses an account id which is then converted to a chainId and pubkey // so for convenience and simplicity we can safely use the first account id here const [firstAccountId] = accountIds - const subtitle = accountIdToLabel(firstAccountId) + const isUtxo = isUtxoAccountId(firstAccountId) return ( - + + + {!isUtxo && } + {sortedAccountIds.map((iterAccountId, index) => ( = ({ title, subtitle }) => ( {title} {subtitle && ( diff --git a/src/components/InlineCopyButton.tsx b/src/components/InlineCopyButton.tsx index 54ca1fcf6cc..01e0ca27f69 100644 --- a/src/components/InlineCopyButton.tsx +++ b/src/components/InlineCopyButton.tsx @@ -1,7 +1,7 @@ import { CheckIcon, CopyIcon } from '@chakra-ui/icons' import { Flex, IconButton } from '@chakra-ui/react' import type { MouseEvent, PropsWithChildren } from 'react' -import React, { useCallback } from 'react' +import React, { useCallback, useMemo } from 'react' import { useTranslate } from 'react-polyglot' import { useCopyToClipboard } from 'hooks/useCopyToClipboard' @@ -31,6 +31,19 @@ export const InlineCopyButton: React.FC = ({ [copyToClipboard, value], ) + const buttonProps = useMemo( + () => ({ + icon: isCopied ? checkIcon : copyIcon, + colorScheme: isCopied ? 'green' : 'gray', + size: 'xs', + variant: 'ghost', + fontSize: 'sm', + 'aria-label': 'Copy value', + onClick: handleCopyClick, + }), + [handleCopyClick, isCopied], + ) + // Hide the copy button if it is disabled if (isDisabled) return <>{children} @@ -39,26 +52,10 @@ export const InlineCopyButton: React.FC = ({ {children} {translate ? ( - + ) : ( - + )} )