Skip to content

Commit

Permalink
Merge pull request #509 from secretkeylabs/tim/eng-2374-account-selec…
Browse files Browse the repository at this point in the history
…tion-dropdown-click-behaviour
  • Loading branch information
teebszet committed Jul 10, 2023
2 parents f02989e + 1c651c6 commit 0a0df9c
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/app/components/accountRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ const RowContainer = styled.div({
flexDirection: 'row',
});

const GradientCircle = styled.button<GradientCircleProps>((props) => ({
const GradientCircle = styled.div<GradientCircleProps>((props) => ({
height: 40,
width: 40,
borderRadius: 25,
background: `linear-gradient(to bottom,${props.firstGradient}, ${props.secondGradient},${props.thirdGradient} )`,
}));

const TopSectionContainer = styled.button((props) => ({
const TopSectionContainer = styled.div((props) => ({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
paddingTop: props.theme.spacing(8),
backgroundColor: 'transparent',
cursor: 'pointer',
}));

const CurrentAcountContainer = styled.div((props) => ({
Expand Down Expand Up @@ -97,7 +98,7 @@ const AddressContainer = styled.div({
justifyContent: 'center',
});

const Button = styled.button`
const TransparentSpan = styled.span`
background: transparent;
`;

Expand Down Expand Up @@ -178,7 +179,7 @@ function AccountRow({
return name.length > 20 ? `${name.slice(0, 20)}...` : name;
}

const handleOnBtcAddressClick = () => {
const handleOnBtcAddressClick = (event: React.MouseEvent<HTMLButtonElement>) => {
navigator.clipboard.writeText(account?.btcAddress!);
setOnBtcCopied(true);
setOnStxCopied(false);
Expand All @@ -187,20 +188,16 @@ function AccountRow({
if (showBtcReceiveAlert !== null) {
dispatch(ChangeShowBtcReceiveAlertAction(true));
}
event.stopPropagation();
};

const handleOnStxAddressClick = () => {
const handleOnStxAddressClick = (event: React.MouseEvent<HTMLButtonElement>) => {
navigator.clipboard.writeText(account?.stxAddress!);
setOnStxCopied(true);
setOnBtcCopied(false);
// set 'Copied' text back to 'Stacks address' after 3 seconds
stxCopiedTooltipTimeoutRef.current = setTimeout(() => setOnStxCopied(false), 3000);
};

const onRowClick = () => {
if (!allowCopyAddress) {
onAccountSelected(account!);
}
event.stopPropagation();
};

const onClick = () => {
Expand Down Expand Up @@ -257,29 +254,28 @@ function AccountRow({
);

return (
<TopSectionContainer>
<TopSectionContainer onClick={onClick}>
<GradientCircle
firstGradient={gradient[0]}
secondGradient={gradient[1]}
thirdGradient={gradient[2]}
onClick={onClick}
/>
<CurrentAcountContainer>
{account
&& (isSelected ? (
<Button onClick={onClick}>
<TransparentSpan>
<CurrentAccountTextContainer>
<CurrentSelectedAccountText>{getName()}</CurrentSelectedAccountText>
{isHardwareAccount(account) && <img src={LedgerBadge} alt="Ledger icon" />}
</CurrentAccountTextContainer>
</Button>
</TransparentSpan>
) : (
<Button onClick={onClick}>
<TransparentSpan onClick={onClick}>
<CurrentAccountTextContainer>
<CurrentUnSelectedAccountText>{getName()}</CurrentUnSelectedAccountText>
{isHardwareAccount(account) && <img src={LedgerBadge} alt="Ledger icon" />}
</CurrentAccountTextContainer>
</Button>
</TransparentSpan>
))}

{!!account && !isHardwareAccount(account) && (
Expand Down

0 comments on commit 0a0df9c

Please sign in to comment.