mirror of
https://github.com/trezor/trezor-wallet
synced 2025-07-01 20:32:37 +00:00
auto generated clickable coinlogos in dashboard
This commit is contained in:
parent
dd668a1b72
commit
25f1d4efcb
26
src/views/Wallet/views/Dashboard/Container.js
Normal file
26
src/views/Wallet/views/Dashboard/Container.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/* @flow */
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import type { MapStateToProps } from 'react-redux';
|
||||||
|
import type { State } from 'flowtype';
|
||||||
|
import Dashboard from "./index";
|
||||||
|
|
||||||
|
type OwnProps = {};
|
||||||
|
|
||||||
|
type StateProps = {
|
||||||
|
localStorage: $ElementType<State, 'localStorage'>,
|
||||||
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Props = StateProps;
|
||||||
|
|
||||||
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (
|
||||||
|
state: State
|
||||||
|
): StateProps => ({
|
||||||
|
localStorage: state.localStorage,
|
||||||
|
wallet: state.wallet,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
null
|
||||||
|
)(Dashboard);
|
@ -1,13 +1,13 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import Content from 'views/Wallet/components/Content';
|
import Content from 'views/Wallet/components/Content';
|
||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
import { CoinLogo, H4, P } from 'trezor-ui-components';
|
import { CoinLogo, H4, P } from 'trezor-ui-components';
|
||||||
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import l10nMessages from './index.messages';
|
import l10nMessages from './index.messages';
|
||||||
|
import { Props } from './Container';
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -30,17 +30,12 @@ const StyledP = styled(P)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Overlay = styled.div`
|
const Coins = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
flex-wrap: wrap;
|
||||||
height: 40px;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
opacity: 0.2;
|
|
||||||
background: white;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledCoinLogo = styled(CoinLogo)`
|
const StyledNavLink = styled(NavLink)`
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
@ -48,7 +43,27 @@ const StyledCoinLogo = styled(CoinLogo)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Dashboard = () => (
|
const StyledCoinLogo = styled(CoinLogo)`
|
||||||
|
opacity: 0.7;
|
||||||
|
transition: opacity 0.2s ease-in-out;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const getBaseUrl = device => {
|
||||||
|
let baseUrl = '';
|
||||||
|
if (device && device.features) {
|
||||||
|
baseUrl = `/device/${device.features.device_id}`;
|
||||||
|
if (device.instance) {
|
||||||
|
baseUrl += `:${device.instance}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseUrl;
|
||||||
|
};
|
||||||
|
const Dashboard = (props: Props) => (
|
||||||
<Content>
|
<Content>
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Row data-test="Dashboard__page__content">
|
<Row data-test="Dashboard__page__content">
|
||||||
@ -58,16 +73,21 @@ const Dashboard = () => (
|
|||||||
<StyledP>
|
<StyledP>
|
||||||
<FormattedMessage {...l10nMessages.TR_YOU_WILL_GAIN_ACCESS} />
|
<FormattedMessage {...l10nMessages.TR_YOU_WILL_GAIN_ACCESS} />
|
||||||
</StyledP>
|
</StyledP>
|
||||||
<Overlay>
|
<Coins>
|
||||||
<StyledCoinLogo network="eth" height={32} />
|
{props.localStorage.config.networks.map(network => (
|
||||||
<StyledCoinLogo network="xrp" height={32} />
|
<StyledNavLink
|
||||||
</Overlay>
|
key={network.shortcut}
|
||||||
|
to={`${getBaseUrl(props.wallet.selectedDevice)}/network/${
|
||||||
|
network.shortcut
|
||||||
|
}/account/0`}
|
||||||
|
>
|
||||||
|
<StyledCoinLogo network={network.shortcut} height={32} />
|
||||||
|
</StyledNavLink>
|
||||||
|
))}
|
||||||
|
</Coins>
|
||||||
</Row>
|
</Row>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
</Content>
|
</Content>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default connect(
|
export default Dashboard
|
||||||
null,
|
|
||||||
null
|
|
||||||
)(Dashboard);
|
|
@ -23,7 +23,7 @@ import AccountSend from 'views/Wallet/views/Account/Send';
|
|||||||
import AccountReceive from 'views/Wallet/views/Account/Receive';
|
import AccountReceive from 'views/Wallet/views/Account/Receive';
|
||||||
import AccountSignVerify from 'views/Wallet/views/Account/SignVerify/Container';
|
import AccountSignVerify from 'views/Wallet/views/Account/SignVerify/Container';
|
||||||
|
|
||||||
import WalletDashboard from 'views/Wallet/views/Dashboard';
|
import WalletDashboard from 'views/Wallet/views/Dashboard/Container';
|
||||||
import WalletDeviceSettings from 'views/Wallet/views/DeviceSettings';
|
import WalletDeviceSettings from 'views/Wallet/views/DeviceSettings';
|
||||||
import WalletSettings from 'views/Wallet/views/WalletSettings/Container';
|
import WalletSettings from 'views/Wallet/views/WalletSettings/Container';
|
||||||
import WalletBootloader from 'views/Wallet/views/Bootloader';
|
import WalletBootloader from 'views/Wallet/views/Bootloader';
|
||||||
|
Loading…
Reference in New Issue
Block a user