|
|
@ -1,6 +1,7 @@
|
|
1
|
1
|
// following along http://facebook.github.io/react/docs/tutorial.html
|
|
2
|
2
|
|
|
3
|
3
|
import React from "react";
|
|
|
4
|
import marked from "marked";
|
|
4
|
5
|
|
|
5
|
6
|
require('./style.css');
|
|
6
|
7
|
|
|
|
@ -16,13 +17,17 @@ class CommentForm extends React.Component {
|
|
16
|
17
|
|
|
17
|
18
|
class CommentList extends React.Component {
|
|
18
|
19
|
render() {
|
|
|
20
|
let commentNodes = this.props.data.map((comment) => {
|
|
|
21
|
return (
|
|
|
22
|
<Comment author={comment.author}>
|
|
|
23
|
{comment.text}
|
|
|
24
|
</Comment>
|
|
|
25
|
);
|
|
|
26
|
});
|
|
|
27
|
|
|
19
|
28
|
return (
|
|
20
|
29
|
<div className="comment-list">
|
|
21
|
|
<Comment author="Alice">Down the... halfpipe!</Comment>
|
|
22
|
|
<Comment author="PP">Alice, what blasphemy!</Comment>
|
|
23
|
|
<Comment author="Maybe Not Lewis">Let her be herself, Peter,
|
|
24
|
|
we let you jump around all the time as well...
|
|
25
|
|
</Comment>
|
|
|
30
|
{commentNodes}
|
|
26
|
31
|
</div>
|
|
27
|
32
|
);
|
|
28
|
33
|
}
|
|
|
@ -33,7 +38,7 @@ class CommentBox extends React.Component {
|
|
33
|
38
|
return (
|
|
34
|
39
|
<div className="comment-box">
|
|
35
|
40
|
<h1>Comments</h1>
|
|
36
|
|
<CommentList />
|
|
|
41
|
<CommentList data={this.props.data} />
|
|
37
|
42
|
<CommentForm />
|
|
38
|
43
|
</div>
|
|
39
|
44
|
);
|
|
|
@ -42,13 +47,20 @@ class CommentBox extends React.Component {
|
|
42
|
47
|
|
|
43
|
48
|
class Comment extends React.Component {
|
|
44
|
49
|
render() {
|
|
|
50
|
let rawMarkup = marked(this.props.children.toString());
|
|
45
|
51
|
return (
|
|
46
|
52
|
<div className="comment">
|
|
47
|
53
|
<h2 className="comment-author">{this.props.author}</h2>
|
|
48
|
|
{this.props.children}
|
|
|
54
|
<span dangerouslySetInnerHTML={{__html: rawMarkup}} />
|
|
49
|
55
|
</div>
|
|
50
|
56
|
);
|
|
51
|
57
|
}
|
|
52
|
58
|
}
|
|
53
|
59
|
|
|
54
|
|
React.render(<CommentBox />, document.getElementById("content"));
|
|
|
60
|
var data = [
|
|
|
61
|
{author: "Alice", text: "Down the... halfpipe!"},
|
|
|
62
|
{author: "PP", text: "Alice, what **blasphemy**!"},
|
|
|
63
|
{author: "Maybe Not Lewis", text: "Let her be herself, Peter, we let *you* jump around all the time as well..."}
|
|
|
64
|
];
|
|
|
65
|
|
|
|
66
|
React.render(<CommentBox data={data} />, document.getElementById("content"));
|