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.

79 lines (70 loc) 3.79 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import * as React from "react"; import styled, { css } from "styled-components"; import Text, { StyledText } from "../../Text"; import TYPE_OPTIONS from "../consts"; import defaultTheme from "../../defaultTheme"; import { ICON_COLORS } from "../../Icon/consts"; import { StyledTooltipChildren } from "../../primitives/TooltipPrimitive"; import { right } from "../../utils/rtl"; var getBackground = function getBackground(_ref) { var _tokens; var theme = _ref.theme, $type = _ref.$type; var tokens = (_tokens = {}, _defineProperty(_tokens, TYPE_OPTIONS.NEUTRAL, theme.orbit.paletteCloudLight), _defineProperty(_tokens, TYPE_OPTIONS.INFO, theme.orbit.paletteBlueLight), _defineProperty(_tokens, TYPE_OPTIONS.SUCCESS, theme.orbit.paletteGreenLight), _defineProperty(_tokens, TYPE_OPTIONS.WARNING, theme.orbit.paletteOrangeLight), _defineProperty(_tokens, TYPE_OPTIONS.CRITICAL, theme.orbit.paletteRedLight), _tokens); return tokens[$type]; }; var getIconColor = function getIconColor(type) { if (type === TYPE_OPTIONS.NEUTRAL) return ICON_COLORS.SECONDARY; return type; }; var StyledBadgeListItem = styled.li.withConfig({ displayName: "BadgeListItem__StyledBadgeListItem", componentId: "sc-1u4ebh6-0" })(["", ";"], function (_ref2) { var theme = _ref2.theme; return 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 }; var StyledVerticalBadge = styled.div.withConfig({ displayName: "BadgeListItem__StyledVerticalBadge", componentId: "sc-1u4ebh6-1" })(["", ";"], function (_ref3) { var theme = _ref3.theme; return css(["background:", ";display:flex;align-items:center;justify-content:center;margin-", ":", ";flex-shrink:0;height:", ";width:", ";border-radius:", ";svg{height:", ";width:", ";}"], getBackground, 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 }; var StyledVerticalBadgeContent = styled.div.withConfig({ displayName: "BadgeListItem__StyledVerticalBadgeContent", componentId: "sc-1u4ebh6-2" })(["", ";"], function (_ref4) { var theme = _ref4.theme; return css(["display:inline-flex;align-items:center;&,", "{font-size:", ";line-height:", ";}", " ", "{font-weight:", ";}"], StyledText, theme.orbit.fontSizeTextSmall, theme.orbit.lineHeightTextSmall, StyledTooltipChildren, StyledText, theme.orbit.fontWeightMedium); }); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198 StyledVerticalBadgeContent.defaultProps = { theme: defaultTheme }; var BadgeListItem = function BadgeListItem(_ref5) { var icon = _ref5.icon, _ref5$type = _ref5.type, type = _ref5$type === void 0 ? TYPE_OPTIONS.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, { type: "secondary", size: "small", as: "span" }, children))); }; export default BadgeListItem;