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.

62 lines (55 loc) 2.31 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import * as React from "react"; import styled from "styled-components"; import defaultTheme from "../defaultTheme"; import { SIZE_OPTIONS, baseURL } from "./consts"; var getHeight = function getHeight(theme, size) { var _height; var tokens = { height: (_height = {}, _defineProperty(_height, SIZE_OPTIONS.SMALL, theme.orbit.heightServiceLogoSmall), _defineProperty(_height, SIZE_OPTIONS.MEDIUM, theme.orbit.heightServiceLogoMedium), _defineProperty(_height, SIZE_OPTIONS.LARGE, theme.orbit.heightServiceLogoLarge), _height) }; return tokens.height[size]; }; var getColor = function getColor(greyScale) { return greyScale ? "logos-grayscale" : "logos"; }; export var StyledServiceLogo = styled(function (_ref) { var className = _ref.className, name = _ref.name, size = _ref.size, grayScale = _ref.grayScale, theme = _ref.theme, dataTest = _ref.dataTest; return /*#__PURE__*/React.createElement("img", { className: className, src: "".concat(baseURL, "/").concat(getColor(grayScale), "/0x").concat(parseInt(getHeight(theme, size), 10), "/").concat(name, ".png"), srcSet: "".concat(baseURL, "/").concat(getColor(grayScale), "/0x").concat(parseInt(getHeight(theme, size), 10) * 2, "/").concat(name, ".png 2x"), alt: name, "data-test": dataTest }); }).withConfig({ displayName: "ServiceLogo__StyledServiceLogo", componentId: "sc-1ujs7cw-0" })(["height:", ";width:auto;background-color:transparent;"], function (_ref2) { var theme = _ref2.theme, size = _ref2.size; return getHeight(theme, size); }); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledServiceLogo.defaultProps = { theme: defaultTheme }; var ServiceLogo = function ServiceLogo(_ref3) { var name = _ref3.name, _ref3$size = _ref3.size, size = _ref3$size === void 0 ? SIZE_OPTIONS.MEDIUM : _ref3$size, _ref3$grayScale = _ref3.grayScale, grayScale = _ref3$grayScale === void 0 ? false : _ref3$grayScale, dataTest = _ref3.dataTest; return /*#__PURE__*/React.createElement(StyledServiceLogo, { name: name, size: size, grayScale: grayScale, dataTest: dataTest }); }; export default ServiceLogo;