Created
July 25, 2015 18:31
-
-
Save kkarimi/5c050d21652d45edbfc5 to your computer and use it in GitHub Desktop.
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
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