UNPKG

@coreui/react-pro

Version:

UI Components Library for React.js

36 lines (33 loc) 1.86 kB
import { __rest } 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, gradientsPropType } from '../../props.js'; const CBadge = forwardRef((_a, ref) => { var { children, as: Component = 'span', className, color, position, shape, size, textBgColor, textColor } = _a, rest = __rest(_a, ["children", "as", "className", "color", "position", "shape", "size", "textBgColor", "textColor"]); return (React.createElement(Component, Object.assign({ className: classNames('badge', { [`bg-${color}`]: color, 'position-absolute translate-middle': position, 'top-0': position === null || position === void 0 ? void 0 : position.includes('top'), 'top-100': position === null || position === void 0 ? void 0 : position.includes('bottom'), 'start-100': position === null || position === void 0 ? void 0 : position.includes('end'), 'start-0': position === null || position === void 0 ? void 0 : position.includes('start'), [`badge-${size}`]: size, [`text-${textColor}`]: textColor, [`text-bg-${textBgColor}`]: textBgColor, }, shape, className) }, rest, { ref: ref }), children)); }); CBadge.propTypes = { as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, color: PropTypes.oneOfType([colorPropType, gradientsPropType]), 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