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.

49 lines (48 loc) 1.46 kB
"use strict"; "use client"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; exports.__esModule = true; exports.default = void 0; var _react = _interopRequireDefault(require("react")); var _clsx = _interopRequireDefault(require("clsx")); var _consts = require("./consts"); const heightClasses = { [_consts.SIZE_OPTIONS.SMALL]: "h-300", [_consts.SIZE_OPTIONS.MEDIUM]: "h-600", [_consts.SIZE_OPTIONS.LARGE]: "h-1200" }; const getColorUrlParam = greyScale => greyScale ? "logos-grayscale" : "logos"; const getSizeUrlParams = size => { const sizes = { [_consts.SIZE_OPTIONS.SMALL]: [12, 24], [_consts.SIZE_OPTIONS.MEDIUM]: [24, 48], [_consts.SIZE_OPTIONS.LARGE]: [48, 96] }; return { lowRes: `0x${sizes[size][0]}`, highRes: `0x${sizes[size][1]}` }; }; const ServiceLogo = ({ name, size = _consts.SIZE_OPTIONS.MEDIUM, grayScale = false, dataTest, alt = "", id }) => { const color = getColorUrlParam(grayScale); const { lowRes, highRes } = getSizeUrlParams(size); return /*#__PURE__*/_react.default.createElement("img", { className: (0, _clsx.default)("orbit-service-logo w-auto bg-transparent", heightClasses[size]), src: `${_consts.baseURL}/${color}/${lowRes}/${name}.png`, srcSet: `${_consts.baseURL}/${color}/${highRes}/${name}.png 2x`, alt: alt, id: id, "data-test": dataTest }); }; var _default = exports.default = ServiceLogo;