diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2018-05-31 07:04:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 07:04:02 +0800 |
commit | dc5477be3cc62dff912a9447c702edab66200f02 (patch) | |
tree | 4c4c4293bfbc2a80812d231af9c7e22877cebfbd /ui/app/components/text-field/text-field.component.js | |
parent | 5fc24930a7febd919ec6a8f6e9c14f2bac0ef2b2 (diff) | |
parent | e59f606adb65de85484b0fb258980543967ee5e1 (diff) | |
download | tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.tar tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.tar.gz tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.tar.bz2 tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.tar.lz tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.tar.xz tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.tar.zst tangerine-wallet-browser-dc5477be3cc62dff912a9447c702edab66200f02.zip |
Merge pull request #4408 from MetaMask/v4.7.0rc2
Version 4.7.0 - rc2
Diffstat (limited to 'ui/app/components/text-field/text-field.component.js')
-rw-r--r-- | ui/app/components/text-field/text-field.component.js | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/ui/app/components/text-field/text-field.component.js b/ui/app/components/text-field/text-field.component.js new file mode 100644 index 000000000..2c72d8124 --- /dev/null +++ b/ui/app/components/text-field/text-field.component.js @@ -0,0 +1,109 @@ +import React from 'react' +import PropTypes from 'prop-types' +import { withStyles } from '@material-ui/core/styles' +import { default as MaterialTextField } from '@material-ui/core/TextField' + +const inputLabelBase = { + transform: 'none', + transition: 'none', + position: 'initial', + color: '#5b5b5b', +} + +const styles = { + materialLabel: { + '&$materialFocused': { + color: '#aeaeae', + }, + '&$materialError': { + color: '#aeaeae', + }, + fontWeight: '400', + color: '#aeaeae', + }, + materialFocused: {}, + materialUnderline: { + '&:after': { + borderBottom: '2px solid #f7861c', + }, + }, + materialError: {}, + // Non-material styles + formLabel: { + '&$formLabelFocused': { + color: '#5b5b5b', + }, + '&$materialError': { + color: '#5b5b5b', + }, + }, + formLabelFocused: {}, + inputFocused: {}, + inputRoot: { + 'label + &': { + marginTop: '8px', + }, + border: '1px solid #d2d8dd', + height: '48px', + borderRadius: '4px', + padding: '0 16px', + display: 'flex', + alignItems: 'center', + '&$inputFocused': { + border: '1px solid #2f9ae0', + }, + }, + largeInputLabel: { + ...inputLabelBase, + fontSize: '1rem', + }, + inputLabel: { + ...inputLabelBase, + fontSize: '.75rem', + }, +} + +const TextField = props => { + const { error, classes, material, startAdornment, largeLabel, ...textFieldProps } = props + + return ( + <MaterialTextField + error={Boolean(error)} + helperText={error} + InputLabelProps={{ + shrink: material ? undefined : true, + className: material ? '' : (largeLabel ? classes.largeInputLabel : classes.inputLabel), + FormLabelClasses: { + root: material ? classes.materialLabel : classes.formLabel, + focused: material ? classes.materialFocused : classes.formLabelFocused, + error: classes.materialError, + }, + }} + InputProps={{ + startAdornment: startAdornment || undefined, + disableUnderline: !material, + classes: { + root: material ? '' : classes.inputRoot, + input: material ? '' : classes.input, + underline: material ? classes.materialUnderline : '', + focused: material ? '' : classes.inputFocused, + }, + }} + {...textFieldProps} + /> + ) +} + +TextField.defaultProps = { + error: null, +} + +TextField.propTypes = { + error: PropTypes.string, + classes: PropTypes.object, + material: PropTypes.bool, + startAdornment: PropTypes.element, + largeLabel: PropTypes.bool, +} + +export default withStyles(styles)(TextField) |