@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 (19 loc) • 897 B
JavaScript
import { css } from "styled-components";
import { POSITIONS, POPOVER_SPACE_BETWEEN } from "../consts";
var resolvePopoverPosition = function resolvePopoverPosition(_ref) {
var position = _ref.position,
containerTop = _ref.containerTop,
containerHeight = _ref.containerHeight,
popoverHeight = _ref.popoverHeight,
overlapped = _ref.overlapped,
containerPureTop = _ref.containerPureTop,
fixed = _ref.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;