1 | import React from 'react';
|
2 | import PropTypes from 'prop-types';
|
3 | import classNames from 'classnames';
|
4 | import { mapToCssModules, tagPropType } from './utils';
|
5 |
|
6 | const propTypes = {
|
7 |
|
8 | 'aria-label': PropTypes.string,
|
9 |
|
10 | className: PropTypes.string,
|
11 |
|
12 | cssModule: PropTypes.object,
|
13 |
|
14 | role: PropTypes.string,
|
15 |
|
16 | size: PropTypes.string,
|
17 |
|
18 | tag: tagPropType,
|
19 |
|
20 | vertical: PropTypes.bool,
|
21 | };
|
22 |
|
23 | function ButtonGroup(props) {
|
24 | const {
|
25 | className,
|
26 | cssModule,
|
27 | size,
|
28 | vertical,
|
29 | tag: Tag = 'div',
|
30 | ...attributes
|
31 | } = props;
|
32 |
|
33 | const classes = mapToCssModules(
|
34 | classNames(
|
35 | className,
|
36 | size ? 'btn-group-' + size : false,
|
37 | vertical ? 'btn-group-vertical' : 'btn-group',
|
38 | ),
|
39 | cssModule,
|
40 | );
|
41 |
|
42 | return <Tag {...{ role: 'group', ...attributes }} className={classes} />;
|
43 | }
|
44 |
|
45 | ButtonGroup.propTypes = propTypes;
|
46 |
|
47 | export default ButtonGroup;
|
48 |
|
\ | No newline at end of file |