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.

84 lines (83 loc) 3.21 kB
"use strict"; "use client"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; exports.__esModule = true; exports.getIconColor = exports.default = exports.VerticalBadge = exports.ItemWrapper = exports.BadgeContent = void 0; var React = _interopRequireWildcard(require("react")); var _clsx = _interopRequireDefault(require("clsx")); var _Text = _interopRequireDefault(require("../../Text")); var _consts = require("../consts"); var _consts2 = require("../../Icon/consts"); var _Icon = require("../../Icon"); const BACKGROUND = { [_consts.TYPE_OPTIONS.NEUTRAL]: "bg-badge-neutral-background", [_consts.TYPE_OPTIONS.INFO]: "bg-badge-info-subtle-background", [_consts.TYPE_OPTIONS.SUCCESS]: "bg-badge-success-subtle-background", [_consts.TYPE_OPTIONS.WARNING]: "bg-badge-warning-subtle-background", [_consts.TYPE_OPTIONS.CRITICAL]: "bg-badge-critical-subtle-background" }; const ICON_COLOR = { [_consts.TYPE_OPTIONS.NEUTRAL]: _Icon.iconColorClasses[_consts2.ICON_COLORS.SECONDARY], [_consts.TYPE_OPTIONS.INFO]: _Icon.iconColorClasses[_consts2.ICON_COLORS.INFO], [_consts.TYPE_OPTIONS.SUCCESS]: _Icon.iconColorClasses[_consts2.ICON_COLORS.SUCCESS], [_consts.TYPE_OPTIONS.WARNING]: _Icon.iconColorClasses[_consts2.ICON_COLORS.WARNING], [_consts.TYPE_OPTIONS.CRITICAL]: _Icon.iconColorClasses[_consts2.ICON_COLORS.CRITICAL] }; const getIconColor = type => { if (type === _consts.TYPE_OPTIONS.NEUTRAL) return _consts2.ICON_COLORS.SECONDARY; return type; }; exports.getIconColor = getIconColor; const ItemWrapper = ({ children, dataTest }) => /*#__PURE__*/React.createElement("li", { className: "orbit-badge-list-item flex w-full flex-row", "data-test": dataTest }, children); exports.ItemWrapper = ItemWrapper; const VerticalBadge = ({ icon, type, iconLabel }) => { return /*#__PURE__*/React.createElement("div", { className: (0, _clsx.default)("me-200 size-icon-large flex shrink-0 items-center justify-center rounded-full", "[&_svg]:size-icon-small", type && [BACKGROUND[type], ICON_COLOR[type]]), "aria-hidden": !iconLabel, "aria-label": iconLabel, role: iconLabel ? "img" : undefined }, icon); }; exports.VerticalBadge = VerticalBadge; const BadgeContent = ({ children, style }) => /*#__PURE__*/React.createElement("div", { className: "inline-flex items-center [&_.orbit-tooltip-wrapper_.orbit-text]:font-medium", style: style }, children); exports.BadgeContent = BadgeContent; const BadgeListItem = ({ icon, strikeThrough, type = _consts.TYPE_OPTIONS.NEUTRAL, size = _consts.SIZE_OPTIONS.SMALL, dataTest, children, iconLabel }) => { return /*#__PURE__*/React.createElement(ItemWrapper, { dataTest: dataTest }, /*#__PURE__*/React.createElement(VerticalBadge, { type: type, icon: icon, iconLabel: iconLabel }), /*#__PURE__*/React.createElement(BadgeContent, null, /*#__PURE__*/React.createElement(_Text.default, { type: "secondary", size: size, as: "span", strikeThrough: strikeThrough }, children))); }; var _default = exports.default = BadgeListItem;