Skip to content

Commit

Permalink
feat: implement hyperstyle() interface
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 15, 2018
1 parent 2de1804 commit 7fe96eb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions addon/hyperstyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

exports.addon = function (renderer) {
if (process.env.NODE_ENV !== 'production') {
require('./__dev__/warnOnMissingDependencies')('hyperstyle', renderer, ['sheet']);
}

renderer.hyperstyle = function (map, block) {
var styles = renderer.sheet(map, block);

return function (type, props) {
if (props) {
var styleName = props.styleName;

if (styleName) {
var className = styles[styleName];

if (className) {
props.className = (props.className || '') + className;
}
}
}

return renderer.h.apply(null, arguments);
};
};
};

0 comments on commit 7fe96eb

Please sign in to comment.