@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 (80 loc) • 3.91 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
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");
const getBackground = ({
theme,
$type
}) => {
const tokens = {
[_consts.default.NEUTRAL]: theme.orbit.paletteCloudLight,
[_consts.default.INFO]: theme.orbit.paletteBlueLight,
[_consts.default.SUCCESS]: theme.orbit.paletteGreenLight,
[_consts.default.WARNING]: theme.orbit.paletteOrangeLight,
[_consts.default.CRITICAL]: theme.orbit.paletteRedLight
};
return tokens[$type];
};
const getIconColor = type => {
if (type === _consts.default.NEUTRAL) return _consts2.ICON_COLORS.SECONDARY;
return type;
};
const StyledBadgeListItem = _styledComponents.default.li.withConfig({
displayName: "BadgeListItem__StyledBadgeListItem",
componentId: "sc-1et93id-0"
})(["", ";"], ({
theme
}) => (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
};
const StyledVerticalBadge = _styledComponents.default.div.withConfig({
displayName: "BadgeListItem__StyledVerticalBadge",
componentId: "sc-1et93id-1"
})(["", ";"], ({
theme
}) => (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
};
const StyledVerticalBadgeContent = _styledComponents.default.div.withConfig({
displayName: "BadgeListItem__StyledVerticalBadgeContent",
componentId: "sc-1et93id-2"
})(["", ";"], ({
theme
}) => (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
};
const BadgeListItem = ({
icon,
type = _consts.default.NEUTRAL,
dataTest,
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;