zeplin-extension-style-kit
Version:
Models and utilities to generate CSS-like style code in Zeplin extensions.
57 lines (46 loc) • 1.87 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var RuleSet = /*#__PURE__*/function () {
function RuleSet(selector, declarations) {
var _this = this;
_classCallCheck(this, RuleSet);
this.selector = selector;
this.declarationMap = {};
declarations.forEach(function (declaration) {
_this.declarationMap[declaration.name] = declaration;
});
}
_createClass(RuleSet, [{
key: "hasProperty",
value: function hasProperty(property) {
return property in this.declarationMap;
}
}, {
key: "addDeclaration",
value: function addDeclaration(declaration) {
this.declarationMap[declaration.name] = declaration;
}
}, {
key: "removeDeclaration",
value: function removeDeclaration(declaration) {
delete this.declarationMap[declaration.name];
}
}, {
key: "declarations",
get: function get() {
var _this2 = this;
return Object.keys(this.declarationMap).map(function (name) {
return _this2.declarationMap[name];
});
}
}]);
return RuleSet;
}();
var _default = RuleSet;
exports.default = _default;
;