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.

41 lines (39 loc) 1.23 kB
"use strict"; exports.__esModule = true; exports.normalizeSpacing = exports.normalize = void 0; var _rtl = require("../utils/rtl"); var _layout = require("../utils/layout"); var _consts = require("../utils/layout/consts"); const normalizeSpacing = (el, theme) => { const tokens = (0, _consts.TOKENS)(theme); if (el !== "none") { return ` margin-${(0, _rtl.left)({ theme })}: -${tokens[el]}; margin-top: -${tokens[el]}; & > * { margin-${(0, _rtl.left)({ theme })}: ${tokens[el]}; margin-top: ${tokens[el]}; } `; } return ""; }; exports.normalizeSpacing = normalizeSpacing; const normalize = object => ({ theme }) => { if (!object) return null; return Object.keys(object).reduce((acc, key) => { const val = object[key]; if (key === "spacing") return [...acc, normalizeSpacing(val, theme)]; if (key === "justify") return [...acc, (0, _layout.formatCSS)("justify-content", (0, _layout.getJustify)(val))]; if (key === "align") return [...acc, (0, _layout.formatCSS)("align-items", (0, _layout.getAlign)(val))]; if (val) return [...acc, (0, _layout.formatCSS)(key, val)]; return acc; }, []); }; exports.normalize = normalize;