@moda/tokens
Version:
Constant values for modaoperandi.com
54 lines • 2.54 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.spacing = exports.colorInHex = exports.color = exports.remToUnitlessPx = exports.text = void 0;
var color_string_1 = __importDefault(require("color-string"));
var colors_1 = require("./colors");
var space_1 = require("./space");
var typography_1 = require("./typography");
var text = function (name, font) {
if (font === void 0) { font = 'sans'; }
var treatment = typography_1.typography['text-treatments'][name];
return __assign(__assign({}, treatment), { 'font-family': typography_1.typography.fonts[font].join(','), 'line-height': "".concat(treatment['line-height']) });
};
exports.text = text;
var remToUnitlessPx = function (value) {
return parseFloat(value) * parseInt(typography_1.typography['root-font-size'], 10);
};
exports.remToUnitlessPx = remToUnitlessPx;
var color = function (name, alpha) {
var _a;
var color = colors_1.colors.all[name];
var _b = (_a = color_string_1.default.get.rgb(color)) !== null && _a !== void 0 ? _a : [], red = _b[0], green = _b[1], blue = _b[2];
return alpha != null ? color_string_1.default.to.rgb(red, green, blue, alpha) : color;
};
exports.color = color;
var colorInHex = function (name, alpha) {
var _a, _b, _c;
var _d = (_b = color_string_1.default.get.rgb((_a = (0, exports.color)(name, alpha)) !== null && _a !== void 0 ? _a : '')) !== null && _b !== void 0 ? _b : [], red = _d[0], green = _d[1], blue = _d[2];
return (_c = color_string_1.default.to.hex(red, green, blue, alpha)) !== null && _c !== void 0 ? _c : '';
};
exports.colorInHex = colorInHex;
var spacing = function (topY, rightX, bottom, left) {
return [topY, rightX, bottom, left].reduce(function (acc, value) {
var _a;
if (value === undefined)
return acc;
return [acc, (_a = space_1.space.scale[Number(value)]) !== null && _a !== void 0 ? _a : value].join(' ');
}, '');
};
exports.spacing = spacing;
//# sourceMappingURL=helpers.js.map