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.

76 lines (61 loc) 2.31 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; exports.__esModule = true; exports.default = void 0; var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var React = _interopRequireWildcard(require("react")); var _styledComponents = _interopRequireDefault(require("styled-components")); var _defaultTheme = _interopRequireDefault(require("../defaultTheme")); var _consts = require("./consts"); const _excluded = ["theme", "type"]; const StyledButtonMobileStore = (0, _styledComponents.default)(_ref => { let { theme, type } = _ref, props = (0, _objectWithoutProperties2.default)(_ref, _excluded); return /*#__PURE__*/React.createElement("a", props, props.children); }).withConfig({ displayName: "ButtonMobileStore__StyledButtonMobileStore", componentId: "sc-117vdh7-0" })(["display:inline-block;height:", ";"], _consts.HEIGHT); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledButtonMobileStore.defaultProps = { theme: _defaultTheme.default }; const getSrc = (type, lang) => { if (type === "appStore") return `https://images.kiwi.com/common/AppStoreButton${lang}.png, https://images.kiwi.com/common/AppStoreButton${lang}@2x.png 2x`; return `https://images.kiwi.com/common/GooglePlayButton${lang}.png, https://images.kiwi.com/common/GooglePlayButton${lang}@2x.png 2x`; }; const ButtonMobileStore = ({ type = _consts.TYPE_OPTIONS.APPSTORE, lang = _consts.LANGUAGE.EN, href, onClick, dataTest, id, alt = "", stopPropagation = false }) => { const onClickHandler = ev => { if (stopPropagation) { ev.stopPropagation(); if (onClick) onClick(); } if (onClick) onClick(); }; return /*#__PURE__*/React.createElement(StyledButtonMobileStore, { href: href, target: "_blank", rel: "noopener", onClick: onClickHandler, "data-test": dataTest, id: id }, /*#__PURE__*/React.createElement("img", { srcSet: getSrc(type, lang), height: _consts.HEIGHT, alt: alt })); }; var _default = ButtonMobileStore; exports.default = _default;