25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
  3. import React from 'react';
  4. import PropTypes from 'prop-types';
  5. import classNames from 'classnames';
  6. import { mapToCssModules, tagPropType } from './utils';
  7. var propTypes = {
  8. color: PropTypes.string,
  9. pill: PropTypes.bool,
  10. tag: tagPropType,
  11. innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  12. children: PropTypes.node,
  13. className: PropTypes.string,
  14. cssModule: PropTypes.object
  15. };
  16. var defaultProps = {
  17. color: 'secondary',
  18. pill: false,
  19. tag: 'span'
  20. };
  21. var Badge = function Badge(props) {
  22. var className = props.className,
  23. cssModule = props.cssModule,
  24. color = props.color,
  25. innerRef = props.innerRef,
  26. pill = props.pill,
  27. Tag = props.tag,
  28. attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "color", "innerRef", "pill", "tag"]);
  29. var classes = mapToCssModules(classNames(className, 'badge', 'badge-' + color, pill ? 'badge-pill' : false), cssModule);
  30. if (attributes.href && Tag === 'span') {
  31. Tag = 'a';
  32. }
  33. return React.createElement(Tag, _extends({}, attributes, {
  34. className: classes,
  35. ref: innerRef
  36. }));
  37. };
  38. Badge.propTypes = propTypes;
  39. Badge.defaultProps = defaultProps;
  40. export default Badge;