Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tim/eng 2374 account selection dropdown click behaviour #509

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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