Skip to content

Instantly share code, notes, and snippets.

@petehunt
Created December 28, 2014 08:11
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petehunt/bd5fa62610f80b6ec087 to your computer and use it in GitHub Desktop.
Save petehunt/bd5fa62610f80b6ec087 to your computer and use it in GitHub Desktop.
function makeStyle(defaults, tagName) {
tagName = tagName || 'div';
var Style = React.createClass({
getDefaultProps: function() {
return assign({}, defaults);
},
render: function() {
var style = assign({}, this.props);
delete style.children;
return React.createElement(
tagName,
{style: style, children: this.props.children}
);
}
});
return Style;
}
var Emphasis = makeStyle({fontWeight: 'bold', color: 'red'});
var Subtitle = makeStyle({color: 'gray'});
var Style = makeStyle();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment