1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-24 09:18:09 +00:00

AsideRowAccount component WIP

This commit is contained in:
Vasek Mlejnsky 2018-08-15 14:03:29 +02:00
parent d511a9d2f4
commit f4651785d7
4 changed files with 100 additions and 20 deletions

View File

@ -10,6 +10,7 @@ import * as stateUtils from 'reducers/utils';
import Loader from 'components/common/LoaderCircle'; import Loader from 'components/common/LoaderCircle';
import Tooltip from 'rc-tooltip'; import Tooltip from 'rc-tooltip';
import AsideRowAccount from './AsideRowAccount';
import AsideSection from './AsideSection'; import AsideSection from './AsideSection';
import type { TrezorDevice, Accounts } from 'flowtype'; import type { TrezorDevice, Accounts } from 'flowtype';
@ -52,10 +53,16 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
} }
return ( return (
<NavLink key={i} activeClassName="selected" className="account" to={url}> <AsideRowAccount
{ `Account #${(account.index + 1)}` } accountIndex={account.index}
<span>{ account.loaded ? balance : 'Loading...' }</span> balance={balance}
</NavLink> url={url}
/>
// <NavLink key={i} activeClassName="selected" className="account" to={url}>
// { `Account #${(account.index + 1)}` }
// <span>{ account.loaded ? balance : 'Loading...' }</span>
// </NavLink>
); );
}); });
@ -63,10 +70,15 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
if (selected.connected) { if (selected.connected) {
const url: string = location.pathname.replace(/account+\/([0-9]*)/, 'account/0'); const url: string = location.pathname.replace(/account+\/([0-9]*)/, 'account/0');
selectedAccounts = ( selectedAccounts = (
<NavLink activeClassName="selected" className="account" to={url}> <AsideRowAccount
Account #1 accountIndex={0}
<span>Loading...</span> url={url}
</NavLink> />
// <NavLink activeClassName="selected" className="account" to={url}>
// Account #1
// <span>Loading...</span>
// </NavLink>
); );
} }
} }
@ -131,7 +143,7 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
return ( return (
<AsideSection> <AsideSection>
{ backButton } {/* { backButton } */}
<div> <div>
{ selectedAccounts } { selectedAccounts }
</div> </div>

View File

@ -0,0 +1,64 @@
import styled, { css } from 'styled-components';
import React from 'react';
import PropTypes from 'prop-types';
import { NavLink } from 'react-router-dom';
import AsideRow from './AsideRow';
import colors from 'config/colors';
import { FONT_SIZE, BORDER_WIDTH } from 'config/variables';
const Wrapper = styled.div`
height: 64px;
font-size: ${FONT_SIZE.SMALL};
border-top: 1px solid ${colors.DIVIDER};
span {
font-size: ${FONT_SIZE.SMALLER};
color: ${colors.TEXT_SECONDARY};
}
${props => props.selected && css`
border-left: ${BORDER_WIDTH.SELECTED} solid ${colors.GREEN_PRIMARY};
background: ${colors.WHITE};
&:hover {
background-color: ${colors.WHITE};
}
&:last-child {
border-bottom: 1px solid ${colors.DIVIDER};
}
`}
`;
const AsideRowAccount = ({ accountIndex, balance, url, selected }) => (
<NavLink to={url}>
<Wrapper
to={url}
selected={selected}
>
<AsideRow column>
Account #{accountIndex + 1}
{balance ? (
<span>{balance}</span>
) : (
<span>Loading...</span>
)}
</AsideRow>
</Wrapper>
</NavLink>
);
AsideRowAccount.propTypes = {
accountIndex: PropTypes.number.isRequired,
balance: PropTypes.string,
url: PropTypes.string.isRequired,
selected: PropTypes.bool,
};
AsideRowAccount.defaultProps = {
selected: true,
};
export default AsideRowAccount;

View File

@ -11,3 +11,7 @@ export const TRANSITION_TIME = {
export const ICON_SIZE = { export const ICON_SIZE = {
BASE: '20px', BASE: '20px',
} }
export const BORDER_WIDTH = {
SELECTED: '3px',
};

View File

@ -281,17 +281,17 @@ aside {
// } // }
&.account { &.account {
height: 64px; // height: 64px;
display: flex; // display: flex;
flex-direction: column; // flex-direction: column;
justify-content: space-evenly; // justify-content: space-evenly;
font-size: 14px; // font-size: 14px;
border-top: 1px solid @color_divider; // border-top: 1px solid @color_divider;
span { // span {
display: block; // display: block;
font-size: 12px; // font-size: 12px;
color: @color_text_secondary; // color: @color_text_secondary;
} // }
&:before { &:before {
content: ''; content: '';