mirror of https://github.com/trezor/trezor-wallet
Merge branch 'styled-components-refactor' of https://github.com/satoshilabs/trezor-wallet into styled-components-refactor
commit
db2008811d
@ -0,0 +1,18 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const Wrapper = styled.p`
|
||||||
|
`;
|
||||||
|
|
||||||
|
const P = ({ children, className }) => (
|
||||||
|
<Wrapper className={className}>{children}</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
P.propTypes = {
|
||||||
|
className: PropTypes.string,
|
||||||
|
children: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default P;
|
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1,22 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
const Wrapper = styled.div``;
|
||||||
|
|
||||||
|
const Img = styled.img`
|
||||||
|
width: ${props => (props.model === 'T' ? '17px' : '13px')};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const TrezorImage = ({ model }) => (
|
||||||
|
<Wrapper>
|
||||||
|
<Img model={model} src={model === 'T' ? './images/trezor-T.png' : './images/trezor-1.png'} />
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
TrezorImage.propTypes = {
|
||||||
|
model: PropTypes.string,
|
||||||
|
status: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TrezorImage;
|
@ -0,0 +1,88 @@
|
|||||||
|
import colors from 'js/config/colors';
|
||||||
|
|
||||||
|
const getStatus = (device) => {
|
||||||
|
let status = 'connected';
|
||||||
|
if (!device.connected) {
|
||||||
|
status = 'disconnected';
|
||||||
|
} else if (!device.available) {
|
||||||
|
status = 'unavailable';
|
||||||
|
} else if (device.type === 'acquired') {
|
||||||
|
if (device.status === 'occupied') {
|
||||||
|
status = 'used-in-other-window';
|
||||||
|
}
|
||||||
|
} else if (device.type === 'unacquired') {
|
||||||
|
status = 'unacquired';
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatusName = (deviceStatus) => {
|
||||||
|
let statusName;
|
||||||
|
switch (deviceStatus) {
|
||||||
|
case 'used-in-other-window':
|
||||||
|
statusName = 'Used in other window';
|
||||||
|
break;
|
||||||
|
case 'connected':
|
||||||
|
statusName = 'Connected';
|
||||||
|
break;
|
||||||
|
case 'disconnected':
|
||||||
|
statusName = 'Disconnected';
|
||||||
|
break;
|
||||||
|
case 'unacquired':
|
||||||
|
statusName = 'Used in other window';
|
||||||
|
break;
|
||||||
|
case 'unavailable':
|
||||||
|
statusName = 'Unavailable';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
statusName = 'Status unknown';
|
||||||
|
}
|
||||||
|
return statusName;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isWebUSB = transport => !!((transport && transport.version.indexOf('webusb') >= 0));
|
||||||
|
|
||||||
|
const isDisabled = (selectedDevice, devices, transport) => (devices.length < 1 && !isWebUSB(transport)) || (devices.length === 1 && !selectedDevice.features && !isWebUSB(transport));
|
||||||
|
|
||||||
|
const getVersion = (device) => {
|
||||||
|
let version;
|
||||||
|
if (device.features && device.features.major_version > 1) {
|
||||||
|
version = 'T';
|
||||||
|
} else {
|
||||||
|
version = '1';
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatusColor = (deviceStatus) => {
|
||||||
|
let color;
|
||||||
|
switch (deviceStatus) {
|
||||||
|
case 'used-in-other-window':
|
||||||
|
color = colors.WARNING_PRIMARY;
|
||||||
|
break;
|
||||||
|
case 'connected':
|
||||||
|
color = colors.GREEN_PRIMARY;
|
||||||
|
break;
|
||||||
|
case 'unacquired':
|
||||||
|
color = colors.WARNING_PRIMARY;
|
||||||
|
break;
|
||||||
|
case 'disconnected':
|
||||||
|
color = colors.ERROR_PRIMARY;
|
||||||
|
break;
|
||||||
|
case 'unavailable':
|
||||||
|
color = colors.ERROR_PRIMARY;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = colors.TEXT_PRIMARY;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
getStatus,
|
||||||
|
isDisabled,
|
||||||
|
getStatusName,
|
||||||
|
getVersion,
|
||||||
|
getStatusColor,
|
||||||
|
};
|
@ -0,0 +1,156 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import styled, { css } from 'styled-components';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import Icon from 'components/Icon';
|
||||||
|
import icons from 'config/icons';
|
||||||
|
import { getStatusColor, getStatusName } from 'utils/device';
|
||||||
|
import TrezorImage from 'components/TrezorImage';
|
||||||
|
|
||||||
|
import colors from 'config/colors';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
position: relative;
|
||||||
|
height: 64px;
|
||||||
|
width: 320px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background: ${colors.WHITE};
|
||||||
|
border-radius: 4px 0 0 0;
|
||||||
|
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
|
||||||
|
|
||||||
|
${props => props.isOpen && css`
|
||||||
|
box-shadow: none;
|
||||||
|
`}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ClickWrapper = styled.div`
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
padding-left: 25px;
|
||||||
|
height: 100%;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
${props => props.disabled && css`
|
||||||
|
cursor: initial;
|
||||||
|
`}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const LabelWrapper = styled.div`
|
||||||
|
flex: 1;
|
||||||
|
padding-left: 18px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Name = styled.div`
|
||||||
|
display: block;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: no-wrap;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 14px;
|
||||||
|
color: ${colors.TEXT_PRIMARY};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Status = styled.div`
|
||||||
|
display: block;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-size: 12px;
|
||||||
|
color: ${colors.TEXT_SECONDARY};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Counter = styled.div`
|
||||||
|
border: 1px solid ${colors.DIVIDER};
|
||||||
|
border-radius: 50%;
|
||||||
|
color: ${colors.TEXT_SECONDARY};
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
line-height: 22px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 11px;
|
||||||
|
margin-right: 8px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const IconWrapper = styled.div`
|
||||||
|
padding-right: 25px;
|
||||||
|
display: flex;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ImageWrapper = styled.div`
|
||||||
|
position: relative;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Dot = styled.div`
|
||||||
|
border: 2px solid ${colors.WHITE};
|
||||||
|
border-radius: 50%;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 10;
|
||||||
|
background: ${props => props.color};
|
||||||
|
top: -4px;
|
||||||
|
right: -3px;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
class DeviceHeader extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
clicked: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClick() {
|
||||||
|
this.setState({ clicked: true });
|
||||||
|
if (!this.props.disabled) {
|
||||||
|
this.props.handleOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {
|
||||||
|
status, label, deviceCount, isOpen, trezorModel, disabled,
|
||||||
|
} = this.props;
|
||||||
|
return (
|
||||||
|
<Wrapper isOpen={isOpen}>
|
||||||
|
<ClickWrapper disabled={disabled} onClick={() => this.handleClick()}>
|
||||||
|
<ImageWrapper>
|
||||||
|
<Dot color={getStatusColor(status)} />
|
||||||
|
<TrezorImage model={trezorModel} />
|
||||||
|
</ImageWrapper>
|
||||||
|
<LabelWrapper>
|
||||||
|
<Name>{label}</Name>
|
||||||
|
<Status>{getStatusName(status)}</Status>
|
||||||
|
</LabelWrapper>
|
||||||
|
<IconWrapper>
|
||||||
|
{deviceCount > 1 && <Counter>{deviceCount}</Counter>}
|
||||||
|
{!disabled && (
|
||||||
|
<Icon
|
||||||
|
canAnimate={this.state.clicked === true}
|
||||||
|
isActive={isOpen}
|
||||||
|
size={25}
|
||||||
|
color={colors.TEXT_SECONDARY}
|
||||||
|
icon={icons.ARROW_DOWN}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</IconWrapper>
|
||||||
|
</ClickWrapper>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DeviceHeader.propTypes = {
|
||||||
|
deviceCount: PropTypes.number,
|
||||||
|
disabled: PropTypes.bool,
|
||||||
|
isOpen: PropTypes.bool,
|
||||||
|
trezorModel: PropTypes.string.isRequired,
|
||||||
|
handleOpen: PropTypes.func.isRequired,
|
||||||
|
status: PropTypes.string.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DeviceHeader;
|
@ -1,17 +1,41 @@
|
|||||||
/* @flow */
|
import styled from 'styled-components';
|
||||||
import { H2 } from 'components/Heading';
|
import { H2 } from 'components/Heading';
|
||||||
|
import Button from 'components/Button';
|
||||||
|
import P from 'components/P';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Row = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const A = styled.a``;
|
||||||
|
|
||||||
|
const StyledP = styled(P)`
|
||||||
|
margin: 20px 50px;
|
||||||
|
display: block;
|
||||||
|
`;
|
||||||
|
|
||||||
const Initialize = () => (
|
const Initialize = () => (
|
||||||
<section className="device-settings">
|
<Wrapper>
|
||||||
<div className="row">
|
<Row>
|
||||||
<H2>Your device is in not initialized</H2>
|
<H2>Your device is in not initialized</H2>
|
||||||
<p>Please use Bitcoin wallet interface to start initialization process</p>
|
<StyledP>Please use Bitcoin wallet interface to start initialization process</StyledP>
|
||||||
<a className="button" href="https://wallet.trezor.io/">Take me to the Bitcoin wallet</a>
|
<A href="https://wallet.trezor.io/">
|
||||||
</div>
|
<Button text="Take me to the Bitcoin wallet" />
|
||||||
</section>
|
</A>
|
||||||
|
</Row>
|
||||||
|
</Wrapper>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default connect(null, null)(Initialize);
|
export default connect(null, null)(Initialize);
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
.acquire {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background: @color_white;
|
|
||||||
|
|
||||||
.warning {
|
|
||||||
background: @color_info_secondary;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
padding: 26px 39px 26px 80px;
|
|
||||||
|
|
||||||
div {
|
|
||||||
flex: 1;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
color: @color_info_primary;
|
|
||||||
font-size: 14px;
|
|
||||||
-webkit-font-smoothing: auto;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
padding: 0px;
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
.icomoon-info;
|
|
||||||
position: absolute;
|
|
||||||
top: -7px;
|
|
||||||
left: -32px;
|
|
||||||
font-size: 32px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
color: @color_info_primary;
|
|
||||||
font-size: 12px;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
html, body {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: relative;
|
|
||||||
background-color: @color_body;
|
|
||||||
font-family: @font-default;
|
|
||||||
font-weight: 400;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app {
|
|
||||||
position: relative;
|
|
||||||
min-height: 100vh;
|
|
||||||
min-width: 720px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
&.resized {
|
|
||||||
// to make sure that unpacked coin menu will not overflow main container
|
|
||||||
// 512 dropdown height + 50 header + 30 margin + 64 topnav height
|
|
||||||
min-height: 680px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 1170px;
|
|
||||||
margin: 0 auto;
|
|
||||||
flex: 1;
|
|
||||||
background: @color_main;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
border-radius: 4px 4px 0px 0px;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-top: 32px;
|
|
||||||
|
|
||||||
@media screen and (max-width: 1170px) {
|
|
||||||
border-radius: 0px;
|
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
.history {
|
|
||||||
flex: 1;
|
|
||||||
padding: 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
border: 1px solid red;
|
|
||||||
|
|
||||||
.history-transaction {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.amount, .time, .address {
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.in {
|
|
||||||
color: green;
|
|
||||||
.amount {
|
|
||||||
&:before {
|
|
||||||
content: '+'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.out {
|
|
||||||
color: red;
|
|
||||||
.amount {
|
|
||||||
&:before {
|
|
||||||
content: '-'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
.log {
|
|
||||||
position: relative;
|
|
||||||
color: @color_info_primary;
|
|
||||||
background: @color_info_secondary;
|
|
||||||
padding: 24px 48px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
.log-close {
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
right: 0;
|
|
||||||
padding: 12px;
|
|
||||||
color: inherit;
|
|
||||||
transition: opacity 0.3s;
|
|
||||||
|
|
||||||
&:after {
|
|
||||||
.icomoon-close;
|
|
||||||
}
|
|
||||||
&:active,
|
|
||||||
&:hover {
|
|
||||||
opacity: 0.6;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: bold;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
padding: 0px;
|
|
||||||
margin: 2px 0px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea {
|
|
||||||
width: 100%;
|
|
||||||
height: 200px;
|
|
||||||
min-height: 200px;
|
|
||||||
resize: vertical;
|
|
||||||
font-size: 10px;
|
|
||||||
&:focus {
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue