add(TextInput): initial implementation

This commit is contained in:
Nicolas Gallagher
2015-08-17 13:45:57 -07:00
parent 95b1af9f1f
commit 5494a8e191
3 changed files with 54 additions and 0 deletions
+2
View File
@@ -3,6 +3,7 @@ import WebStyleComponent from './modules/WebStyleComponent';
import StylePropTypes from './modules/StylePropTypes';
import Image from './modules/Image';
import Text from './modules/Text';
import TextInput from './modules/TextInput';
import View from './modules/View';
export default {
@@ -13,5 +14,6 @@ export default {
WebStyleComponent,
Image,
Text,
TextInput,
View
};
@@ -0,0 +1,14 @@
import { PropTypes } from 'react';
import { TypographicPropTypes } from '../StylePropTypes';
import ViewStylePropTypes from '../View/ViewStylePropTypes';
export default {
...ViewStylePropTypes,
...TypographicPropTypes
};
export const TextInputDefaultStyles = {
background: 'transparent',
color: 'inherit',
font: 'inherit'
};
+38
View File
@@ -0,0 +1,38 @@
import { pickProps } from '../filterObjectProps';
import React, { PropTypes } from 'react';
import TextInputStylePropTypes, { TextInputDefaultStyles } from './TextInputStylePropTypes';
import WebStyleComponent from '../WebStyleComponent';
class TextInput extends React.Component {
static propTypes = {
className: PropTypes.string,
editable: PropTypes.bool,
multiline: PropTypes.bool,
placeholder: PropTypes.string,
style: PropTypes.shape(TextInputStylePropTypes)
};
static defaultProps = {
editable: true,
multiline: false
}
render() {
const { className, editable, multiline, placeholder, style, ...other } = this.props;
const filteredStyle = pickProps(style, Object.keys(TextInputStylePropTypes));
const mergedStyle = { ...TextInputDefaultStyles, ...filteredStyle };
return (
<WebStyleComponent
{...other}
className={`sdk-TextInput ${className}`}
disabled={!editable}
element={multiline ? 'textarea' : 'input'}
placeholder={placeholder}
style={mergedStyle}
/>
);
}
}
export default TextInput;