zeplin-extension-style-kit
Version:
Models and utilities to generate CSS-like style code in Zeplin extensions.
74 lines (59 loc) • 2.48 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _constants = require("../constants");
var _scalar = _interopRequireDefault(require("../values/scalar"));
var _length = _interopRequireDefault(require("../values/length"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 useRemUnitForFont = function useRemUnitForFont(_ref) {
var useForFontSizes = _ref.useForFontSizes;
return useForFontSizes;
};
var LineHeight = /*#__PURE__*/function () {
function LineHeight(lineHeight, fontSize) {
_classCallCheck(this, LineHeight);
this.lineHeight = lineHeight;
this.fontSize = fontSize;
}
_createClass(LineHeight, [{
key: "equals",
value: function equals(other) {
return this.hasDefaultValue() && other.hasDefaultValue() || this.lineHeight === other.lineHeight;
}
}, {
key: "hasDefaultValue",
value: function hasDefaultValue() {
return this.lineHeight === LineHeight.DEFAULT_VALUE;
}
}, {
key: "getValue",
value: function getValue(params, variables) {
if (this.hasDefaultValue()) {
return this.lineHeight;
}
var unitlessLineHeight = params.unitlessLineHeight;
var value = unitlessLineHeight ? new _scalar.default(this.lineHeight / this.fontSize) : new _length.default(this.lineHeight, {
useRemUnit: useRemUnitForFont
});
return value.toStyleValue(params, variables);
}
}, {
key: "name",
get: function get() {
return _constants.STYLE_PROPS.LINE_HEIGHT;
}
}], [{
key: "DEFAULT_VALUE",
get: function get() {
return "normal";
}
}]);
return LineHeight;
}();
var _default = LineHeight;
exports.default = _default;
;