Last active
August 29, 2015 14:25
-
-
Save justanr/d3453d9adb739682e8df to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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>; | |
); | |
} | |
}, | |
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>); | |
} | |
}): | |
React.render(<WeaponBox />, document.getElementById('weapons')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment