diff --git a/src/components/editable-header.js b/src/components/editable-header.js index 3995a25..1b83755 100644 --- a/src/components/editable-header.js +++ b/src/components/editable-header.js @@ -37,45 +37,69 @@ class EditableHeader extends React.Component { this.setState({ title: nextProps.title }); } - startEditing = () => { + edit = () => { this.setState({ editing: true }); } - stopEditing = () => { + save = () => { this.setState({ editing: false }); + + if (this.props.onChange != null) { + this.props.onChange(this.state.title); + } + } + + cancel = () => { + this.setState({ editing: false, title: this.props.title }); } onChange = event => { - + this.setState({ title: event.target.value }); } render() { + const wrapperStyle= { + float: 'left' + }; + + const glyphStyle = { + float: 'left', + + marginLeft: '10px', + marginTop: '25px', + marginBottom: '20px' + }; + if (this.state.editing) { const editStyle = { - maxWidth: '500px' + maxWidth: '500px', + + marginTop: '10px' }; return
-
+ - + +
; } return
-

+

{this.state.title}

- +
; } } EditableHeader.PropTypes = { - title: PropTypes.string + title: PropTypes.string.isRequired, + onChange: PropTypes.func }; export default EditableHeader;