@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.
44 lines (33 loc) • 1.23 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _styledComponents = require("styled-components");
var _mediaQuery = _interopRequireDefault(require("../../utils/mediaQuery"));
var _consts = _interopRequireDefault(require("../consts"));
const computedWidth = (width, isPrefixed) => `${isPrefixed ? "-" : ""}${width}`;
const transitionCss = ({
width,
shown
}) => isPrefixed => {
return (0, _styledComponents.css)(["transform:translate3d(", ");", ";"], shown ? "0, 0, 0" : `${computedWidth("100%", isPrefixed)} , 0, 0`, _mediaQuery.default.largeMobile((0, _styledComponents.css)(["transform:translate3d(", ");"], shown ? "0, 0, 0" : `${computedWidth(width, isPrefixed)} , 0, 0`)));
};
const getTransitionAnimation = ({
width,
shown,
position,
theme
}) => {
const resultCss = transitionCss({
width,
shown
});
if (position === _consts.default.RIGHT && !theme.rtl || position === _consts.default.LEFT && theme.rtl) {
return resultCss(false);
}
return resultCss(true);
};
var _default = getTransitionAnimation;
exports.default = _default;