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.

50 lines (49 loc) 1.45 kB
"use client"; import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from "react"; import { TYPE_OPTIONS, LANGUAGE } from "./consts"; 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, title, stopPropagation = false }) => { const onClickHandler = ev => { if (stopPropagation) { ev.stopPropagation(); } if (onClick) onClick(ev); }; const commonProps = { className: "orbit-button-mobile-store h-1000 inline-block", onClick: onClickHandler, "data-test": dataTest, id }; const imageElement = /*#__PURE__*/React.createElement("img", { srcSet: getSrc(type, lang), height: "40px", alt: alt, title: title }); if (href) { return /*#__PURE__*/React.createElement("a", _extends({}, commonProps, { href: href, target: "_blank", rel: "noopener noreferrer" }), imageElement); } return /*#__PURE__*/React.createElement("button", _extends({}, commonProps, { type: "button" }), imageElement); }; export default ButtonMobileStore;