@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.
27 lines (25 loc) • 877 B
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import getSizeToken from "./getSizeToken";
import getPadding from "./getPadding";
import { SIZE_OPTIONS } from "./consts";
const getCommonProps = ({
width,
size = SIZE_OPTIONS.NORMAL,
theme,
iconRight,
contentAlign,
contentWidth,
iconLeft,
children
}) => {
const onlyIcon = Boolean((iconLeft || iconRight) && !children);
const hasCenteredContent = Boolean(onlyIcon || children && !(iconLeft || iconRight));
return _objectSpread(_objectSpread({}, getSizeToken(size, theme)), {}, {
width,
padding: getPadding(onlyIcon, iconRight, iconLeft, size, theme),
fontWeight: theme.orbit.fontWeightMedium,
contentAlign: contentAlign || (onlyIcon || hasCenteredContent ? "center" : "space-between"),
contentWidth: contentWidth || "100%"
});
};
export default getCommonProps;