UNPKG

@s-ui/react-atom-badge

Version:
60 lines (58 loc) 1.7 kB
import cx from 'classnames'; export var MAX_LABEL_LENGTH = 100; export var TRANSPARENT = 'transparent'; export var SIZES = { LARGE: 'large', MEDIUM: 'medium', SMALL: 'small' }; export var TYPES = { SUCCESS: 'success', ERROR: 'error', INFO: 'info', ALERT: 'alert', NEW: 'new', NEUTRAL: 'neutral', PRIMARY: 'primary', SECONDARY: 'secondary' }; export var DESIGNS = { SOLID: 'solid', SOFT: 'soft' }; export var BASE_CLASS = "sui-AtomBadge"; export var CLASS_ICON = BASE_CLASS + "-icon"; export var CLASS_ICON_RIGHT = CLASS_ICON + "--iconRight"; export var CLASS_TEXT = CLASS_ICON + "-text"; /** * @param {object} options * @param {string} options.size * @param {boolean} options.transparent * @param {object} options.iconRight * @param {string} options.type * @return {string} */ export var getClassNames = function getClassNames(_ref) { var _cx; var design = _ref.design, iconRight = _ref.iconRight, size = _ref.size, isTransparent = _ref.transparent, type = _ref.type, className = _ref.className; return cx(BASE_CLASS, BASE_CLASS + "-size-" + size, BASE_CLASS + "-type-" + type, BASE_CLASS + "-design-" + design, (_cx = {}, _cx[BASE_CLASS + "--isTransparent"] = isTransparent, _cx), className); }; /** * Small badges with a background can't have an icon * @param {Object} options * @param {Object} options.icon * @param {string} options.size * @param {boolean} options.transparent * @return {boolean} */ export var shouldRenderIcon = function shouldRenderIcon(_ref2) { var icon = _ref2.icon, size = _ref2.size, transparent = _ref2.transparent; return Boolean(icon && (size !== SIZES.SMALL || transparent)); };