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.

58 lines (50 loc) 1.37 kB
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-1eir8gw-0" })(["height:", "px;width:auto;background-color:transparent;"], baseSize); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 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;