-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TextField] Make it meet the guidelines (#6566)
* Adjusted styles accordingto specs, fixed #6425 * Fixes, simplified styles * Removed dead `TextFieldLabel` component as for #6580 * Added colors according to specs, `InputLabel` disabled prop * Avoiding label flicker and blurry text in webkit browsers * More smooth label animation. * More smooth font-size animation * Proper error color, added `FormHelperText` component * FormHelperText docs * Fixed lint errors * Added new component to styles order, fixes * Fixed disabled border style * FormHelperText exports * Remove unused TextFieldLabel * Form helper fixes, test, docs * TextField tests for FormHelperText * Get rid of TextFieldLabel.md, added tests for InputLabel * Added tests for FormControl * Make dirty if `defaultValue` is set * Fix helper text font * Fix label "flicker" in webkit browsers. * Use `theme.spacing.unit` instead of number values * Disabled composed text field demo * Fixed type check * Fixed type check error * Make `ComposedTextFiled` accept disabled prop * Fixed lint * Fixed docs and input * Exposed FormHelperTextProps and InputLabelProps * Fixed docs * Fixed multiline styles * Placeholder + Label behaviour * Fixes Placeholder styles look ugly. laceholder prefixing is to be impplemented in next JSS versions. * Fixed lint errors * Typo fixes * Typo fixes 2
- Loading branch information
1 parent
08075b1
commit 1c96695
Showing
28 changed files
with
424 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
components: Input, TextField, TextFieldLabel | ||
components: Input, TextField, FormHelperText | ||
--- | ||
|
||
# Text Fields | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// @flow weak | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import { createStyleSheet } from 'jss-theme-reactor'; | ||
import withStyles from '../styles/withStyles'; | ||
|
||
export const styleSheet = createStyleSheet('MuiFormHelperText', theme => ({ | ||
root: { | ||
color: theme.palette.input.helperText, | ||
fontFamily: theme.typography.fontFamily, | ||
fontSize: 12, | ||
lineHeight: 1.4, | ||
margin: 0, | ||
}, | ||
error: { | ||
color: theme.palette.error.A400, | ||
}, | ||
disabled: { | ||
color: theme.palette.input.disabled, | ||
}, | ||
})); | ||
|
||
function FormHelperText(props, context) { | ||
const { | ||
children, | ||
classes, | ||
className: classNameProp, | ||
disabled: disabledProp, | ||
error: errorProp, | ||
...other | ||
} = props; | ||
const { muiFormControl } = context; | ||
|
||
let disabled = disabledProp; | ||
let error = errorProp; | ||
|
||
if (muiFormControl && typeof disabled === 'undefined') { | ||
disabled = muiFormControl.disabled; | ||
} | ||
|
||
if (muiFormControl && typeof error === 'undefined') { | ||
error = muiFormControl.error; | ||
} | ||
|
||
const className = classNames( | ||
classes.root, | ||
{ | ||
[classes.disabled]: disabled, | ||
[classes.error]: error, | ||
}, | ||
classNameProp, | ||
); | ||
|
||
return ( | ||
<p className={className} {...other}> | ||
{children} | ||
</p> | ||
); | ||
} | ||
|
||
FormHelperText.propTypes = { | ||
/** | ||
* The content of the component. | ||
*/ | ||
children: PropTypes.node, | ||
/** | ||
* Useful to extend the style applied to components. | ||
*/ | ||
classes: PropTypes.object.isRequired, | ||
/** | ||
* @ignore | ||
*/ | ||
className: PropTypes.string, | ||
/** | ||
* If `true`, the helper text should be displayed in a disabled state. | ||
*/ | ||
disabled: PropTypes.bool, | ||
/** | ||
* If `true`, helper text should be displayed in an error state. | ||
*/ | ||
error: PropTypes.bool, | ||
}; | ||
|
||
FormHelperText.contextTypes = { | ||
muiFormControl: PropTypes.object, | ||
}; | ||
|
||
export default withStyles(styleSheet)(FormHelperText); |
Oops, something went wrong.