@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.
65 lines (59 loc) • 2.13 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
const _excluded = ["theme", "type"];
import * as React from "react";
import styled from "styled-components";
import defaultTheme from "../defaultTheme";
import { TYPE_OPTIONS, HEIGHT, TYPE_VARIANT } from "./consts";
const StyledButtonMobileStore = styled((_ref) => {
let {
theme,
type
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement("a", props, props.children);
}).withConfig({
displayName: "ButtonMobileStore__StyledButtonMobileStore",
componentId: "sc-117vdh7-0"
})(["display:inline-block;height:", ";"], HEIGHT); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledButtonMobileStore.defaultProps = {
theme: defaultTheme
};
const src = {
[TYPE_VARIANT.DARK]: {
appStore: "https://images.kiwi.com/common/AppStoreGrayButton.png, https://images.kiwi.com/common/AppStoreGrayButton@2x.png 2x",
googlePlay: "https://images.kiwi.com/common/GooglePlayGrayButton.png, https://images.kiwi.com/common/GooglePlayGrayButton@2x.png 2x"
},
[TYPE_VARIANT.LIGHT]: {
appStore: "https://images.kiwi.com/common/AppStoreLightButton.png, https://images.kiwi.com/common/AppStoreLightButton@2x.png 2x",
googlePlay: "https://images.kiwi.com/common/GooglePlayLightButton.png, https://images.kiwi.com/common/GooglePlayLightButton@2x.png 2x"
}
};
const ButtonMobileStore = ({
type = TYPE_OPTIONS.APPSTORE,
variant = TYPE_VARIANT.DARK,
href,
onClick,
dataTest,
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
}, /*#__PURE__*/React.createElement("img", {
srcSet: src[variant][type],
height: HEIGHT,
alt: alt
}));
};
export default ButtonMobileStore;