mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-16 10:02:01 +00:00
Refactored /wallet/aside folder to new folder structure
This commit is contained in:
parent
0c58820999
commit
71d8712575
@ -1,77 +0,0 @@
|
|||||||
/* @flow */
|
|
||||||
|
|
||||||
|
|
||||||
//import React, { Node } from 'react';
|
|
||||||
import * as React from 'react';
|
|
||||||
import { Link, NavLink } from 'react-router-dom';
|
|
||||||
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
||||||
|
|
||||||
import type { TrezorDevice } from 'flowtype';
|
|
||||||
import { DeviceSelect, DeviceDropdown } from './DeviceSelection';
|
|
||||||
import AccountSelection from './AccountSelection';
|
|
||||||
import CoinSelection from './CoinSelection';
|
|
||||||
import StickyContainer from './StickyContainer';
|
|
||||||
|
|
||||||
import type { Props } from './index';
|
|
||||||
|
|
||||||
|
|
||||||
type TransitionMenuProps = {
|
|
||||||
animationType: string;
|
|
||||||
children?: React.Node;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TransitionMenu = (props: TransitionMenuProps): React$Element<TransitionGroup> => (
|
|
||||||
<TransitionGroup component="div" className="transition-container">
|
|
||||||
<CSSTransition
|
|
||||||
key={props.animationType}
|
|
||||||
onExit={() => { window.dispatchEvent(new Event('resize')); }}
|
|
||||||
onExited={() => window.dispatchEvent(new Event('resize'))}
|
|
||||||
in
|
|
||||||
out
|
|
||||||
classNames={props.animationType}
|
|
||||||
appear={false}
|
|
||||||
timeout={300}
|
|
||||||
>
|
|
||||||
{ props.children }
|
|
||||||
</CSSTransition>
|
|
||||||
</TransitionGroup>
|
|
||||||
);
|
|
||||||
|
|
||||||
const Aside = (props: Props): React$Element<typeof StickyContainer | string> => {
|
|
||||||
const selected: ?TrezorDevice = props.wallet.selectedDevice;
|
|
||||||
const { location } = props.router;
|
|
||||||
|
|
||||||
if (location.pathname === '/' || !selected) return (<aside />);
|
|
||||||
|
|
||||||
let menu = <section />;
|
|
||||||
|
|
||||||
if (props.deviceDropdownOpened) {
|
|
||||||
menu = <DeviceDropdown {...props} />;
|
|
||||||
} else if (location.state.network) {
|
|
||||||
menu = (
|
|
||||||
<TransitionMenu animationType="slide-left">
|
|
||||||
<AccountSelection {...props} />
|
|
||||||
</TransitionMenu>
|
|
||||||
);
|
|
||||||
} else if (selected.features && !selected.features.bootloader_mode && selected.features.initialized) {
|
|
||||||
menu = (
|
|
||||||
<TransitionMenu animationType="slide-right">
|
|
||||||
<CoinSelection {...props} />
|
|
||||||
</TransitionMenu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StickyContainer location={location.pathname} deviceSelection={props.deviceDropdownOpened}>
|
|
||||||
<DeviceSelect {...props} />
|
|
||||||
{ menu }
|
|
||||||
<div className="sticky-bottom">
|
|
||||||
<div className="help">
|
|
||||||
<a href="https://trezor.io/support/" target="_blank" rel="noreferrer noopener">Need help?</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</StickyContainer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Aside;
|
|
@ -1,16 +0,0 @@
|
|||||||
import styled from 'styled-components';
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
const Section = styled.section`
|
|
||||||
width: 320px;
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: top;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AsideSection = (props) => (
|
|
||||||
<Section>
|
|
||||||
{props.children}
|
|
||||||
</Section>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default AsideSection;
|
|
@ -1,63 +0,0 @@
|
|||||||
import colors from 'config/colors';
|
|
||||||
import { FONT_SIZE, BORDER_WIDTH } from 'config/variables';
|
|
||||||
import { NavLink } from 'react-router-dom';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
|
||||||
import styled, { css } from 'styled-components';
|
|
||||||
|
|
||||||
import AsideRow from '../AsideRow';
|
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
|
||||||
height: 64px;
|
|
||||||
|
|
||||||
font-size: ${FONT_SIZE.SMALL};
|
|
||||||
color: ${colors.TEXT_PRIMARY};
|
|
||||||
|
|
||||||
border-top: 1px solid ${colors.DIVIDER};
|
|
||||||
span {
|
|
||||||
font-size: ${FONT_SIZE.SMALLER};
|
|
||||||
color: ${colors.TEXT_SECONDARY};
|
|
||||||
}
|
|
||||||
|
|
||||||
${props => props.isSelected && 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, isSelected = false,
|
|
||||||
}) => (
|
|
||||||
<NavLink to={url}>
|
|
||||||
<Wrapper
|
|
||||||
to={url}
|
|
||||||
isSelected={isSelected}
|
|
||||||
>
|
|
||||||
<AsideRow column>
|
|
||||||
Account #{accountIndex + 1}
|
|
||||||
{balance ? (
|
|
||||||
<span>{balance}</span>
|
|
||||||
) : (
|
|
||||||
<span>Loading...</span>
|
|
||||||
)}
|
|
||||||
</AsideRow>
|
|
||||||
</Wrapper>
|
|
||||||
</NavLink>
|
|
||||||
);
|
|
||||||
|
|
||||||
AsideRowAccount.propTypes = {
|
|
||||||
accountIndex: PropTypes.number.isRequired,
|
|
||||||
url: PropTypes.string.isRequired,
|
|
||||||
balance: PropTypes.string,
|
|
||||||
isSelected: PropTypes.bool,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AsideRowAccount;
|
|
@ -1,49 +0,0 @@
|
|||||||
|
|
||||||
import colors from 'config/colors';
|
|
||||||
import { FONT_SIZE } from 'config/variables';
|
|
||||||
import Icon from 'components/common/Icon';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
import AsideRow from '../AsideRow';
|
|
||||||
import CoinName from './CoinName';
|
|
||||||
import { coinProp } from '../../common';
|
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
|
||||||
display: block;
|
|
||||||
height: 50px;
|
|
||||||
|
|
||||||
font-size: ${FONT_SIZE.BASE};
|
|
||||||
color: ${colors.TEXT_PRIMARY};
|
|
||||||
&:hover {
|
|
||||||
background-color: ${colors.GRAY_LIGHT};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const AsideRowCoin = ({ coin, icon }) => (
|
|
||||||
<Wrapper>
|
|
||||||
<AsideRow>
|
|
||||||
<CoinName
|
|
||||||
coinImg={coin.img}
|
|
||||||
text={coin.name}
|
|
||||||
/>
|
|
||||||
{icon && (
|
|
||||||
<Icon
|
|
||||||
icon={icon.type}
|
|
||||||
color={icon.color}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</AsideRow>
|
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
|
|
||||||
AsideRowCoin.propTypes = {
|
|
||||||
...coinProp,
|
|
||||||
icon: PropTypes.shape({
|
|
||||||
type: PropTypes.string.isRequired,
|
|
||||||
color: PropTypes.string.isRequired,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AsideRowCoin;
|
|
@ -1,39 +0,0 @@
|
|||||||
import styled from 'styled-components';
|
|
||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import colors from 'config/colors';
|
|
||||||
import { ICON_SIZE } from 'config/variables';
|
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Logo = styled.div`
|
|
||||||
height: ${ICON_SIZE.BASE};
|
|
||||||
width: ${ICON_SIZE.BASE};
|
|
||||||
margin-right: 10px;
|
|
||||||
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: center;
|
|
||||||
background-size: auto ${ICON_SIZE.BASE};
|
|
||||||
background-image: url('${props => props.coinImg}');
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CoinName = ({ coinImg, text }) => (
|
|
||||||
<Wrapper>
|
|
||||||
<Logo
|
|
||||||
coinImg={coinImg}
|
|
||||||
/>
|
|
||||||
<p>{text}</p>
|
|
||||||
</Wrapper>
|
|
||||||
);
|
|
||||||
|
|
||||||
CoinName.propTypes = {
|
|
||||||
coinImg: PropTypes.string.isRequired,
|
|
||||||
text: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default CoinName
|
|
@ -10,7 +10,8 @@ import Header from '../common/Header';
|
|||||||
import Footer from '../common/Footer';
|
import Footer from '../common/Footer';
|
||||||
import AccountTabs from './account/AccountTabs';
|
import AccountTabs from './account/AccountTabs';
|
||||||
import DeviceSettingsTabs from './pages/DeviceSettingsTabs';
|
import DeviceSettingsTabs from './pages/DeviceSettingsTabs';
|
||||||
import AsideContainer from './aside';
|
// import AsideContainer from './aside';
|
||||||
|
import LeftNavigation from 'views/Device/components/LeftNavigation/Container';
|
||||||
import ModalContainer from '../modal';
|
import ModalContainer from '../modal';
|
||||||
import Notifications from '../common/Notification';
|
import Notifications from '../common/Notification';
|
||||||
import Log from '../common/Log';
|
import Log from '../common/Log';
|
||||||
@ -29,7 +30,7 @@ const Wallet = (props: WalletContainerProps) => (
|
|||||||
<Header />
|
<Header />
|
||||||
{/* <div>{ props.wallet.online ? "ONLINE" : "OFFLINE" }</div> */}
|
{/* <div>{ props.wallet.online ? "ONLINE" : "OFFLINE" }</div> */}
|
||||||
<main>
|
<main>
|
||||||
<AsideContainer />
|
<LeftNavigation />
|
||||||
<article>
|
<article>
|
||||||
<nav>
|
<nav>
|
||||||
<Route path="/device/:device/network/:network/account/:account" component={AccountTabs} />
|
<Route path="/device/:device/network/:network/account/:account" component={AccountTabs} />
|
||||||
|
0
src/js/views/Device/Container.js
Normal file
0
src/js/views/Device/Container.js
Normal file
@ -1,18 +1,14 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
import { toggleDeviceDropdown } from 'actions/WalletActions';
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { withRouter } from 'react-router-dom';
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
import * as TrezorConnectActions from 'actions/TrezorConnectActions';
|
||||||
import { toggleDeviceDropdown } from 'actions/WalletActions';
|
|
||||||
|
|
||||||
|
|
||||||
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
|
||||||
import type { State, Dispatch } from 'flowtype';
|
import type { State, Dispatch } from 'flowtype';
|
||||||
import Aside from './Aside';
|
|
||||||
|
import LeftNavigation from './LeftNavigation';
|
||||||
|
|
||||||
type OwnProps = {
|
type OwnProps = {
|
||||||
|
|
||||||
@ -41,8 +37,6 @@ type DispatchProps = {
|
|||||||
onSelectDevice: typeof TrezorConnectActions.onSelectDevice,
|
onSelectDevice: typeof TrezorConnectActions.onSelectDevice,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
|
||||||
|
|
||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => ({
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => ({
|
||||||
connect: state.connect,
|
connect: state.connect,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
@ -67,7 +61,6 @@ const mapDispatchToProps: MapDispatchToProps<Dispatch, OwnProps, DispatchProps>
|
|||||||
onSelectDevice: bindActionCreators(TrezorConnectActions.onSelectDevice, dispatch),
|
onSelectDevice: bindActionCreators(TrezorConnectActions.onSelectDevice, dispatch),
|
||||||
});
|
});
|
||||||
|
|
||||||
// export default connect(mapStateToProps, mapDispatchToProps)(Aside);
|
|
||||||
export default withRouter(
|
export default withRouter(
|
||||||
connect(mapStateToProps, mapDispatchToProps)(Aside),
|
connect(mapStateToProps, mapDispatchToProps)(LeftNavigation),
|
||||||
);
|
);
|
@ -16,16 +16,16 @@ const Wrapper = styled.div`
|
|||||||
border-bottom: 1px solid ${colors.DIVIDER};
|
border-bottom: 1px solid ${colors.DIVIDER};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const AsideDivider = ({ textLeft, textRight }) => (
|
const Divider = ({ textLeft, textRight }) => (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<p>{textLeft}</p>
|
<p>{textLeft}</p>
|
||||||
<p>{textRight}</p>
|
<p>{textRight}</p>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|
||||||
AsideDivider.propTypes = {
|
Divider.propTypes = {
|
||||||
textLeft: PropTypes.string.isRequired,
|
textLeft: PropTypes.string.isRequired,
|
||||||
textRight: PropTypes.string.isRequired,
|
textRight: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AsideDivider;
|
export default Divider;
|
112
src/js/views/Device/components/LeftNavigation/LeftNavigation.js
Normal file
112
src/js/views/Device/components/LeftNavigation/LeftNavigation.js
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/* @flow */
|
||||||
|
import * as React from 'react';
|
||||||
|
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import type { TrezorDevice } from 'flowtype';
|
||||||
|
import { DeviceSelect, DeviceDropdown } from './selection/DeviceSelection';
|
||||||
|
import AccountSelection from './selection/AccountSelection';
|
||||||
|
import CoinSelection from './selection/CoinSelection';
|
||||||
|
import StickyContainer from './StickyContainer';
|
||||||
|
|
||||||
|
import type { Props } from './index';
|
||||||
|
|
||||||
|
type TransitionMenuProps = {
|
||||||
|
animationType: string;
|
||||||
|
children?: React.Node;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TransitionGroupWrapper = styled(TransitionGroup)`
|
||||||
|
width: 640px;
|
||||||
|
`;
|
||||||
|
const TransitionContentWrapper = styled.div`
|
||||||
|
width: 320px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TransitionMenu = (props: TransitionMenuProps): React$Element<TransitionGroup> => {
|
||||||
|
return (
|
||||||
|
<TransitionGroupWrapper component="div" className="transition-container">
|
||||||
|
<CSSTransition
|
||||||
|
key={props.animationType}
|
||||||
|
onExit={() => { window.dispatchEvent(new Event('resize')); }}
|
||||||
|
onExited={() => window.dispatchEvent(new Event('resize'))}
|
||||||
|
in
|
||||||
|
out
|
||||||
|
classNames={props.animationType}
|
||||||
|
appear={false}
|
||||||
|
timeout={300}
|
||||||
|
>
|
||||||
|
<TransitionContentWrapper>
|
||||||
|
{props.children}
|
||||||
|
</TransitionContentWrapper>
|
||||||
|
</CSSTransition>
|
||||||
|
</TransitionGroupWrapper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const LeftNavigation = (props: Props): React$Element<typeof StickyContainer | string> => {
|
||||||
|
const selected: ?TrezorDevice = props.wallet.selectedDevice;
|
||||||
|
const { location } = props.router;
|
||||||
|
|
||||||
|
if (location.pathname === '/' || !selected) return (<aside />);
|
||||||
|
|
||||||
|
let menu = <section />;
|
||||||
|
|
||||||
|
let shouldRenderDeviceSelection = false;
|
||||||
|
// let shouldRenderCoins = false;
|
||||||
|
// let shouldRenderAccounts = false;
|
||||||
|
|
||||||
|
let animationType = '';
|
||||||
|
if (props.deviceDropdownOpened) {
|
||||||
|
shouldRenderDeviceSelection = true;
|
||||||
|
// menu = <DeviceDropdown {...props} />;
|
||||||
|
} else if (location.state.network) {
|
||||||
|
// shouldRenderAccounts = true;
|
||||||
|
shouldRenderDeviceSelection = false;
|
||||||
|
animationType = 'slide-left';
|
||||||
|
// menu = (
|
||||||
|
// <TransitionMenu animationType="slide-left">
|
||||||
|
// <AccountSelection {...props} />
|
||||||
|
// </TransitionMenu>
|
||||||
|
// );
|
||||||
|
} else if (selected.features && !selected.features.bootloader_mode && selected.features.initialized) {
|
||||||
|
// shouldRenderCoins = true;
|
||||||
|
shouldRenderDeviceSelection = false;
|
||||||
|
animationType = 'slide-right';
|
||||||
|
// menu = (
|
||||||
|
// <TransitionMenu animationType="slide-right">
|
||||||
|
// <CoinSelection {...props} />
|
||||||
|
// </TransitionMenu>
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StickyContainer location={location.pathname} deviceSelection={props.deviceDropdownOpened}>
|
||||||
|
<DeviceSelect {...props} />
|
||||||
|
{/* { menu } */}
|
||||||
|
|
||||||
|
{shouldRenderDeviceSelection ? (
|
||||||
|
<DeviceDropdown {...props} />
|
||||||
|
) : (
|
||||||
|
<TransitionMenu
|
||||||
|
animationType={animationType}
|
||||||
|
>
|
||||||
|
{animationType === 'slide-left' && <AccountSelection key="accounts" {...props} />}
|
||||||
|
{animationType === 'slide-right' && <CoinSelection key="coins" {...props} />}
|
||||||
|
</TransitionMenu>
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
<div className="sticky-bottom">
|
||||||
|
<div className="help">
|
||||||
|
<a href="https://trezor.io/support/" target="_blank" rel="noreferrer noopener">Need help?</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</StickyContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LeftNavigation;
|
@ -22,14 +22,16 @@ const Wrapper = styled.div`
|
|||||||
transition: background-color ${TRANSITION_TIME.BASE}, color ${TRANSITION_TIME.BASE};
|
transition: background-color ${TRANSITION_TIME.BASE}, color ${TRANSITION_TIME.BASE};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const AsideRow = ({ children, column = false }) => (
|
const Row = ({
|
||||||
|
children, column = false,
|
||||||
|
}) => (
|
||||||
<Wrapper
|
<Wrapper
|
||||||
column={column}
|
column={column}
|
||||||
>{children}
|
>{children}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|
||||||
AsideRow.propTypes = {
|
Row.propTypes = {
|
||||||
children: PropTypes.oneOfType([
|
children: PropTypes.oneOfType([
|
||||||
PropTypes.arrayOf(PropTypes.node),
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
PropTypes.node,
|
PropTypes.node,
|
||||||
@ -37,4 +39,4 @@ AsideRow.propTypes = {
|
|||||||
column: PropTypes.bool,
|
column: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AsideRow;
|
export default Row;
|
@ -141,7 +141,7 @@ export default class StickyContainer extends React.PureComponent<Props> {
|
|||||||
className="sticky-container"
|
className="sticky-container"
|
||||||
ref={node => this.wrapper = node}
|
ref={node => this.wrapper = node}
|
||||||
>
|
>
|
||||||
{ this.props.children }
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
@ -10,19 +10,75 @@ 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 colors from 'config/colors';
|
||||||
import AsideSection from './AsideSection';
|
import { FONT_SIZE, BORDER_WIDTH } from 'config/variables';
|
||||||
|
import styled, { css } from 'styled-components';
|
||||||
|
import Row from '../Row';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
//import AsideRowAccount from './row/account/AsideRowAccount';
|
||||||
|
|
||||||
import type { TrezorDevice, Accounts } from 'flowtype';
|
import type { TrezorDevice, Accounts } from 'flowtype';
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
|
|
||||||
|
const RowAccountWrapper = styled.div`
|
||||||
|
height: 64px;
|
||||||
|
|
||||||
|
font-size: ${FONT_SIZE.SMALL};
|
||||||
|
color: ${colors.TEXT_PRIMARY};
|
||||||
|
|
||||||
|
border-top: 1px solid ${colors.DIVIDER};
|
||||||
|
span {
|
||||||
|
font-size: ${FONT_SIZE.SMALLER};
|
||||||
|
color: ${colors.TEXT_SECONDARY};
|
||||||
|
}
|
||||||
|
|
||||||
|
${props => props.isSelected && 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 RowAccount = ({
|
||||||
|
accountIndex, balance, url, isSelected = false,
|
||||||
|
}) => (
|
||||||
|
<NavLink to={url}>
|
||||||
|
<RowAccountWrapper
|
||||||
|
to={url}
|
||||||
|
isSelected={isSelected}
|
||||||
|
>
|
||||||
|
<Row column>
|
||||||
|
Account #{accountIndex + 1}
|
||||||
|
{balance ? (
|
||||||
|
<span>{balance}</span>
|
||||||
|
) : (
|
||||||
|
<span>Loading...</span>
|
||||||
|
)}
|
||||||
|
</Row>
|
||||||
|
</RowAccountWrapper>
|
||||||
|
</NavLink>
|
||||||
|
);
|
||||||
|
RowAccount.propTypes = {
|
||||||
|
accountIndex: PropTypes.number.isRequired,
|
||||||
|
url: PropTypes.string.isRequired,
|
||||||
|
balance: PropTypes.string,
|
||||||
|
isSelected: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
const AccountSelection = (props: Props): ?React$Element<string> => {
|
const AccountSelection = (props: Props): ?React$Element<string> => {
|
||||||
const selected = props.wallet.selectedDevice;
|
const selected = props.wallet.selectedDevice;
|
||||||
if (!selected) return null;
|
if (!selected) return null;
|
||||||
|
|
||||||
const { location } = props.router;
|
const { location } = props.router;
|
||||||
const urlParams = location.state;
|
const urlParams = location.state;
|
||||||
const accounts = props.accounts;
|
const { accounts } = props;
|
||||||
const baseUrl: string = urlParams.deviceInstance ? `/device/${urlParams.device}:${urlParams.deviceInstance}` : `/device/${urlParams.device}`;
|
const baseUrl: string = urlParams.deviceInstance ? `/device/${urlParams.device}:${urlParams.deviceInstance}` : `/device/${urlParams.device}`;
|
||||||
|
|
||||||
const { config } = props.localStorage;
|
const { config } = props.localStorage;
|
||||||
@ -53,7 +109,7 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsideRowAccount
|
<RowAccount
|
||||||
accountIndex={account.index}
|
accountIndex={account.index}
|
||||||
balance={balance}
|
balance={balance}
|
||||||
url={url}
|
url={url}
|
||||||
@ -70,7 +126,7 @@ 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 = (
|
||||||
<AsideRowAccount
|
<RowAccount
|
||||||
accountIndex={0}
|
accountIndex={0}
|
||||||
url={url}
|
url={url}
|
||||||
/>
|
/>
|
||||||
@ -110,7 +166,7 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
|
|||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
<div className="add-account disabled">
|
<div className="add-account disabled">
|
||||||
Add account
|
Add account
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
@ -119,7 +175,7 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
|
|||||||
discoveryStatus = (
|
discoveryStatus = (
|
||||||
<div className="discovery-status">
|
<div className="discovery-status">
|
||||||
Accounts could not be loaded
|
Accounts could not be loaded
|
||||||
<span>{ `Connect ${selected.instanceLabel} device` }</span>
|
<span>{`Connect ${selected.instanceLabel} device`}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -136,20 +192,20 @@ const AccountSelection = (props: Props): ?React$Element<string> => {
|
|||||||
if (selectedCoin) {
|
if (selectedCoin) {
|
||||||
backButton = (
|
backButton = (
|
||||||
<NavLink to={baseUrl} className={`back ${selectedCoin.network}`}>
|
<NavLink to={baseUrl} className={`back ${selectedCoin.network}`}>
|
||||||
<span className={selectedCoin.network}>{ selectedCoin.name }</span>
|
<span className={selectedCoin.network}>{selectedCoin.name}</span>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsideSection>
|
<React.Fragment>
|
||||||
{/* { backButton } */}
|
{backButton}
|
||||||
<div>
|
<div>
|
||||||
{ selectedAccounts }
|
{selectedAccounts}
|
||||||
</div>
|
</div>
|
||||||
{ discoveryStatus }
|
{discoveryStatus}
|
||||||
</AsideSection>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AccountSelection;
|
export default AccountSelection;
|
@ -1,17 +1,92 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import coins from 'constants/coins';
|
import coins from 'constants/coins';
|
||||||
import colors from 'config/colors';
|
import colors from 'config/colors';
|
||||||
|
import { FONT_SIZE } from 'config/variables';
|
||||||
|
import Icon from 'components/common/Icon';
|
||||||
import ICONS from 'config/icons';
|
import ICONS from 'config/icons';
|
||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
import { ICON_SIZE } from 'config/variables';
|
||||||
|
import { coinProp } from '../common';
|
||||||
|
import Divider from '../Divider';
|
||||||
|
import Row from '../Row';
|
||||||
|
|
||||||
import type { TrezorDevice } from 'flowtype';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
import AsideDivider from './AsideDivider';
|
|
||||||
import AsideRowCoin from './row/coin/AsideRowCoin';
|
|
||||||
|
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
|
|
||||||
|
|
||||||
|
const CoinNameWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
`;
|
||||||
|
const Logo = styled.div`
|
||||||
|
height: ${ICON_SIZE.BASE};
|
||||||
|
width: ${ICON_SIZE.BASE};
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: center;
|
||||||
|
background-size: auto ${ICON_SIZE.BASE};
|
||||||
|
background-image: url('${props => props.coinImg}');
|
||||||
|
`;
|
||||||
|
const CoinName = ({
|
||||||
|
coinImg, text,
|
||||||
|
}) => (
|
||||||
|
<CoinNameWrapper>
|
||||||
|
<Logo
|
||||||
|
coinImg={coinImg}
|
||||||
|
/>
|
||||||
|
<p>{text}</p>
|
||||||
|
</CoinNameWrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
CoinName.propTypes = {
|
||||||
|
coinImg: PropTypes.string.isRequired,
|
||||||
|
text: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
const RowCoinWrapper = styled.div`
|
||||||
|
display: block;
|
||||||
|
height: 50px;
|
||||||
|
|
||||||
|
font-size: ${FONT_SIZE.BASE};
|
||||||
|
color: ${colors.TEXT_PRIMARY};
|
||||||
|
&:hover {
|
||||||
|
background-color: ${colors.GRAY_LIGHT};
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const RowCoin = ({
|
||||||
|
coin, icon,
|
||||||
|
}) => (
|
||||||
|
<RowCoinWrapper>
|
||||||
|
<Row>
|
||||||
|
<CoinName
|
||||||
|
coinImg={coin.img}
|
||||||
|
text={coin.name}
|
||||||
|
/>
|
||||||
|
{icon && (
|
||||||
|
<Icon
|
||||||
|
icon={icon.type}
|
||||||
|
color={icon.color}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Row>
|
||||||
|
</RowCoinWrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
RowCoin.propTypes = {
|
||||||
|
...coinProp,
|
||||||
|
icon: PropTypes.shape({
|
||||||
|
type: PropTypes.string.isRequired,
|
||||||
|
color: PropTypes.string.isRequired,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CoinSelection extends Component {
|
class CoinSelection extends Component {
|
||||||
getBaseUrl() {
|
getBaseUrl() {
|
||||||
const { selectedDevice } = this.props.wallet;
|
const { selectedDevice } = this.props.wallet;
|
||||||
@ -44,7 +119,7 @@ class CoinSelection extends Component {
|
|||||||
key={item.network}
|
key={item.network}
|
||||||
to={`${this.getBaseUrl()}/network/${item.network}/account/0`}
|
to={`${this.getBaseUrl()}/network/${item.network}/account/0`}
|
||||||
>
|
>
|
||||||
<AsideRowCoin
|
<RowCoin
|
||||||
coin={{
|
coin={{
|
||||||
img: imgUrl,
|
img: imgUrl,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
@ -53,13 +128,13 @@ class CoinSelection extends Component {
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<AsideDivider
|
<Divider
|
||||||
textLeft="Other coins"
|
textLeft="Other coins"
|
||||||
textRight="(You will be redirected)"
|
textRight="(You will be redirected)"
|
||||||
/>
|
/>
|
||||||
{coins.map(coin => (
|
{coins.map(coin => (
|
||||||
<a href={coin.url}>
|
<a href={coin.url}>
|
||||||
<AsideRowCoin
|
<RowCoin
|
||||||
coin={{
|
coin={{
|
||||||
img: coin.image,
|
img: coin.image,
|
||||||
name: coin.coinName,
|
name: coin.coinName,
|
@ -5,13 +5,11 @@ import React, { Component } from 'react';
|
|||||||
import Select from 'react-select';
|
import Select from 'react-select';
|
||||||
import TrezorConnect from 'trezor-connect';
|
import TrezorConnect from 'trezor-connect';
|
||||||
|
|
||||||
import AsideDivider from './AsideDivider';
|
import AsideDivider from '../Divider';
|
||||||
|
|
||||||
import type { TrezorDevice } from 'flowtype';
|
import type { TrezorDevice } from 'flowtype';
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
|
|
||||||
import AsideSection from './AsideSection';
|
|
||||||
|
|
||||||
export const DeviceSelect = (props: Props) => {
|
export const DeviceSelect = (props: Props) => {
|
||||||
const { devices } = props;
|
const { devices } = props;
|
||||||
const { transport } = props.connect;
|
const { transport } = props.connect;
|
||||||
@ -59,10 +57,10 @@ export const DeviceSelect = (props: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className={css} onClick={!disabled ? handleOpen : null}>
|
<div className={css} onClick={!disabled ? handleOpen : null}>
|
||||||
<div className="label-container">
|
<div className="label-container">
|
||||||
<span className="label">{ selected.instanceLabel }</span>
|
<span className="label">{selected.instanceLabel}</span>
|
||||||
<span className="status">{ deviceStatus }</span>
|
<span className="status">{deviceStatus}</span>
|
||||||
</div>
|
</div>
|
||||||
{ deviceCount > 1 ? <div className="counter">{ deviceCount }</div> : null }
|
{deviceCount > 1 ? <div className="counter">{deviceCount}</div> : null}
|
||||||
<div className="arrow" />
|
<div className="arrow" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -164,11 +162,11 @@ export class DeviceDropdown extends Component<Props> {
|
|||||||
|
|
||||||
|
|
||||||
const deviceMenuButtons = deviceMenuItems.map((item, index) => (
|
const deviceMenuButtons = deviceMenuItems.map((item, index) => (
|
||||||
<div key={item.type} className={item.type} onClick={event => this.onDeviceMenuClick(item, selected)}>{ item.label}</div>
|
<div key={item.type} className={item.type} onClick={event => this.onDeviceMenuClick(item, selected)}>{item.label}</div>
|
||||||
));
|
));
|
||||||
currentDeviceMenu = deviceMenuButtons.length < 1 ? null : (
|
currentDeviceMenu = deviceMenuButtons.length < 1 ? null : (
|
||||||
<div className="device-menu">
|
<div className="device-menu">
|
||||||
{ deviceMenuButtons }
|
{deviceMenuButtons}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -199,8 +197,8 @@ export class DeviceDropdown extends Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<div key={index} className={css} onClick={() => this.props.onSelectDevice(dev)}>
|
<div key={index} className={css} onClick={() => this.props.onSelectDevice(dev)}>
|
||||||
<div className="label-container">
|
<div className="label-container">
|
||||||
<span className="label">{ dev.instanceLabel }</span>
|
<span className="label">{dev.instanceLabel}</span>
|
||||||
<span className="status">{ deviceStatus }</span>
|
<span className="status">{deviceStatus}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="forget-button"
|
className="forget-button"
|
||||||
@ -216,12 +214,12 @@ export class DeviceDropdown extends Component<Props> {
|
|||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsideSection>
|
<React.Fragment>
|
||||||
{ currentDeviceMenu }
|
{currentDeviceMenu}
|
||||||
{ deviceList.length > 1 ? <AsideDivider textLeft={'Other devices'}/> : null }
|
{deviceList.length > 1 ? <AsideDivider textLeft={'Other devices'} /> : null}
|
||||||
{ deviceList }
|
{deviceList}
|
||||||
{ webUsbButton }
|
{webUsbButton}
|
||||||
</AsideSection>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,7 +34,7 @@ const BrowserNotSupported = (props: {}): React$Element<string> => (
|
|||||||
|
|
||||||
|
|
||||||
export default (props: Props) => {
|
export default (props: Props) => {
|
||||||
const web3 = props.web3;
|
const { web3 } = props;
|
||||||
const { devices } = props;
|
const { devices } = props;
|
||||||
const { browserState, transport } = props.connect;
|
const { browserState, transport } = props.connect;
|
||||||
const localStorageError = props.localStorage.error;
|
const localStorageError = props.localStorage.error;
|
||||||
|
Loading…
Reference in New Issue
Block a user