Skip to content

Commit 3bda5f7

Browse files
committed
fix: CButtonToolbar: component refactor:
- fix justify prop, - add default aria support, - delete tag prop
1 parent 688eb3b commit 3bda5f7

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/CButtonToolbar.js

+19-21
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,48 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
4-
import {tagPropType, mapToCssModules} from './Shared/helper.js';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
4+
import { mapToCssModules } from './Shared/helper.js'
55

66
//component - CoreUI / CButtonToolbar
77

88
const CButtonToolbar = props=>{
99

1010
const {
11-
tag: Tag,
1211
className,
1312
cssModule,
1413
//
1514
innerRef,
1615
justify,
1716
...attributes
18-
} = props;
17+
} = props
1918

2019
//render
2120

2221
const classes = mapToCssModules(classNames(
2322
className,
24-
justify ? 'justify-content-between' : false,
25-
'btn-toolbar'
26-
), cssModule);
23+
'btn-toolbar',
24+
{ [`justify-content-${justify}`]: justify }
25+
), cssModule)
2726

2827
return (
29-
<Tag {...attributes} className={classes} ref={innerRef} />
30-
);
28+
<div
29+
className={classes}
30+
role="toolbar"
31+
aria-label="toolbar"
32+
{...attributes}
33+
ref={innerRef}
34+
/>
35+
)
3136

3237
}
3338

3439
CButtonToolbar.propTypes = {
35-
tag: tagPropType,
3640
className: PropTypes.string,
3741
cssModule: PropTypes.object,
3842
//
3943
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
4044
role: PropTypes.string,
41-
justify: PropTypes.bool,
42-
'aria-label': PropTypes.string,
43-
};
44-
45-
CButtonToolbar.defaultProps = {
46-
tag: 'div',
47-
role: 'toolbar',
48-
};
45+
justify: PropTypes.oneOf(['', 'start', 'end', 'between', 'center'])
46+
}
4947

50-
export default CButtonToolbar;
48+
export default CButtonToolbar

0 commit comments

Comments
 (0)