-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathCommentCreateWidget.js
More file actions
49 lines (43 loc) · 1.63 KB
/
CommentCreateWidget.js
File metadata and controls
49 lines (43 loc) · 1.63 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
38
39
40
41
42
43
44
45
46
47
48
49
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
// Import Style
import styles from './CommentCreateWidget.css';
const CommentCreateWidget = ({ addComment, closeForm }) => {
const [authorName, changeAuthor] = useState('');
const [content, changeContent] = useState('');
const addNewComment = () => {
addComment(authorName, content);
closeForm();
};
return (
<div className={styles.form}>
<div className={styles['form-content']}>
<h2 className={styles['form-title']}><FormattedMessage id="createNewComment" /></h2>
<input placeholder="Author Name" className={styles['form-field']} value={authorName} onChange={e => changeAuthor(e.target.value)} />
<textarea placeholder="Content" className={`${styles['form-field']} ${styles['form-field-large']}`} value={content} onChange={e => changeContent(e.target.value)} />
<div className={styles['comment-actions']}>
<a
className={`${styles['comment-button']} ${styles['comment-cancel-button']}`}
href="#"
onClick={() => closeForm()}
>
<FormattedMessage id="cancel" />
</a>
<a
className={`${styles['comment-button']} ${styles['comment-submit-button']}`}
href="#"
onClick={() => addNewComment()}
>
<FormattedMessage id="submit" />
</a>
</div>
</div>
</div>
);
};
CommentCreateWidget.propTypes = {
addComment: PropTypes.func.isRequired,
closeForm: PropTypes.func.isRequired,
};
export default CommentCreateWidget;