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.

45 lines (44 loc) 1.14 kB
"use client"; import React from "react"; import cx from "clsx"; import { SIZE_OPTIONS, baseURL } from "./consts"; const heightClasses = { [SIZE_OPTIONS.SMALL]: "h-300", [SIZE_OPTIONS.MEDIUM]: "h-600", [SIZE_OPTIONS.LARGE]: "h-1200" }; const getColorUrlParam = greyScale => greyScale ? "logos-grayscale" : "logos"; const getSizeUrlParams = size => { const sizes = { [SIZE_OPTIONS.SMALL]: [12, 24], [SIZE_OPTIONS.MEDIUM]: [24, 48], [SIZE_OPTIONS.LARGE]: [48, 96] }; return { lowRes: `0x${sizes[size][0]}`, highRes: `0x${sizes[size][1]}` }; }; const ServiceLogo = ({ name, size = SIZE_OPTIONS.MEDIUM, grayScale = false, dataTest, alt = "", id }) => { const color = getColorUrlParam(grayScale); const { lowRes, highRes } = getSizeUrlParams(size); return /*#__PURE__*/React.createElement("img", { className: cx("orbit-service-logo w-auto bg-transparent", heightClasses[size]), src: `${baseURL}/${color}/${lowRes}/${name}.png`, srcSet: `${baseURL}/${color}/${highRes}/${name}.png 2x`, alt: alt, id: id, "data-test": dataTest }); }; export default ServiceLogo;