mirror of https://github.com/trezor/trezor-wallet
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
|
@ -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;
|
Loading…
Reference in new issue