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.

113 lines (95 loc) 4.28 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.getSize = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var React = _interopRequireWildcard(require("react")); var _styledComponents = _interopRequireWildcard(require("styled-components")); var _consts = require("./consts"); var _defaultTheme = _interopRequireDefault(require("../defaultTheme")); var getSize = function getSize(size) { return function (_ref) { var _tokens; var theme = _ref.theme; var tokens = (_tokens = {}, (0, _defineProperty2.default)(_tokens, _consts.ICON_SIZES.SMALL, theme.orbit.widthIconSmall), (0, _defineProperty2.default)(_tokens, _consts.ICON_SIZES.MEDIUM, theme.orbit.widthIconMedium), (0, _defineProperty2.default)(_tokens, _consts.ICON_SIZES.LARGE, theme.orbit.widthIconLarge), _tokens); return tokens[size] || tokens[_consts.ICON_SIZES.MEDIUM]; }; }; exports.getSize = getSize; var getColor = function getColor() { return function (_ref2) { var _tokens2; var theme = _ref2.theme, color = _ref2.color; var tokens = (_tokens2 = {}, (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.PRIMARY, theme.orbit.colorIconPrimary), (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.SECONDARY, theme.orbit.colorIconSecondary), (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.TERTIARY, theme.orbit.colorIconTertiary), (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.INFO, theme.orbit.colorIconInfo), (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.SUCCESS, theme.orbit.colorIconSuccess), (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.WARNING, theme.orbit.colorIconWarning), (0, _defineProperty2.default)(_tokens2, _consts.ICON_COLORS.CRITICAL, theme.orbit.colorIconCritical), _tokens2); return tokens[color]; }; }; var reverse = function reverse(_ref3) { var reverseOnRtl = _ref3.reverseOnRtl, theme = _ref3.theme; return reverseOnRtl && theme.rtl && (0, _styledComponents.css)(["transform:scale(-1,1);"]); }; var StyledIcon = (0, _styledComponents.default)(function (_ref4) { var className = _ref4.className, viewBox = _ref4.viewBox, dataTest = _ref4.dataTest, children = _ref4.children, ariaHidden = _ref4.ariaHidden, ariaLabel = _ref4.ariaLabel; return /*#__PURE__*/React.createElement("svg", { className: className, viewBox: viewBox, "data-test": dataTest, preserveAspectRatio: "xMidYMid meet", "aria-hidden": ariaHidden ? "true" : undefined, "aria-label": ariaLabel }, children); }).withConfig({ displayName: "Icon__StyledIcon", componentId: "sc-1pnzn3g-0" })(["display:inline-block;width:", ";height:", ";flex-shrink:0;vertical-align:middle;fill:currentColor;color:", ";", ";"], function (_ref5) { var size = _ref5.size; return getSize(size); }, function (_ref6) { var size = _ref6.size; return getSize(size); }, function (_ref7) { var color = _ref7.color, customColor = _ref7.customColor; return customColor || color && getColor(); }, reverse); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledIcon.defaultProps = { theme: _defaultTheme.default }; var OrbitIcon = function OrbitIcon(props) { var size = props.size, color = props.color, customColor = props.customColor, className = props.className, children = props.children, viewBox = props.viewBox, dataTest = props.dataTest, ariaHidden = props.ariaHidden, reverseOnRtl = props.reverseOnRtl, ariaLabel = props.ariaLabel; return /*#__PURE__*/React.createElement(StyledIcon, { viewBox: viewBox, size: size, className: className, dataTest: dataTest, customColor: customColor, color: color, ariaHidden: ariaHidden, reverseOnRtl: reverseOnRtl, ariaLabel: ariaLabel }, children); }; OrbitIcon.defaultProps = { size: _consts.ICON_SIZES.MEDIUM }; var _default = OrbitIcon; exports.default = _default;