@kiwicom/orbit-components
Version:
<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"
36 lines (29 loc) • 1.41 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTokens from "../defaultTokens";
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 }) => 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"
})(["height:", ";width:auto;background-color:transparent;"], ({ theme, size }) => getHeight(theme, size));
StyledServiceLogo.defaultProps = {
theme: defaultTokens
};
const ServiceLogo = ({ name, size = SIZE_OPTIONS.MEDIUM, grayScale = false, dataTest }) => React.createElement(StyledServiceLogo, { name: name, size: size, grayScale: grayScale, dataTest: dataTest });
export default ServiceLogo;