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.

25 lines (23 loc) 809 B
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, iconLeft, children }) => { const onlyIcon = Boolean(iconLeft && !children); const hasCenteredContent = Boolean(iconLeft && !children || children && !(iconLeft || iconRight)); return _objectSpread(_objectSpread({}, getSizeToken(size, theme)), {}, { width, padding: getPadding(onlyIcon, iconRight, iconLeft, size, theme), fontWeight: theme.orbit.fontWeightMedium, contentAlign: onlyIcon || hasCenteredContent ? "center" : "space-between", contentWidth: "100%" }); }; export default getCommonProps;