Vulcan/packages/nova-components/lib/comments/list/CommentNode.jsx

43 lines
1 KiB
React
Raw Normal View History

2016-02-18 17:53:04 +09:00
const CommentNode = React.createClass({
propTypes: {
comment: React.PropTypes.object.isRequired, // the current comment
2016-02-18 21:39:33 +09:00
currentUser: React.PropTypes.object, // the current user
2016-02-18 17:53:04 +09:00
},
renderComment(comment) {
({CommentItem} = Telescope.components);
return (
2016-02-18 21:39:33 +09:00
<CommentItem comment={comment} key={comment._id} currentUser={this.props.currentUser}/>
2016-02-18 17:53:04 +09:00
)
},
renderChildren(children) {
// ({CommentNode} = Telescope.components);
return (
<div className="comment-children">
2016-02-18 21:39:33 +09:00
{children.map(comment => <CommentNode comment={comment} key={comment._id} currentUser={this.props.currentUser}/>)}
2016-02-18 17:53:04 +09:00
</div>
)
},
render() {
const comment = this.props.comment;
const children = this.props.comment.childrenResults;
return (
<div className="comment-node" style={{borderLeft:"2px solid #eee", paddingLeft: "10px"}}>
{this.renderComment(comment)}
{children ? this.renderChildren(children) : ""}
</div>
)
}
});
module.exports = CommentNode;