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

Fixing width for Sender Component. #286

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/components/SenderAccountsListByChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function SenderAccountsListByChain({ chain, showCompanion, showEm
address={option.account.address}
balance={option.account.balance.formattedBalance}
companionBalance={option.companionAccount.balance.formattedBalance}
companionAddress={option.companionAccount.address}
showCompanion={showCompanion}
/>
);
Expand Down
67 changes: 47 additions & 20 deletions src/components/SenderDropdownItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import React, { useState } from 'react';
import cx from 'classnames';
import { Box, makeStyles, Typography } from '@material-ui/core';
import { Box, makeStyles, Typography, Tooltip } from '@material-ui/core';
import shorterItem from '../util/shortenItem';
import AccountIdenticon from './AccountIdenticon';
import { useGUIContext } from '../contexts/GUIContextProvider';
Expand All @@ -27,12 +27,15 @@ interface Props {
companionBalance: string;
address: string;
showCompanion: boolean;
companionAddress: string;
}

const useStyles = makeStyles((theme) => ({
topBalance: {
minWidth: theme.spacing(14)
minWidth: theme.spacing(14),
marginLeft: theme.spacing(5)
},

bottomBalance: {
border: `1px solid ${theme.palette.divider}`,
borderRadius: theme.spacing(0.5),
Expand Down Expand Up @@ -63,13 +66,27 @@ const useStyles = makeStyles((theme) => ({
},
address: {
marginLeft: theme.spacing(0.5)
},
addressContainer: {
maxWidth: theme.spacing(30)
},
tooltip: {
maxWidth: 350
}
}));

const SenderDropdownItem = ({ name, address, balance, companionBalance, showCompanion }: Props) => {
const SenderDropdownItem = ({ name, address, balance, companionBalance, showCompanion, companionAddress }: Props) => {
const classes = useStyles();
const [hoover, setHoover] = useState(false);
const { isBridged } = useGUIContext();

const companionTitle = ` Companion: ${companionAddress}`;
let title = `Native: ${address}`;

if (isBridged) {
title = title.concat(companionTitle);
}

return (
<div
className={cx(classes.main, hoover ? classes.hoover : '')}
Expand All @@ -80,31 +97,41 @@ const SenderDropdownItem = ({ name, address, balance, companionBalance, showComp
setHoover(false);
}}
>
<Box display="flex" className={classes.box} id="test-transaction-header" alignItems="start">
<AccountIdenticon address={address} />
<Typography classes={{ root: classes.address }}>
{name} [{shorterItem(address)}]
</Typography>
<Tooltip placement="top" title={title} aria-label="add" classes={{ tooltip: classes.tooltip }} arrow>
<Box display="flex" className={classes.box} id="test-transaction-header" alignItems="start">
<AccountIdenticon address={address} />
<div className={classes.addressContainer}>
<Typography noWrap classes={{ root: classes.address }}>
{name} [{shorterItem(address)}]
</Typography>
</div>

<Box marginLeft="auto" display="flex" flexDirection="column" alignItems="flex-end" id="test-transaction-header">
<Box
className={cx(classes.topBalance, isBridged && showCompanion ? classes.border : '')}
marginLeft="auto"
display="flex"
justifyContent="flex-end"
flexDirection="column"
alignItems="flex-end"
id="test-transaction-header"
>
<Typography component="p" className={classes.balanceBody}>
{balance}
</Typography>
</Box>
{showCompanion && isBridged && (
<Box className={classes.bottomBalance} display="flex" justifyContent="flex-end">
<Box
className={cx(classes.topBalance, isBridged && showCompanion ? classes.border : '')}
display="flex"
justifyContent="flex-end"
>
<Typography component="p" className={classes.balanceBody}>
{companionBalance}
{balance}
</Typography>
</Box>
)}
{showCompanion && isBridged && (
<Box className={classes.bottomBalance} display="flex" justifyContent="flex-end">
<Typography component="p" className={classes.balanceBody}>
{companionBalance}
</Typography>
</Box>
)}
</Box>
</Box>
</Box>
</Tooltip>
</div>
);
};
Expand Down