-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
var data = [ | ||
{author: "Pete Hunt", text: "This is one comment"}, | ||
{author: "Jordan Walke", text: "This is *another* comment"} | ||
]; | ||
var converter = new Showdown.converter(); | ||
var CommentBox = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div className="commentBox"> | ||
<h1>Comments</h1> | ||
<CommentList data={this.props.data} /> | ||
<CommentForm /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var CommentList = React.createClass({ | ||
render: function() { | ||
var commentNodes = this.props.data.map(function (comment) { | ||
return ( | ||
/*<Comment author={comment.author}> | ||
{comment.text} | ||
</Comment>*/ | ||
); | ||
}); | ||
return ( | ||
//{commentNodes} | ||
); | ||
} | ||
}); | ||
|
||
var CommentForm = React.createClass({ | ||
render: function() { | ||
return ( | ||
<div className="commentForm"> | ||
Hello, world! I am a CommentForm. | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
var Comment = React.createClass({ | ||
render: function() { | ||
var rawMarkup = converter.makeHtml(this.props.children.toString()); | ||
return ( | ||
<div className="comment"> | ||
<h2 className="commentAuthor"> | ||
{this.props.author} | ||
</h2> | ||
<span dangerouslySetInnerHTML={{__html: rawMarkup}} /> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
React.render( | ||
<CommentBox data={data} />, | ||
document.getElementById('content') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
To change this license header, choose License Headers in Project Properties. | ||
To change this template file, choose Tools | Templates | ||
and open the template in the editor. | ||
--> | ||
<html> | ||
<head> | ||
<title>Test Page</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/JSXTransformer.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script> | ||
<script type="text/jsx;harmony=true" src="js/tutorial.jsx"></script> | ||
</head> | ||
<body> | ||
<div id="content"></div> | ||
</body> | ||
</html> |