Skip to content

Instantly share code, notes, and snippets.

@kkarimi
Created July 25, 2015 18:31
Show Gist options
  • Save kkarimi/5c050d21652d45edbfc5 to your computer and use it in GitHub Desktop.
Save kkarimi/5c050d21652d45edbfc5 to your computer and use it in GitHub Desktop.
var React = require('react');
var WeaponList = React.createClass({
render: function() {
return (<ul className="list-unstyled">
<li>
<Weapon name="flail" attrs={["1d8 bludgeoning;"]} />
</li>
<li>
<Weapon name="morning star" attrs={["1d8 piercing;"]} />
</li>
</ul>
);
}
});
var Weapon = React.createClass({
render: function() {
return (<div>
<h2 className="text-center">{this.props.name}</h2>
<AttributeList attributes={this.props.attrs} />
</div>
);
}
});
var AttributeList = React.createClass({
processAttributes: function(attrs) {
return attrs.map(function(attr) {
return (<li>
<Attribute>{attr}</Attribute>
</li>);
}, this);
},
render: function() {
var attrs = this.processAttributes(this.props.attributes);
return (
<ul>
{attrs}
</ul>
);
}
});
var Attribute = React.createClass({
render: function () {
return (
<span>{this.props.children.toString()}</span>
);
}
});
module.exports = WeaponList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment