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.

56 lines (50 loc) 1.58 kB
import * as React from "react"; import styled from "styled-components"; import defaultTheme from "../defaultTheme"; import { SIZE_OPTIONS, baseURL } from "./consts"; const getHeight = (theme, size) => { const tokens = { height: { [SIZE_OPTIONS.SMALL]: theme.orbit.heightServiceLogoSmall, [SIZE_OPTIONS.MEDIUM]: theme.orbit.heightServiceLogoMedium, [SIZE_OPTIONS.LARGE]: theme.orbit.heightServiceLogoLarge } }; return tokens.height[size]; }; const getColor = greyScale => greyScale ? "logos-grayscale" : "logos"; export const StyledServiceLogo = styled(({ className, name, size, grayScale, theme, dataTest }) => /*#__PURE__*/React.createElement("img", { className: className, src: `${baseURL}/${getColor(grayScale)}/0x${parseInt(getHeight(theme, size), 10)}/${name}.png`, srcSet: `${baseURL}/${getColor(grayScale)}/0x${parseInt(getHeight(theme, size), 10) * 2}/${name}.png 2x`, alt: name, "data-test": dataTest })).withConfig({ displayName: "ServiceLogo__StyledServiceLogo", componentId: "sc-1v8dmk4-0" })(["height:", ";width:auto;background-color:transparent;"], ({ theme, size }) => getHeight(theme, size)); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledServiceLogo.defaultProps = { theme: defaultTheme }; const ServiceLogo = ({ name, size = SIZE_OPTIONS.MEDIUM, grayScale = false, dataTest }) => /*#__PURE__*/React.createElement(StyledServiceLogo, { name: name, size: size, grayScale: grayScale, dataTest: dataTest }); export default ServiceLogo;