@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.
38 lines (35 loc) • 1.71 kB
JavaScript
import { rtlSpacing } from "../../../utils/rtl";
import { SIZE_OPTIONS, TOKENS } from "./consts";
const getSpacing = (onlyIcon, iconRight, iconLeft, size, theme) => {
const wrappedRtl = value => rtlSpacing(value)({
theme
});
if (onlyIcon) return wrappedRtl(theme.orbit.paddingButtonWithoutText);
const tokens = {
[]: {
[]: theme.orbit.paddingButtonLarge,
[]: theme.orbit.paddingButtonNormal,
[]: theme.orbit.paddingButtonSmall
},
[]: {
[]: theme.orbit.paddingButtonLargeWithIcons,
[]: theme.orbit.paddingButtonNormalWithIcons,
[]: theme.orbit.paddingButtonSmallWithIcons
},
[]: {
[]: theme.orbit.paddingButtonLargeWithLeftIcon,
[]: theme.orbit.paddingButtonNormalWithLeftIcon,
[]: theme.orbit.paddingButtonSmallWithLeftIcon
},
[]: {
[]: theme.orbit.paddingButtonLargeWithRightIcon,
[]: theme.orbit.paddingButtonNormalWithRightIcon,
[]: theme.orbit.paddingButtonSmallWithRightIcon
}
};
if (iconLeft && iconRight) return wrappedRtl(tokens[TOKENS.paddingButtonWithIcons][size]);
if (iconLeft && !iconRight) return wrappedRtl(tokens[TOKENS.paddingButtonWithLeftIcon][size]);
if (!iconLeft && iconRight) return wrappedRtl(tokens[TOKENS.paddingButtonWithRightIcon][size]);
return wrappedRtl(tokens[TOKENS.paddingButton][size]);
};
export default getSpacing;