diff --git a/addon/sheet.js b/addon/sheet.js new file mode 100644 index 00000000..5a8d03b5 --- /dev/null +++ b/addon/sheet.js @@ -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; + }; +}; diff --git a/lib/index.js b/lib/index.js index 31598c15..cf995df8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -8,6 +8,7 @@ var isClient = typeof window === 'object'; exports.create = function (h) { var renderer = { + h: h, raw: '', cns: {}, pfx: '_',