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.

56 lines (55 loc) 2.34 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.iconColorClasses = exports.getSize = exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _clsx = _interopRequireDefault(require("clsx")); var _consts = require("./consts"); const getSize = size => ({ theme }) => { const tokens = { [_consts.ICON_SIZES.SMALL]: theme.orbit.iconSmallSize, [_consts.ICON_SIZES.MEDIUM]: theme.orbit.iconMediumSize, [_consts.ICON_SIZES.LARGE]: theme.orbit.iconLargeSize, [_consts.ICON_SIZES.EXTRA_LARGE]: theme.orbit.iconExtraLargeSize }; return tokens[size] || tokens[_consts.ICON_SIZES.MEDIUM]; }; exports.getSize = getSize; const iconColorClasses = exports.iconColorClasses = { [_consts.ICON_COLORS.PRIMARY]: "text-icon-primary-foreground", [_consts.ICON_COLORS.SECONDARY]: "text-icon-secondary-foreground", [_consts.ICON_COLORS.TERTIARY]: "text-icon-tertiary-foreground", [_consts.ICON_COLORS.INFO]: "text-icon-info-foreground", [_consts.ICON_COLORS.SUCCESS]: "text-icon-success-foreground", [_consts.ICON_COLORS.WARNING]: "text-icon-warning-foreground", [_consts.ICON_COLORS.CRITICAL]: "text-icon-critical-foreground" }; const OrbitIcon = ({ size = _consts.ICON_SIZES.MEDIUM, color, customColor, className, children, viewBox, dataTest, ariaHidden, reverseOnRtl, ariaLabel }) => { return /*#__PURE__*/React.createElement("svg", { className: (0, _clsx.default)(className, "orbit-icon", "inline-block shrink-0 fill-current align-middle", reverseOnRtl && "rtl:-scale-x-100", size === _consts.ICON_SIZES.SMALL && "size-icon-small", size === _consts.ICON_SIZES.MEDIUM && "size-icon-medium", size === _consts.ICON_SIZES.LARGE && "size-icon-large", size === _consts.ICON_SIZES.EXTRA_LARGE && "size-icon-extra-large", !customColor && color && iconColorClasses[color]), viewBox: viewBox, preserveAspectRatio: "xMidYMid meet", "data-test": dataTest, "aria-hidden": ariaHidden ? "true" : undefined, "aria-label": ariaLabel, style: customColor ? { color: customColor } : {} }, children); }; var _default = exports.default = OrbitIcon;