@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.
60 lines (54 loc) • 1.81 kB
JavaScript
import { SIZE_OPTIONS, TOKENS } from "../consts";
import { rtlSpacing } from "../../utils/rtl/index";
const getButtonSpacing = () => ({
theme,
onlyIcon,
iconRight,
iconLeft,
size
}) => {
if (onlyIcon) return rtlSpacing(theme.orbit.paddingButtonWithoutText)({
theme
});
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 rtlSpacing(tokens[TOKENS.paddingButtonWithIcons][size])({
theme
});
}
if (iconLeft && !iconRight) {
return rtlSpacing(tokens[TOKENS.paddingButtonWithLeftIcon][size])({
theme
});
}
if (!iconLeft && iconRight) {
return rtlSpacing(tokens[TOKENS.paddingButtonWithRightIcon][size])({
theme
});
}
return rtlSpacing(tokens[TOKENS.paddingButton][size])({
theme
});
};
export default getButtonSpacing;