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.

76 lines (61 loc) 3.08 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.StyledImage = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var React = _interopRequireWildcard(require("react")); var _styledComponents = _interopRequireDefault(require("styled-components")); var _defaultTheme = _interopRequireDefault(require("../../defaultTheme")); var _consts = require("./consts"); var _getSpacingToken = _interopRequireDefault(require("../../common/getSpacingToken")); var getHeightToken = function getHeightToken(_ref) { var _tokens; var theme = _ref.theme, size = _ref.size; var tokens = (_tokens = {}, (0, _defineProperty2.default)(_tokens, _consts.SIZE_OPTIONS.EXTRASMALL, theme.orbit.heightIllustrationSmall), (0, _defineProperty2.default)(_tokens, _consts.SIZE_OPTIONS.SMALL, "120px"), (0, _defineProperty2.default)(_tokens, _consts.SIZE_OPTIONS.MEDIUM, theme.orbit.heightIllustrationMedium), (0, _defineProperty2.default)(_tokens, _consts.SIZE_OPTIONS.LARGE, "280px"), (0, _defineProperty2.default)(_tokens, _consts.SIZE_OPTIONS.DISPLAY, "460px"), _tokens); return tokens[size]; }; var StyledImage = _styledComponents.default.img.attrs(function (_ref2) { var theme = _ref2.theme, size = _ref2.size, illustrationName = _ref2.illustrationName; var height = parseInt(getHeightToken({ theme: theme, size: size }), 10); var illustrationPath = "".concat(illustrationName, "-Q85.png"); return { src: "".concat(_consts.baseURL, "/illustrations/0x").concat(height, "/").concat(illustrationPath), srcSet: "".concat(_consts.baseURL, "/illustrations/0x").concat(height * 2, "/").concat(illustrationPath, " 2x, ").concat(_consts.baseURL, "/illustrations/0x").concat(height * 3, "/").concat(illustrationPath, " 3x") }; }).withConfig({ displayName: "IllustrationPrimitive__StyledImage", componentId: "sc-2hh260-0" })(["display:inline-block;margin:auto 0;max-height:", ";max-width:100%;background-color:", ";margin-bottom:", ";flex-shrink:0;"], getHeightToken, function (_ref3) { var theme = _ref3.theme; return theme.orbit.backgroundIllustration; }, _getSpacingToken.default); exports.StyledImage = StyledImage; StyledImage.defaultProps = { theme: _defaultTheme.default }; var IllustrationPrimitive = function IllustrationPrimitive(_ref4) { var name = _ref4.name, alt = _ref4.alt, _ref4$size = _ref4.size, size = _ref4$size === void 0 ? _consts.SIZE_OPTIONS.MEDIUM : _ref4$size, dataTest = _ref4.dataTest, spaceAfter = _ref4.spaceAfter; return /*#__PURE__*/React.createElement(StyledImage, { illustrationName: name, alt: typeof alt === "string" ? alt : name, size: size, "data-test": dataTest, spaceAfter: spaceAfter }); }; var _default = IllustrationPrimitive; exports.default = _default;