@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.
24 lines (20 loc) • 705 B
JavaScript
import { css } from "styled-components";
import { POSITIONS, POPOVER_SPACE_BETWEEN } from "../consts";
const resolvePopoverPosition = ({
position,
containerTop,
containerHeight,
popoverHeight,
overlapped,
containerPureTop,
fixed
}) => {
if (position === POSITIONS.TOP) {
return css(["top:", "px;"], Math.floor((fixed ? containerPureTop : containerTop) - popoverHeight - (overlapped ? -containerHeight : POPOVER_SPACE_BETWEEN)));
}
if (position === POSITIONS.BOTTOM) {
return css(["top:", "px;"], Math.floor((fixed ? containerPureTop : containerTop) + (overlapped ? 0 : containerHeight + POPOVER_SPACE_BETWEEN)));
}
return null;
};
export default resolvePopoverPosition;