Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Restructure and break out react views

  • Loading branch information...
commit 472f6b7996f91ed3663f006a484d367c5b843d9b 1 parent 78d6cfe
@benjreinhart benjreinhart authored
View
17 components/search/views/react/result.jsx
@@ -0,0 +1,17 @@
+/** @jsx React.DOM */
+
+module.exports = React.createClass({
+ render: function() {
+ var result = this.props.result;
+ return (
+ <li>
+ <span className="date">{result.get('humanDate')}</span>
+ <span className="location">
+ {result.get('venue').name} <br />
+ {result.get('venue').location.city}, {result.get('venue').location.state}
+ </span>
+ <p className="show-notes" dangerouslySetInnerHTML={{__html: result.get('pnet').setlistNotes}} />
+ </li>
+ );
+ }
+});
View
11 components/search/views/react/result_header.jsx
@@ -0,0 +1,11 @@
+/** @jsx React.DOM */
+
+module.exports = React.createClass({
+ render: function() {
+ return (
+ <section className="heading">
+ <h5><b>{this.props.total}</b> matches</h5>
+ </section>
+ );
+ }
+});
View
24 components/search/views/react/results.jsx
@@ -2,24 +2,18 @@
module.exports = React.createClass({
render: function() {
+ var props = this.props
+ , Header = props.Header
+ , results = props.results;
return (
<section className="results">
- <section className="heading">
- <h5><b>{this.props.total}</b> matches</h5>
- </section>
+ <Header />
<ul>
- {this.props.results.map(function(result){
- return (
- <li>
- <span className="date">{result.get('humanDate')}</span>
- <span className="location">
- {result.get('venue').name} <br />
- {result.get('venue').location.city}, {result.get('venue').location.state}
- </span>
- <p className="show-notes" dangerouslySetInnerHTML={{__html: result.get('pnet').setlistNotes}} />
- </li>
- );
- }, this)}
+ {
+ results.map(function(result){
+ <Result result={result} />
+ });
+ }
</ul>
</section>
);
View
15 components/search/views/results.js
@@ -1,5 +1,7 @@
var Backbone = require('backbone')
- , Results = require('./react/results');
+ , Result = require('./react/result')
+ , Results = require('./react/results')
+ , ResultHeader = require('./react/result_header');
module.exports = Backbone.View.extend({
initialize: function() {
@@ -12,10 +14,17 @@ module.exports = Backbone.View.extend({
total: results.total,
results: results.hits
};
- React.renderComponent(Results(results), this.$el[0]);
+
+ var props = {
+ Header: ResultHeader,
+ Result: Result,
+ results: results
+ };
+
+ React.renderComponent(Results(props), this.$el[0]);
},
onError: function() {
throw new Error('TODO: write me');
}
-});
+});
Please sign in to comment.
Something went wrong with that request. Please try again.