@plusscommunities/pluss-core-web 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +343 -210
- package/dist/index.esm.js +342 -209
- package/dist/index.umd.js +346 -213
- package/package.json +1 -1
- package/src/components/Comment.js +22 -0
- package/src/components/CommentSection.js +63 -0
- package/src/components/index.js +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { toParagraphed } from '../helper';
|
|
4
|
+
import { ProfilePic } from './ProfilePic';
|
|
5
|
+
|
|
6
|
+
class Comment extends Component {
|
|
7
|
+
render() {
|
|
8
|
+
const { comment } = this.props;
|
|
9
|
+
return (
|
|
10
|
+
<div key={comment.Id} className="comment">
|
|
11
|
+
<p className="comment_text">{toParagraphed(comment.Comment)}</p>
|
|
12
|
+
<div className="comment_bottom">
|
|
13
|
+
<ProfilePic className="comment_profilePic" size={25} image={comment.User.profilePic} />
|
|
14
|
+
<p className="comment_name">{comment.User.displayName}</p>
|
|
15
|
+
<p className="comment_time">{moment.utc(comment.Timestamp).local().format('D MMM YYYY • h:mma')}</p>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Comment };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import FontAwesome from 'react-fontawesome';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import Textarea from 'react-textarea-autosize';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
import { Comment } from './Comment';
|
|
7
|
+
|
|
8
|
+
class CommentSection extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
|
|
12
|
+
this.state = {
|
|
13
|
+
commentInput: '',
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
onHandleChange = (event) => {
|
|
18
|
+
var stateChange = {};
|
|
19
|
+
stateChange[event.target.getAttribute('id')] = event.target.value;
|
|
20
|
+
this.setState(stateChange);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
onAddComment = async () => {
|
|
24
|
+
const { commentInput } = this.state;
|
|
25
|
+
this.setState({ commentInput: '' });
|
|
26
|
+
this.props.onAddComment(commentInput);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
{this.props.includeTitle && (
|
|
33
|
+
<Text type="formTitleSmall" className="marginBottom-16">
|
|
34
|
+
Comments
|
|
35
|
+
</Text>
|
|
36
|
+
)}
|
|
37
|
+
<div className="commentSection">
|
|
38
|
+
{this.props.comments.map((c) => (
|
|
39
|
+
<Comment key={c.Id} comment={c} />
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
<div className="commentReply">
|
|
43
|
+
<div
|
|
44
|
+
className={`commentReply_button${!_.isEmpty(this.state.commentInput) ? ' commentReply_button-active' : ''}`}
|
|
45
|
+
onClick={this.onAddComment}
|
|
46
|
+
>
|
|
47
|
+
<FontAwesome className="commentReply_icon" name="paper-plane-o" />
|
|
48
|
+
</div>
|
|
49
|
+
<Textarea
|
|
50
|
+
id="commentInput"
|
|
51
|
+
placeholder="Reply here..."
|
|
52
|
+
type="text"
|
|
53
|
+
className="commentReply_input"
|
|
54
|
+
value={this.state.commentInput}
|
|
55
|
+
onChange={(e) => this.onHandleChange(e)}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { CommentSection };
|
package/src/components/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export * from './AddButton';
|
|
|
2
2
|
export * from './Attachment';
|
|
3
3
|
export * from './Button';
|
|
4
4
|
export * from './CheckBox';
|
|
5
|
+
export * from './Comment';
|
|
6
|
+
export * from './CommentSection';
|
|
5
7
|
export * from './DatePicker';
|
|
6
8
|
export * from './FileInput';
|
|
7
9
|
export * from './GenericInput';
|