1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-11 17:48:09 +00:00

Add trezor action to textarea

This commit is contained in:
Vladimir Volek 2018-11-05 16:45:45 +01:00
parent 12f094a595
commit bc0238403b
4 changed files with 48 additions and 69 deletions

View File

@ -123,7 +123,6 @@ export const verify = (
} }
}; };
export const clear = (): ThunkAction => (dispatch: Dispatch): void => { export const clear = (): ThunkAction => (dispatch: Dispatch): void => {
dispatch({ dispatch({
type: SIGN_VERIFY.CLEAR, type: SIGN_VERIFY.CLEAR,

View File

@ -7,6 +7,7 @@ import { FONT_SIZE, FONT_WEIGHT, FONT_FAMILY } from 'config/variables';
const Wrapper = styled.div` const Wrapper = styled.div`
width: 100%; width: 100%;
position: relative;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
@ -83,7 +84,7 @@ const StyledTextarea = styled(Textarea)`
} }
} }
${props => props.isInTrezorAction && css` ${props => props.trezorAction && css`
z-index: 10001; /* bigger than modal container */ z-index: 10001; /* bigger than modal container */
border-color: ${colors.WHITE}; border-color: ${colors.WHITE};
border-width: 2px; border-width: 2px;
@ -115,6 +116,32 @@ const getColor = (inputState) => {
return color; return color;
}; };
const TrezorAction = styled.div`
align-items: center;
margin: 0px 10px;
padding: 0 14px 0 5px;
position: absolute;
background: black;
bottom: -25px;
color: ${colors.WHITE};
border-radius: 5px;
line-height: 37px;
z-index: 10001;
transform: translate(-1px, -1px);
`;
const ArrowUp = styled.div`
position: absolute;
top: -9px;
left: 12px;
width: 0;
height: 0;
border-left: 9px solid transparent;
border-right: 9px solid transparent;
border-bottom: 9px solid black;
z-index: 10001;
`;
const TextArea = ({ const TextArea = ({
className, className,
placeholder = '', placeholder = '',
@ -130,11 +157,9 @@ const TextArea = ({
maxRows, maxRows,
state = '', state = '',
bottomText = '', bottomText = '',
isInTrezorAction = false, trezorAction = null,
}) => ( }) => (
<Wrapper <Wrapper className={className}>
className={className}
>
{topLabel && ( {topLabel && (
<TopLabel>{topLabel}</TopLabel> <TopLabel>{topLabel}</TopLabel>
)} )}
@ -151,8 +176,13 @@ const TextArea = ({
placeholder={placeholder} placeholder={placeholder}
onChange={onChange} onChange={onChange}
borderColor={getColor(state)} borderColor={getColor(state)}
isInTrezorAction={isInTrezorAction} trezorAction={trezorAction}
/> />
{trezorAction && (
<TrezorAction>
<ArrowUp />{trezorAction}
</TrezorAction>
)}
{bottomText && ( {bottomText && (
<BottomText <BottomText
color={getColor(state)} color={getColor(state)}
@ -178,7 +208,7 @@ TextArea.propTypes = {
topLabel: PropTypes.node, topLabel: PropTypes.node,
state: PropTypes.string, state: PropTypes.string,
bottomText: PropTypes.string, bottomText: PropTypes.string,
isInTrezorAction: PropTypes.bool, trezorAction: PropTypes.node,
}; };
export default TextArea; export default TextArea;

View File

@ -1,21 +0,0 @@
import React from 'react';
import colors from 'config/colors';
import ICONS from 'config/icons';
import Icon from 'components/Icon';
import styled from 'styled-components';
const Wrapper = styled.div`
display: flex;
`;
const Tooltip = () => (
<Wrapper>
<Icon
icon={ICONS.T1}
color={colors.WHITE}
/>
Check address on your Trezor
</Wrapper>
);
export default Tooltip;

View File

@ -53,40 +53,13 @@ const Label = styled.div`
padding: 5px 0px 10px 0; padding: 5px 0px 10px 0;
`; `;
const ConfirmTooltip = styled.div`
position: absolute;
z-index: 10001;
padding: 3px 5px;
display: flex;
justify-content: center;
align-items: center;
min-width: 250px;
background: black;
border: 0;
color: ${colors.WHITE};
border-radius: 5px;
transform: translate(-1px, -1px);
`;
const ArrowUp = styled.div`
position: absolute;
top: -9px;
left: 20px;
width: 0;
height: 0;
border-left: 9px solid transparent;
border-right: 9px solid transparent;
border-bottom: 9px solid black;
z-index: 10001;
`;
const StyledIcon = styled(Icon)` const StyledIcon = styled(Icon)`
position: relative; position: relative;
left: 0; left: 0;
`; `;
const ConfirmText = styled.div` const ActionWrapper = styled.div`
color: white; white-space: nowrap
`; `;
type State = { type State = {
@ -169,18 +142,16 @@ class SignVerify extends Component<Props, State> {
rows={4} rows={4}
maxRows={4} maxRows={4}
maxLength="255" maxLength="255"
isInTrezorAction={this.props.isSignProgress} trezorAction={this.props.isSignProgress ? (
/> <ActionWrapper>
{this.props.isSignProgress && (
<ConfirmTooltip>
<ArrowUp />
<StyledIcon <StyledIcon
icon={ICONS.T1} icon={ICONS.T1}
color={colors.WHITE} color={colors.WHITE}
/> />
<ConfirmText>Check address on your Trezor</ConfirmText> Check address on your Trezor
</ConfirmTooltip> </ActionWrapper>
)} ) : null}
/>
</Row> </Row>
<Row> <Row>
<Label>Signature</Label> <Label>Signature</Label>