@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.
39 lines (35 loc) • 1.78 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { ALIGNS, JUSTIFY, DIRECTIONS } from "./consts";
export var isDefined = function isDefined(prop) {
return typeof prop !== "undefined";
};
var evaluateProp = function evaluateProp(prop, positive, negative) {
if (isDefined(prop)) return prop ? positive : negative;
return "";
};
export var formatCSS = function formatCSS(key, value) {
return "".concat(key, ": ").concat(value, ";");
};
export var getAlign = function getAlign(align) {
var _tokens;
var tokens = (_tokens = {}, _defineProperty(_tokens, ALIGNS.START, "flex-start"), _defineProperty(_tokens, ALIGNS.END, "flex-end"), _defineProperty(_tokens, ALIGNS.CENTER, "center"), _defineProperty(_tokens, ALIGNS.STRETCH, "stretch"), _defineProperty(_tokens, ALIGNS.BASELINE, "baseline"), _tokens);
return align && tokens[align];
};
export var getJustify = function getJustify(justify) {
var _tokens2;
var tokens = (_tokens2 = {}, _defineProperty(_tokens2, JUSTIFY.START, "flex-start"), _defineProperty(_tokens2, JUSTIFY.END, "flex-end"), _defineProperty(_tokens2, JUSTIFY.CENTER, "center"), _defineProperty(_tokens2, JUSTIFY.BETWEEN, "space-between"), _defineProperty(_tokens2, JUSTIFY.AROUND, "space-around"), _tokens2);
return justify && tokens[justify];
};
export var getDirection = function getDirection(direction) {
if (!direction) return "";
return Object.values(DIRECTIONS).indexOf(direction) !== -1 ? direction : DIRECTIONS.ROW;
};
export var getGrow = function getGrow(grow) {
return evaluateProp(grow, "1", "0");
};
export var getShrink = function getShrink(shrink) {
return evaluateProp(shrink, "1", "0");
};
export var getWrap = function getWrap(wrap) {
return evaluateProp(wrap, "wrap", "nowrap");
};