Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import React, { Component, PropTypes } from 'react';
  2. import { Block, Flex } from 'jsxstyle';
  3. import L from '../LayoutConstants';
  4. import TextArea from 'react-textarea-autosize';
  5.  
  6. class Input extends Component {
  7. constructor() {
  8. super();
  9. this.state = {
  10. focused: false,
  11. };
  12. }
  13.  
  14. handleOnFocus() {
  15. this.setState({ focused: true });
  16. }
  17.  
  18. handleOnBlur() {
  19. this.setState({ focused: false });
  20. }
  21.  
  22. render() {
  23. const { style, rows, ...rest } = this.props;
  24. const border = this.state.focused ? '1px solid #aaa' : '1px solid #c4c4c4';
  25. const defaults = {
  26. boxSizing: 'border-box',
  27. fontFamily: L.sans,
  28. transition: '.2s border',
  29. border: border,
  30. fontSize: '1rem',
  31. outline: 'none !important',
  32. padding: '8px 10px',
  33. borderRadius:'2px',
  34. WebkitAppearance: 'none',
  35. display: 'inline-block',
  36. };
  37. const inputStyle = Object.assign({}, defaults, style);
  38. return (
  39. rows ? <TextArea
  40. useCacheForDOMMeasurements
  41. rows={rows}
  42. onFocus={this.handleOnFocus.bind(this)}
  43. onBlur={this.handleOnBlur.bind(this)}
  44. style={inputStyle}
  45. {...rest}/> : <input
  46. onFocus={this.handleOnFocus.bind(this)}
  47. onBlur={this.handleOnBlur.bind(this)}
  48. style={inputStyle}
  49. {...rest}/>
  50. );
  51. }
  52. }
  53.  
  54. export default Input;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement