UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

72 lines (49 loc) 2.56 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.getWrap = exports.getShrink = exports.getGrow = exports.getDirection = exports.getJustify = exports.getAlign = exports.formatCSS = exports.isDefined = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _consts = require("./consts"); var isDefined = function isDefined(prop) { return typeof prop !== "undefined"; }; exports.isDefined = isDefined; var evaluateProp = function evaluateProp(prop, positive, negative) { if (isDefined(prop)) return prop ? positive : negative; return ""; }; var formatCSS = function formatCSS(key, value) { return "".concat(key, ": ").concat(value, ";"); }; exports.formatCSS = formatCSS; var getAlign = function getAlign(align) { var _tokens; var tokens = (_tokens = {}, (0, _defineProperty2.default)(_tokens, _consts.ALIGNS.START, "flex-start"), (0, _defineProperty2.default)(_tokens, _consts.ALIGNS.END, "flex-end"), (0, _defineProperty2.default)(_tokens, _consts.ALIGNS.CENTER, "center"), (0, _defineProperty2.default)(_tokens, _consts.ALIGNS.STRETCH, "stretch"), (0, _defineProperty2.default)(_tokens, _consts.ALIGNS.BASELINE, "baseline"), _tokens); return align && tokens[align]; }; exports.getAlign = getAlign; var getJustify = function getJustify(justify) { var _tokens2; var tokens = (_tokens2 = {}, (0, _defineProperty2.default)(_tokens2, _consts.JUSTIFY.START, "flex-start"), (0, _defineProperty2.default)(_tokens2, _consts.JUSTIFY.END, "flex-end"), (0, _defineProperty2.default)(_tokens2, _consts.JUSTIFY.CENTER, "center"), (0, _defineProperty2.default)(_tokens2, _consts.JUSTIFY.BETWEEN, "space-between"), (0, _defineProperty2.default)(_tokens2, _consts.JUSTIFY.AROUND, "space-around"), _tokens2); return justify && tokens[justify]; }; exports.getJustify = getJustify; var getDirection = function getDirection(direction) { if (!direction) return ""; return Object.values(_consts.DIRECTIONS).indexOf(direction) !== -1 ? direction : _consts.DIRECTIONS.ROW; }; exports.getDirection = getDirection; var getGrow = function getGrow(grow) { return evaluateProp(grow, "1", "0"); }; exports.getGrow = getGrow; var getShrink = function getShrink(shrink) { return evaluateProp(shrink, "1", "0"); }; exports.getShrink = getShrink; var getWrap = function getWrap(wrap) { return evaluateProp(wrap, "wrap", "nowrap"); }; exports.getWrap = getWrap;