mirror of https://github.com/trezor/trezor-wallet
Merge pull request #134 from trezor/feature/change-passphrase
Feature/change passphrasepull/147/head
commit
f258f1b125
@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import colors from 'config/colors';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const SvgWrapper = styled.svg`
|
||||
:hover {
|
||||
path {
|
||||
fill: ${props => props.hoverColor}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const Path = styled.path`
|
||||
fill: ${props => props.color};
|
||||
`;
|
||||
|
||||
export const HIDDEN = 'M23.9,13.6l-4-11C19.8,2.3,19.4,2,19,2h-3c-0.6,0-1,0.4-1,1s0.4,1,1,1h2.3l3.3,9H14h-4H2.4l3.3-9H8 c0.6,0,1-0.4,1-1S8.6,2,8,2H5C4.6,2,4.2,2.3,4.1,2.7l-4,11C0,13.7,0,13.9,0,14c0,0,0,0,0,0v0c0,0,0,0,0,0v5c0,1.7,1.3,3,3,3h5 c1.7,0,3-1.3,3-3v-4h2v4c0,1.7,1.3,3,3,3h5c1.7,0,3-1.3,3-3v-5c0,0,0,0,0,0v0c0,0,0,0,0,0C24,13.9,24,13.7,23.9,13.6z';
|
||||
export const STANDARD = 'M23,4H4H3C2.449,4,2,3.551,2,3s0.449-1,1-1h15v1h2V1c0-0.552-0.448-1-1-1H3C1.343,0,0,1.343,0,3v17 c0,2.209,1.791,4,4,4h19c0.552,0,1-0.448,1-1V5C24,4.448,23.552,4,23,4z M18,16c-1.105,0-2-0.895-2-2c0-1.105,0.895-2,2-2 s2,0.895,2,2C20,15.105,19.105,16,18,16z';
|
||||
|
||||
const Icon = ({
|
||||
type = 'standard',
|
||||
size = 24,
|
||||
color = colors.TEXT_SECONDARY,
|
||||
hoverColor,
|
||||
onClick,
|
||||
}) => (
|
||||
<SvgWrapper
|
||||
hoverColor={hoverColor}
|
||||
width={`${size}`}
|
||||
height={`${size}`}
|
||||
viewBox="-12 -12 48 48"
|
||||
onClick={onClick}
|
||||
>
|
||||
<Path
|
||||
key={type}
|
||||
color={color}
|
||||
d={type === 'hidden' ? HIDDEN : STANDARD}
|
||||
/>
|
||||
</SvgWrapper>
|
||||
);
|
||||
|
||||
Icon.propTypes = {
|
||||
type: PropTypes.string,
|
||||
size: PropTypes.number,
|
||||
color: PropTypes.string,
|
||||
hoverColor: PropTypes.string,
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
|
||||
export default Icon;
|
@ -0,0 +1,139 @@
|
||||
/* @flow */
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { H3 } from 'components/Heading';
|
||||
import P from 'components/Paragraph';
|
||||
import Button from 'components/Button';
|
||||
import Tooltip from 'components/Tooltip';
|
||||
import Icon from 'components/Icon';
|
||||
import Link from 'components/Link';
|
||||
import colors from 'config/colors';
|
||||
import icons from 'config/icons';
|
||||
import WalletTypeIcon from 'components/images/WalletType';
|
||||
|
||||
import type { Props } from 'components/modals/index';
|
||||
|
||||
const Wrapper = styled.div`
|
||||
width: 360px;
|
||||
padding: 24px 48px;
|
||||
`;
|
||||
|
||||
const StyledLink = styled(Link)`
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 15px;
|
||||
`;
|
||||
|
||||
const StyledButton = styled(Button)`
|
||||
margin: 0 0 10px 0;
|
||||
`;
|
||||
|
||||
const StyledTooltip = styled(Tooltip)`
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: 1px;
|
||||
`;
|
||||
|
||||
const StyledIcon = styled(Icon)`
|
||||
position: relative;
|
||||
top: -1px;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
`;
|
||||
|
||||
const Row = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px 0;
|
||||
`;
|
||||
|
||||
const Span = styled.div`
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
`;
|
||||
|
||||
const Divider = styled.div`
|
||||
margin: 20px 0;
|
||||
border-top: 1px solid ${colors.DIVIDER};
|
||||
`;
|
||||
|
||||
class WalletType extends Component<Props> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.keyboardHandler = this.keyboardHandler.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
window.addEventListener('keydown', this.keyboardHandler, false);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
window.removeEventListener('keydown', this.keyboardHandler, false);
|
||||
}
|
||||
|
||||
keyboardHandler(event: KeyboardEvent): void {
|
||||
if (event.keyCode === 13) {
|
||||
event.preventDefault();
|
||||
this.changeType(false);
|
||||
}
|
||||
}
|
||||
|
||||
keyboardHandler: (event: KeyboardEvent) => void;
|
||||
|
||||
changeType(hidden: boolean) {
|
||||
const { modal } = this.props;
|
||||
if (!modal.opened) return;
|
||||
this.props.modalActions.onWalletTypeRequest(modal.device, hidden);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.props.modal.opened) return null;
|
||||
const { device } = this.props.modal;
|
||||
const { onCancel } = this.props.modalActions;
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
{ device.state && (
|
||||
<StyledLink onClick={onCancel}>
|
||||
<Icon size={20} color={colors.TEXT_SECONDARY} icon={icons.CLOSE} />
|
||||
</StyledLink>
|
||||
)}
|
||||
<H3>RequestWalletType for { device.instanceLabel }?</H3>
|
||||
<Row>
|
||||
<Span>
|
||||
<WalletTypeIcon type="standard" size={24} color={colors.TEXT_SECONDARY} />
|
||||
Standard Wallet
|
||||
</Span>
|
||||
<P isSmaller>Continue to access your standard wallet.</P>
|
||||
<StyledButton onClick={() => this.changeType(false)}>Go to your standard wallet</StyledButton>
|
||||
<Divider />
|
||||
<Span>
|
||||
<WalletTypeIcon type="hidden" size={24} color={colors.TEXT_SECONDARY} />
|
||||
Hidden Wallet
|
||||
<StyledTooltip
|
||||
maxWidth={285}
|
||||
placement="top"
|
||||
content="Passphrase is an optional feature of the Trezor device that is recommended for advanced users only. It is a word or a sentence of your choice. Its main purpose is to access a hidden wallet."
|
||||
readMoreLink="https://wiki.trezor.io/Passphrase"
|
||||
>
|
||||
<StyledIcon
|
||||
icon={icons.HELP}
|
||||
color={colors.TEXT_SECONDARY}
|
||||
size={24}
|
||||
/>
|
||||
</StyledTooltip>
|
||||
</Span>
|
||||
<P isSmaller>You will be asked to enter your passphrase to unlock your hidden wallet.</P>
|
||||
<StyledButton isWhite onClick={() => this.changeType(true)}>Go to your hidden wallet</StyledButton>
|
||||
</Row>
|
||||
</Wrapper>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default WalletType;
|
Loading…
Reference in new issue