forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputGroupButton.js
More file actions
56 lines (47 loc) · 1.23 KB
/
InputGroupButton.js
File metadata and controls
56 lines (47 loc) · 1.23 KB
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
51
52
53
54
55
56
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import { mapToCssModules } from './utils';
import Button from './Button';
const propTypes = {
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
children: PropTypes.node,
groupClassName: PropTypes.string,
groupAttributes: PropTypes.object,
className: PropTypes.string,
cssModule: PropTypes.object,
};
const defaultProps = {
tag: 'div'
};
const InputGroupButton = (props) => {
let {
className,
cssModule,
tag: Tag,
children,
groupClassName,
groupAttributes,
...attributes
} = props;
if (typeof children === 'string') {
const groupClasses = mapToCssModules(classNames(
groupClassName,
'input-group-btn'
), cssModule);
return (
<Tag {...groupAttributes} className={groupClasses}>
<Button {...attributes} className={className} children={children} />
</Tag>
);
}
const classes = mapToCssModules(classNames(
className,
'input-group-btn'
), cssModule);
return (
<Tag {...attributes} className={classes} children={children} />
);
};
InputGroupButton.propTypes = propTypes;
InputGroupButton.defaultProps = defaultProps;
export default InputGroupButton;