You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

  1. import IconButton from '../../../components/icon_button';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. const FollowForm = React.createClass({
  4. contextTypes: {
  5. router: React.PropTypes.object
  6. },
  7. propTypes: {
  8. text: React.PropTypes.string.isRequired,
  9. is_submitting: React.PropTypes.bool,
  10. onChange: React.PropTypes.func.isRequired,
  11. onSubmit: React.PropTypes.func.isRequired
  12. },
  13. mixins: [PureRenderMixin],
  14. handleChange (e) {
  15. this.props.onChange(e.target.value);
  16. },
  17. handleKeyUp (e) {
  18. if (e.keyCode === 13) {
  19. this.handleSubmit();
  20. }
  21. },
  22. handleSubmit () {
  23. this.props.onSubmit(this.context.router);
  24. },
  25. render () {
  26. return (
  27. <div style={{ display: 'flex', lineHeight: '20px', padding: '10px', background: '#373b4a' }}>
  28. <input type='text' disabled={this.props.is_submitting} placeholder='username@domain' value={this.props.text} onKeyUp={this.handleKeyUp} onChange={this.handleChange} className='follow-form__input' style={{ flex: '1 1 auto', boxSizing: 'border-box', display: 'block', border: 'none', padding: '10px', fontFamily: 'Roboto', color: '#282c37', fontSize: '14px', margin: '0' }} />
  29. <div style={{ padding: '10px', paddingRight: '0' }}><IconButton title='Follow' size={20} icon='user-plus' onClick={this.handleSubmit} disabled={this.props.is_submitting} /></div>
  30. </div>
  31. );
  32. }
  33. });
  34. export default FollowForm;