Skip to content

Commit

Permalink
feat: add sheet() addon
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 13, 2018
1 parent 859a01f commit f2d4bd2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions addon/sheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

var hash = require('../lib/hash').hash;

exports.addonSheet = function (renderer) {
renderer.sheet = function (map, block) {
var result = {};

if (!block) {
block = hash(map);
}

for (var elementModifier in map) {
var styles = map[elementModifier];

Object.defineProperty(result, elementModifier, {
configurable: true,
get: function () {
var classNames = this.rule(styles, block + '-' + elementModifier);

Object.defineProperty(result, elementModifier, {
value: classNames,
});

return classNames;
},
});
}

return result;
};
};
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var isClient = typeof window === 'object';

exports.create = function (h) {
var renderer = {
h: h,
raw: '',
cns: {},
pfx: '_',
Expand Down

0 comments on commit f2d4bd2

Please sign in to comment.