-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2567 from newoga/text-field-hint
[TextField] Separate TextFieldHint into separate internal component.
- Loading branch information
Showing
2 changed files
with
84 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import Transitions from '../styles/transitions'; | ||
import styleUtils from '../utils/styles'; | ||
|
||
const propTypes = { | ||
/** | ||
* The material-ui theme applied to this component. | ||
*/ | ||
muiTheme: React.PropTypes.object.isRequired, | ||
|
||
/** | ||
* True if the hint text should be visible. | ||
*/ | ||
show: React.PropTypes.bool, | ||
|
||
/** | ||
* Override the inline-styles of the hint text. | ||
*/ | ||
style: React.PropTypes.object, | ||
|
||
/** | ||
* The hint text displayed. | ||
*/ | ||
text: React.PropTypes.string, | ||
}; | ||
|
||
const defaultProps = { | ||
show: true, | ||
}; | ||
|
||
const TextFieldHint = (props) => { | ||
|
||
const { | ||
muiTheme, | ||
show, | ||
style, | ||
text, | ||
} = props; | ||
|
||
const { | ||
textField: { | ||
hintColor, | ||
}, | ||
} = muiTheme; | ||
|
||
const styles = { | ||
root: { | ||
position: 'absolute', | ||
opacity: show ? 1 : 0, | ||
color: hintColor, | ||
transition: Transitions.easeOut(), | ||
bottom: 12, | ||
}, | ||
}; | ||
|
||
return ( | ||
<div | ||
style={styleUtils.prepareStyles(muiTheme, styles.root, style)}>{text} | ||
</div> | ||
); | ||
}; | ||
|
||
TextFieldHint.propTypes = propTypes; | ||
TextFieldHint.defaultProps = defaultProps; | ||
|
||
export default TextFieldHint; |