1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +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"
margin="normal"
fullWidth
largeLabel
/>
<TextField
id="confirm-password"
@ -155,6 +156,7 @@ class CreatePasswordScreen extends Component {
autoComplete="confirm-password"
margin="normal"
fullWidth
largeLabel
/>
<button
className="first-time-flow__button"

View File

@ -146,6 +146,7 @@ class ImportSeedPhraseScreen extends Component {
error={passwordError}
autoComplete="new-password"
margin="normal"
largeLabel
/>
<TextField
id="confirm-password"
@ -157,6 +158,7 @@ class ImportSeedPhraseScreen extends Component {
error={confirmPasswordError}
autoComplete="confirm-password"
margin="normal"
largeLabel
/>
<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 { 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': {
@ -46,29 +53,18 @@ const styles = {
border: '1px solid #2f9ae0',
},
},
largeInputLabel: {
...inputLabelBase,
fontSize: '1rem',
},
inputLabel: {
...inputLabelBase,
fontSize: '.75rem',
transform: 'none',
transition: 'none',
position: 'initial',
color: '#5b5b5b',
},
}
class TextField extends Component {
static defaultProps = {
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
const TextField = props => {
const { error, classes, material, startAdornment, largeLabel, ...textFieldProps } = props
return (
<MaterialTextField
@ -76,7 +72,7 @@ class TextField extends Component {
helperText={error}
InputLabelProps={{
shrink: material ? undefined : true,
className: material ? '' : classes.inputLabel,
className: material ? '' : (largeLabel ? classes.largeInputLabel : classes.inputLabel),
FormLabelClasses: {
root: material ? classes.materialLabel : classes.formLabel,
focused: material ? classes.materialFocused : classes.formLabelFocused,
@ -97,6 +93,17 @@ class TextField extends Component {
/>
)
}
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)

View File

@ -22,3 +22,32 @@ storiesOf('TextField', module)
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
/>
)