UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

64 lines (55 loc) 2.83 kB
import _values from "lodash/values"; import _keys from "lodash/keys"; function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from 'react'; import PropTypes from 'react-peek/prop-types'; import { lucidClassNames } from '../../util/style-helpers'; import { omitProps } from '../../util/component-types'; var cx = lucidClassNames.bind('&-Badge'); var node = PropTypes.node, string = PropTypes.string, oneOf = PropTypes.oneOf; export var Kind; (function (Kind) { Kind["default"] = "default"; Kind["primary"] = "primary"; Kind["success"] = "success"; Kind["danger"] = "danger"; Kind["warning"] = "warning"; Kind["info"] = "info"; Kind["dark"] = "dark"; })(Kind || (Kind = {})); export var Type; (function (Type) { Type["filled"] = "filled"; Type["stroke"] = "stroke"; })(Type || (Type = {})); var defaultProps = { kind: Kind.default, type: Type.filled }; export var Badge = function Badge(props) { var className = props.className, kind = props.kind, type = props.type, children = props.children, passThroughs = _objectWithoutProperties(props, ["className", "kind", "type", "children"]); return /*#__PURE__*/React.createElement("span", _extends({ className: cx('&', "&-".concat(kind), "&-".concat(type), className) }, omitProps(passThroughs, undefined, _keys(Badge.propTypes))), children); }; Badge.defaultProps = defaultProps; Badge.displayName = 'Badge'; Badge.peek = { description: "\n\t\t\t\t`Badge` is a quick utility component to create a badge around any\n\t\t\t\telement(s).\n\t\t\t", categories: ['visual design', 'icons'] }; Badge.propTypes = { className: string, children: node, kind: oneOf(_values(Kind)), type: oneOf(_values(Type)) }; export default Badge;