forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBadge.js
More file actions
50 lines (42 loc) · 947 Bytes
/
Copy pathBadge.js
File metadata and controls
50 lines (42 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules } from './utils';
const propTypes = {
color: PropTypes.string,
pill: PropTypes.bool,
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
children: PropTypes.node,
className: PropTypes.string,
cssModule: PropTypes.object,
};
const defaultProps = {
color: 'secondary',
pill: false,
tag: 'span'
};
const Badge = (props) => {
let {
className,
cssModule,
color,
pill,
tag: Tag,
...attributes
} = props;
const classes = mapToCssModules(classNames(
className,
'badge',
'badge-' + color,
pill ? 'badge-pill' : false
), cssModule);
if (attributes.href && Tag === 'span') {
Tag = 'a';
}
return (
<Tag {...attributes} className={classes} />
);
};
Badge.propTypes = propTypes;
Badge.defaultProps = defaultProps;
export default Badge;