@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.
34 lines (25 loc) • 3.25 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _rtl = require("../../../utils/rtl");
var _consts = require("./consts");
var getSpacing = function getSpacing(onlyIcon, iconRight, iconLeft, size, theme) {
var _TOKENS$paddingButton, _TOKENS$paddingButton2, _TOKENS$paddingButton3, _TOKENS$paddingButton4, _tokens;
var wrappedRtl = function wrappedRtl(value) {
return (0, _rtl.rtlSpacing)(value)({
theme: theme
});
};
if (onlyIcon) return wrappedRtl(theme.orbit.paddingButtonWithoutText);
var tokens = (_tokens = {}, (0, _defineProperty2.default)(_tokens, _consts.TOKENS.paddingButton, (_TOKENS$paddingButton = {}, (0, _defineProperty2.default)(_TOKENS$paddingButton, _consts.SIZE_OPTIONS.LARGE, theme.orbit.paddingButtonLarge), (0, _defineProperty2.default)(_TOKENS$paddingButton, _consts.SIZE_OPTIONS.NORMAL, theme.orbit.paddingButtonNormal), (0, _defineProperty2.default)(_TOKENS$paddingButton, _consts.SIZE_OPTIONS.SMALL, theme.orbit.paddingButtonSmall), _TOKENS$paddingButton)), (0, _defineProperty2.default)(_tokens, _consts.TOKENS.paddingButtonWithIcons, (_TOKENS$paddingButton2 = {}, (0, _defineProperty2.default)(_TOKENS$paddingButton2, _consts.SIZE_OPTIONS.LARGE, theme.orbit.paddingButtonLargeWithIcons), (0, _defineProperty2.default)(_TOKENS$paddingButton2, _consts.SIZE_OPTIONS.NORMAL, theme.orbit.paddingButtonNormalWithIcons), (0, _defineProperty2.default)(_TOKENS$paddingButton2, _consts.SIZE_OPTIONS.SMALL, theme.orbit.paddingButtonSmallWithIcons), _TOKENS$paddingButton2)), (0, _defineProperty2.default)(_tokens, _consts.TOKENS.paddingButtonWithLeftIcon, (_TOKENS$paddingButton3 = {}, (0, _defineProperty2.default)(_TOKENS$paddingButton3, _consts.SIZE_OPTIONS.LARGE, theme.orbit.paddingButtonLargeWithLeftIcon), (0, _defineProperty2.default)(_TOKENS$paddingButton3, _consts.SIZE_OPTIONS.NORMAL, theme.orbit.paddingButtonNormalWithLeftIcon), (0, _defineProperty2.default)(_TOKENS$paddingButton3, _consts.SIZE_OPTIONS.SMALL, theme.orbit.paddingButtonSmallWithLeftIcon), _TOKENS$paddingButton3)), (0, _defineProperty2.default)(_tokens, _consts.TOKENS.paddingButtonWithRightIcon, (_TOKENS$paddingButton4 = {}, (0, _defineProperty2.default)(_TOKENS$paddingButton4, _consts.SIZE_OPTIONS.LARGE, theme.orbit.paddingButtonLargeWithRightIcon), (0, _defineProperty2.default)(_TOKENS$paddingButton4, _consts.SIZE_OPTIONS.NORMAL, theme.orbit.paddingButtonNormalWithRightIcon), (0, _defineProperty2.default)(_TOKENS$paddingButton4, _consts.SIZE_OPTIONS.SMALL, theme.orbit.paddingButtonSmallWithRightIcon), _TOKENS$paddingButton4)), _tokens);
if (iconLeft && iconRight) return wrappedRtl(tokens[_consts.TOKENS.paddingButtonWithIcons][size]);
if (iconLeft && !iconRight) return wrappedRtl(tokens[_consts.TOKENS.paddingButtonWithLeftIcon][size]);
if (!iconLeft && iconRight) return wrappedRtl(tokens[_consts.TOKENS.paddingButtonWithRightIcon][size]);
return wrappedRtl(tokens[_consts.TOKENS.paddingButton][size]);
};
var _default = getSpacing;
exports.default = _default;