zeplin-extension-style-kit
Version:
Models and utilities to generate CSS-like style code in Zeplin extensions.
92 lines (72 loc) • 3.88 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _constants = require("../constants");
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 STRETCH_KEYWORD = Object.freeze({
"ultra-condensed": 50,
"extra-condensed": 62.5,
"condensed": 75,
"semi-condensed": 87.5,
"normal": 100,
"semi-expanded": 112.5,
"expanded": 125,
"extra-expanded": 150,
"ultra-expanded": 200
});
var FontStretch = /*#__PURE__*/function () {
function FontStretch() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : FontStretch.DEFAULT_VALUE;
_classCallCheck(this, FontStretch);
if (typeof value === "string") {
this.value = STRETCH_KEYWORD[value];
} else {
this.value = value;
}
}
_createClass(FontStretch, [{
key: "equals",
value: function equals(other) {
return this.value === other.value;
}
}, {
key: "hasDefaultValue",
value: function hasDefaultValue() {
return this.value === FontStretch.DEFAULT_VALUE;
}
}, {
key: "getValue",
value: function getValue() {
var _this = this;
var value = Object.entries(STRETCH_KEYWORD).find(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
val = _ref2[1];
return _this.value === val;
});
return value ? value[0] : "".concat(this.value, "%");
}
}, {
key: "name",
get: function get() {
return _constants.STYLE_PROPS.FONT_STRETCH;
}
}], [{
key: "DEFAULT_VALUE",
get: function get() {
return STRETCH_KEYWORD.normal;
}
}]);
return FontStretch;
}();
var _default = FontStretch;
exports.default = _default;
;