1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-26 17:08:07 +00:00

Add error text under the input

This commit is contained in:
Vasek Mlejnsky 2018-08-30 15:19:58 +02:00
parent 6d9cdfcabb
commit 797b66d9d5

View File

@ -49,7 +49,19 @@ const StyledInput = styled.input`
} }
`; `;
const Wrapper = styled.div``; const Wrapper = styled.div`
display: flex;
flex-direction: column;
justify-content: flex-start;
`;
const InputWrapper = styled.div``;
const ErrorLabel = styled.span`
margin-top: 10px;
font-size: ${FONT_SIZE.SMALLER};
color: ${colors.ERROR_PRIMARY};
`;
const StyledIcon = styled(Icon)` const StyledIcon = styled(Icon)`
position: absolute; position: absolute;
@ -57,9 +69,10 @@ const StyledIcon = styled(Icon)`
`; `;
const Input = ({ const Input = ({
type, autoComplete, autoCorrect, autoCapitalize, spellCheck, value, onChange, isSuccess, isWarning, isError, type, autoComplete, autoCorrect, autoCapitalize, spellCheck, value, onChange, isSuccess, isWarning, isError, errorText,
}) => ( }) => (
<Wrapper> <Wrapper>
<InputWrapper>
<StyledInput <StyledInput
type={type} type={type}
autoComplete={autoComplete} autoComplete={autoComplete}
@ -90,6 +103,12 @@ const Input = ({
color={colors.SUCCESS_PRIMARY} color={colors.SUCCESS_PRIMARY}
/> />
)} )}
</InputWrapper>
{isError && (
<ErrorLabel>
{errorText}
</ErrorLabel>
)}
</Wrapper> </Wrapper>
); );
@ -104,6 +123,7 @@ Input.propTypes = {
isSuccess: PropTypes.bool, isSuccess: PropTypes.bool,
isWarning: PropTypes.bool, isWarning: PropTypes.bool,
isError: PropTypes.bool, isError: PropTypes.bool,
errorText: PropTypes.string,
}; };
export default Input; export default Input;