@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.
43 lines (32 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _styledComponents = require("styled-components");
var _isPosition = require("./isPosition");
var _consts = require("../consts");
var resolveContainerPosition = function resolveContainerPosition(_ref) {
var position = _ref.position,
containerTop = _ref.containerTop,
containerLeft = _ref.containerLeft,
containerHeight = _ref.containerHeight,
containerWidth = _ref.containerWidth,
tooltipHeight = _ref.tooltipHeight,
tooltipWidth = _ref.tooltipWidth;
if ((0, _isPosition.isPositionTop)(position)) {
return (0, _styledComponents.css)(["top:", "px;"], Math.floor(containerTop - tooltipHeight - parseFloat(_consts.TOOLTIP_ARROW_SIZE)));
}
if ((0, _isPosition.isPositionBottom)(position)) {
return (0, _styledComponents.css)(["top:", "px;"], Math.floor(containerTop + containerHeight + parseFloat(_consts.TOOLTIP_ARROW_SIZE)));
}
if ((0, _isPosition.isPositionRight)(position)) {
return (0, _styledComponents.css)(["left:", "px;"], Math.floor(containerLeft + containerWidth + parseFloat(_consts.TOOLTIP_ARROW_SIZE)));
}
if ((0, _isPosition.isPositionLeft)(position)) {
return (0, _styledComponents.css)(["left:", "px;"], Math.floor(containerLeft - tooltipWidth - parseFloat(_consts.TOOLTIP_ARROW_SIZE)));
}
return null;
};
var _default = resolveContainerPosition;
exports.default = _default;