UNPKG

@coreui/react

Version:

UI Components Library for React.js

37 lines (34 loc) 2.02 kB
import { __rest, __assign } from '../../node_modules/tslib/tslib.es6.js'; import React, { forwardRef } from 'react'; import PropTypes from 'prop-types'; import classNames from '../../_virtual/index.js'; import { textColorsPropType, colorPropType, shapePropType } from '../../props.js'; var CBadge = forwardRef(function (_a, ref) { var _b; var children = _a.children, _c = _a.as, Component = _c === void 0 ? 'span' : _c, className = _a.className, color = _a.color, position = _a.position, shape = _a.shape, size = _a.size, textBgColor = _a.textBgColor, textColor = _a.textColor, rest = __rest(_a, ["children", "as", "className", "color", "position", "shape", "size", "textBgColor", "textColor"]); return (React.createElement(Component, __assign({ className: classNames('badge', (_b = {}, _b["bg-".concat(color)] = color, _b['position-absolute translate-middle'] = position, _b['top-0'] = position === null || position === void 0 ? void 0 : position.includes('top'), _b['top-100'] = position === null || position === void 0 ? void 0 : position.includes('bottom'), _b['start-100'] = position === null || position === void 0 ? void 0 : position.includes('end'), _b['start-0'] = position === null || position === void 0 ? void 0 : position.includes('start'), _b["badge-".concat(size)] = size, _b["text-".concat(textColor)] = textColor, _b["text-bg-".concat(textBgColor)] = textBgColor, _b), shape, className) }, rest, { ref: ref }), children)); }); CBadge.propTypes = { as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, color: colorPropType, position: PropTypes.oneOf(['top-start', 'top-end', 'bottom-end', 'bottom-start']), shape: shapePropType, size: PropTypes.oneOf(['sm']), textBgColor: colorPropType, textColor: textColorsPropType, }; CBadge.displayName = 'CBadge'; export { CBadge }; //# sourceMappingURL=CBadge.js.map