@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.
52 lines (51 loc) • 1.28 kB
JavaScript
"use client";
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from "react";
import styled from "styled-components";
import defaultTheme from "../defaultTheme";
import { baseURL } from "./consts";
const baseSize = 52;
const getURL = name => (size = 1) => {
const url = `${baseURL}/feature-icons/${baseSize * size}x${baseSize * size}/${name}.png`;
if (size > 1) {
return `${url} ${size}x`;
}
return url;
};
const generateURL = name => {
const urlWithName = getURL(name);
return {
src: urlWithName(),
srcSet: [urlWithName(2), urlWithName(3)].join(",")
};
};
export const StyledFeatureIcon = styled(({
className,
name,
alt,
dataTest,
id
}) => /*#__PURE__*/React.createElement("img", _extends({
className: className,
alt: alt,
"data-test": dataTest,
id: id
}, generateURL(name)))).withConfig({
displayName: "FeatureIcon__StyledFeatureIcon",
componentId: "sc-8d499j-0"
})(["height:", "px;width:auto;background-color:transparent;"], baseSize);
StyledFeatureIcon.defaultProps = {
theme: defaultTheme
};
const FeatureIcon = ({
alt = "",
name,
dataTest,
id
}) => /*#__PURE__*/React.createElement(StyledFeatureIcon, {
alt: alt,
name: name,
dataTest: dataTest,
id: id
});
export default FeatureIcon;