Created
October 5, 2015 08:41
-
-
Save Anahkiasen/fba304ef944c90dbcef5 to your computer and use it in GitHub Desktop.
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
import React, {PropTypes} from 'react'; | |
import debounce from 'lodash/function/debounce'; | |
import AbstractSubstep from './AbstractSubstep'; | |
export default class Story extends AbstractSubstep { | |
static propTypes = { | |
contents: PropTypes.string, | |
label: PropTypes.string, | |
placeholder: PropTypes.string, | |
setStory: PropTypes.func.isRequired, | |
}; | |
static defaultProps = { | |
editing: false, | |
placeholder: 'Write description...', | |
}; | |
/** | |
* Set the story for this step | |
*/ | |
setStory() { | |
this.props.setStory( | |
React.findDOMNode(this.refs.story).value | |
); | |
} | |
render() { | |
const attributes = { | |
className: 'story--content-editable', | |
defaultValue: this.props.contents, | |
onChange: debounce(this.setStory.bind(this), 250), | |
placeholder: this.props.placeholder, | |
ref: 'story', | |
disabled: !this.state.editing, | |
rows: 3, | |
}; | |
return ( | |
<div className="form-group story"> | |
<label className="control-label">{this.props.label}</label> | |
<div className="col-ld-8"> | |
{this.renderPencil()} | |
<textarea {...attributes}></textarea> | |
</div> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment