@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.
104 lines (78 loc) • 4.54 kB
JavaScript
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var React = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _Text = _interopRequireWildcard(require("../../Text"));
var _consts = _interopRequireDefault(require("../consts"));
var _defaultTheme = _interopRequireDefault(require("../../defaultTheme"));
var _consts2 = require("../../Icon/consts");
var _TooltipPrimitive = require("../../primitives/TooltipPrimitive");
var _rtl = require("../../utils/rtl");
var getBackground = function getBackground(_ref) {
var _tokens;
var theme = _ref.theme,
$type = _ref.$type;
var tokens = (_tokens = {}, (0, _defineProperty2.default)(_tokens, _consts.default.NEUTRAL, theme.orbit.paletteCloudLight), (0, _defineProperty2.default)(_tokens, _consts.default.INFO, theme.orbit.paletteBlueLight), (0, _defineProperty2.default)(_tokens, _consts.default.SUCCESS, theme.orbit.paletteGreenLight), (0, _defineProperty2.default)(_tokens, _consts.default.WARNING, theme.orbit.paletteOrangeLight), (0, _defineProperty2.default)(_tokens, _consts.default.CRITICAL, theme.orbit.paletteRedLight), _tokens);
return tokens[$type];
};
var getIconColor = function getIconColor(type) {
if (type === _consts.default.NEUTRAL) return _consts2.ICON_COLORS.SECONDARY;
return type;
};
var StyledBadgeListItem = _styledComponents.default.li.withConfig({
displayName: "BadgeListItem__StyledBadgeListItem",
componentId: "sc-1u4ebh6-0"
})(["", ";"], function (_ref2) {
var theme = _ref2.theme;
return (0, _styledComponents.css)(["display:flex;flex-direction:row;width:100%;& + &{margin-top:", ";}"], theme.orbit.spaceXXSmall);
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledBadgeListItem.defaultProps = {
theme: _defaultTheme.default
};
var StyledVerticalBadge = _styledComponents.default.div.withConfig({
displayName: "BadgeListItem__StyledVerticalBadge",
componentId: "sc-1u4ebh6-1"
})(["", ";"], function (_ref3) {
var theme = _ref3.theme;
return (0, _styledComponents.css)(["background:", ";display:flex;align-items:center;justify-content:center;margin-", ":", ";flex-shrink:0;height:", ";width:", ";border-radius:", ";svg{height:", ";width:", ";}"], getBackground, _rtl.right, theme.orbit.spaceXSmall, theme.orbit.heightIconMedium, theme.orbit.widthIconMedium, theme.orbit.borderRadiusCircle, theme.orbit.heightIconSmall, theme.orbit.widthIconSmall);
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledVerticalBadge.defaultProps = {
theme: _defaultTheme.default
};
var StyledVerticalBadgeContent = _styledComponents.default.div.withConfig({
displayName: "BadgeListItem__StyledVerticalBadgeContent",
componentId: "sc-1u4ebh6-2"
})(["", ";"], function (_ref4) {
var theme = _ref4.theme;
return (0, _styledComponents.css)(["display:inline-flex;align-items:center;&,", "{font-size:", ";line-height:", ";}", " ", "{font-weight:", ";}"], _Text.StyledText, theme.orbit.fontSizeTextSmall, theme.orbit.lineHeightTextSmall, _TooltipPrimitive.StyledTooltipChildren, _Text.StyledText, theme.orbit.fontWeightMedium);
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledVerticalBadgeContent.defaultProps = {
theme: _defaultTheme.default
};
var BadgeListItem = function BadgeListItem(_ref5) {
var icon = _ref5.icon,
_ref5$type = _ref5.type,
type = _ref5$type === void 0 ? _consts.default.NEUTRAL : _ref5$type,
dataTest = _ref5.dataTest,
children = _ref5.children;
return /*#__PURE__*/React.createElement(StyledBadgeListItem, {
"data-test": dataTest
}, /*#__PURE__*/React.createElement(StyledVerticalBadge, {
$type: type,
"aria-hidden": true
}, /*#__PURE__*/React.isValidElement(icon) && /*#__PURE__*/React.cloneElement(icon, {
color: getIconColor(type)
})), /*#__PURE__*/React.createElement(StyledVerticalBadgeContent, null, /*#__PURE__*/React.createElement(_Text.default, {
type: "secondary",
size: "small",
as: "span"
}, children)));
};
var _default = BadgeListItem;
exports.default = _default;