forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTag.js
More file actions
45 lines (38 loc) · 861 Bytes
/
Copy pathTag.js
File metadata and controls
45 lines (38 loc) · 861 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
import React, { PropTypes } from 'react';
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: 'default',
pill: false,
tag: 'span'
};
const Tag = (props) => {
const {
className,
cssModule,
color,
pill,
tag: Component,
...attributes
} = props;
const classes = mapToCssModules(classNames(
className,
'tag',
'tag-' + color,
pill ? 'tag-pill' : false
), cssModule);
return (
<Component {...attributes} className={classes} />
);
};
Tag.propTypes = propTypes;
Tag.defaultProps = defaultProps;
export default Tag;