1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix text field labels of first time flow. Add text fields to storybook (#4389)

This commit is contained in:
Alexander Tseung 2018-05-29 09:35:18 -05:00 committed by GitHub
parent c665fe191d
commit d1f5d8ccc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 44 deletions

View File

@ -143,6 +143,7 @@ class CreatePasswordScreen extends Component {
autoComplete="new-password" autoComplete="new-password"
margin="normal" margin="normal"
fullWidth fullWidth
largeLabel
/> />
<TextField <TextField
id="confirm-password" id="confirm-password"
@ -155,6 +156,7 @@ class CreatePasswordScreen extends Component {
autoComplete="confirm-password" autoComplete="confirm-password"
margin="normal" margin="normal"
fullWidth fullWidth
largeLabel
/> />
<button <button
className="first-time-flow__button" className="first-time-flow__button"

View File

@ -146,6 +146,7 @@ class ImportSeedPhraseScreen extends Component {
error={passwordError} error={passwordError}
autoComplete="new-password" autoComplete="new-password"
margin="normal" margin="normal"
largeLabel
/> />
<TextField <TextField
id="confirm-password" id="confirm-password"
@ -157,6 +158,7 @@ class ImportSeedPhraseScreen extends Component {
error={confirmPasswordError} error={confirmPasswordError}
autoComplete="confirm-password" autoComplete="confirm-password"
margin="normal" margin="normal"
largeLabel
/> />
<button <button
className="first-time-flow__button" className="first-time-flow__button"

View File

@ -1,8 +1,15 @@
import React, { Component } from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles' import { withStyles } from '@material-ui/core/styles'
import { default as MaterialTextField } from '@material-ui/core/TextField' import { default as MaterialTextField } from '@material-ui/core/TextField'
const inputLabelBase = {
transform: 'none',
transition: 'none',
position: 'initial',
color: '#5b5b5b',
}
const styles = { const styles = {
materialLabel: { materialLabel: {
'&$materialFocused': { '&$materialFocused': {
@ -46,29 +53,18 @@ const styles = {
border: '1px solid #2f9ae0', border: '1px solid #2f9ae0',
}, },
}, },
largeInputLabel: {
...inputLabelBase,
fontSize: '1rem',
},
inputLabel: { inputLabel: {
...inputLabelBase,
fontSize: '.75rem', fontSize: '.75rem',
transform: 'none',
transition: 'none',
position: 'initial',
color: '#5b5b5b',
}, },
} }
class TextField extends Component { const TextField = props => {
static defaultProps = { const { error, classes, material, startAdornment, largeLabel, ...textFieldProps } = props
error: null,
}
static propTypes = {
error: PropTypes.string,
classes: PropTypes.object,
material: PropTypes.bool,
startAdornment: PropTypes.element,
}
render () {
const { error, classes, material, startAdornment, ...textFieldProps } = this.props
return ( return (
<MaterialTextField <MaterialTextField
@ -76,7 +72,7 @@ class TextField extends Component {
helperText={error} helperText={error}
InputLabelProps={{ InputLabelProps={{
shrink: material ? undefined : true, shrink: material ? undefined : true,
className: material ? '' : classes.inputLabel, className: material ? '' : (largeLabel ? classes.largeInputLabel : classes.inputLabel),
FormLabelClasses: { FormLabelClasses: {
root: material ? classes.materialLabel : classes.formLabel, root: material ? classes.materialLabel : classes.formLabel,
focused: material ? classes.materialFocused : classes.formLabelFocused, focused: material ? classes.materialFocused : classes.formLabelFocused,
@ -96,7 +92,18 @@ class TextField extends Component {
{...textFieldProps} {...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) export default withStyles(styles)(TextField)

View File

@ -22,3 +22,32 @@ storiesOf('TextField', module)
error="Invalid value" error="Invalid value"
/> />
) )
.add('Mascara text', () =>
<TextField
label="Text"
type="text"
largeLabel
/>
)
.add('Material text', () =>
<TextField
label="Text"
type="text"
material
/>
)
.add('Material password', () =>
<TextField
label="Password"
type="password"
material
/>
)
.add('Material error', () =>
<TextField
type="text"
label="Name"
error="Invalid value"
material
/>
)