react-themable-hoc-jss-interface
Version:
Use JSS with react-themable-hoc
81 lines (68 loc) • 2.6 kB
JavaScript
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['exports', 'jss'], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require('jss'));
} else {
var mod = {
exports: {}
};
factory(mod.exports, global.jss);
global.JSSInterface = mod.exports;
}
})(this, function (exports, _jss) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var JSSInterface = function () {
function JSSInterface() {
var jss = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _jss.create)();
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, JSSInterface);
this.jss = jss;
this.options = options;
}
_createClass(JSSInterface, [{
key: 'css',
value: function css(styles) {
var styleSheet = this.jss.createStyleSheet(styles, this.options).attach();
return _extends({}, styleSheet.classes);
}
}]);
return JSSInterface;
}();
exports.default = JSSInterface;
});