Skip to content

Instantly share code, notes, and snippets.

@Anahkiasen
Created October 5, 2015 08:41
Show Gist options
  • Save Anahkiasen/fba304ef944c90dbcef5 to your computer and use it in GitHub Desktop.
Save Anahkiasen/fba304ef944c90dbcef5 to your computer and use it in GitHub Desktop.
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