@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.
46 lines • 1.45 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTheme from "../defaultTheme";
import { HEIGHT, TYPE_OPTIONS, LANGUAGE } from "./consts";
const StyledButtonMobileStore = styled.a.withConfig({
displayName: "ButtonMobileStore__StyledButtonMobileStore",
componentId: "sc-1qhdbt4-0"
})(["display:inline-block;height:", ";"], HEIGHT);
StyledButtonMobileStore.defaultProps = {
theme: defaultTheme
};
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 = TYPE_OPTIONS.APPSTORE,
lang = LANGUAGE.EN,
href,
onClick,
dataTest,
id,
alt = "",
stopPropagation = false
}) => {
const onClickHandler = ev => {
if (stopPropagation) {
ev.stopPropagation();
if (onClick) onClick(ev);
}
if (onClick) onClick(ev);
};
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: HEIGHT,
alt: alt
}));
};
export default ButtonMobileStore;