-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathCommentCreateWidget.js
More file actions
37 lines (32 loc) · 1.13 KB
/
CommentCreateWidget.js
File metadata and controls
37 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage } from 'react-intl';
// Import Style
import styles from './CommentCreateWidget.css';
export class CommentCreateWidget extends Component {
addComment = () => {
const authorRef = this.refs.author;
const contentRef = this.refs.content;
if (authorRef.value && contentRef.value) {
this.props.addComment(authorRef.value, contentRef.value);
authorRef.value = contentRef.value = '';
}
};
render() {
const cls = `${styles.form}`;
return (
<div className={cls}>
<div className={styles['form-title']}>Comment</div>
<div className={styles['form-content']}>
<input className={styles['form-field']} ref="author" />
<textarea className={styles['form-field']} ref="content" />
<a className={styles['post-submit-button']} href="#" onClick={this.addComment}><FormattedMessage id="submit" /></a>
</div>
</div>
);
}
}
CommentCreateWidget.propTypes = {
addComment: PropTypes.func.isRequired,
};
export default injectIntl(CommentCreateWidget);