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.

63 lines (52 loc) 1.72 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); var _consts = require("./consts"); var _rtl = require("../../../utils/rtl"); var _Icon = require("../../../Icon"); var _consts2 = require("../../../Icon/consts"); const getIconSpacing = (onlyIcon, size, theme) => { if (onlyIcon) { return null; } const tokens = { [_consts.TOKENS.marginRightIcon]: { [_consts.SIZE_OPTIONS.LARGE]: theme.orbit.marginButtonIconLarge, [_consts.SIZE_OPTIONS.NORMAL]: theme.orbit.marginButtonIconNormal, [_consts.SIZE_OPTIONS.SMALL]: theme.orbit.marginButtonIconSmall } }; return { leftMargin: (0, _rtl.rtlSpacing)(`0 ${tokens[_consts.TOKENS.marginRightIcon][size]} 0 0`)({ theme }), rightMargin: (0, _rtl.rtlSpacing)(`0 0 0 ${tokens[_consts.TOKENS.marginRightIcon][size]}`)({ theme }) }; }; const getIconContainer = ({ iconLeft, children, theme, size = _consts.SIZE_OPTIONS.NORMAL, iconForeground }) => { const onlyIcon = Boolean(iconLeft && !children); const sizeIcon = size === _consts2.ICON_SIZES.SMALL ? _consts2.ICON_SIZES.SMALL : _consts2.ICON_SIZES.MEDIUM; const computedSize = (0, _Icon.getSize)(sizeIcon)({ theme }); return { icons: (0, _objectSpread2.default)((0, _objectSpread2.default)({ height: computedSize, width: computedSize }, getIconSpacing(onlyIcon, size, theme)), iconForeground) }; }; var _default = getIconContainer; exports.default = _default;