Skip to content

Commit a24f91c

Browse files
committed
fix: CButtonClose: component refactor
- delete 'tag' and 'iconHtml' props, - add buttonClass prop
1 parent 6d0e7fa commit a24f91c

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/CButtonClose.js

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,53 @@
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 / CButtonClose
77

8-
const CButtonClose = props=>{
8+
const CButtonClose = props => {
99

1010
const {
11-
tag: Tag,
1211
children,
1312
className,
1413
cssModule,
1514
//
15+
buttonClass,
1616
innerRef,
17-
iconHtml,
1817
...attributes
19-
} = props;
18+
} = props
2019

2120
//render
2221

2322
const classes = mapToCssModules(classNames(
24-
'close',
23+
buttonClass,
2524
className
26-
), cssModule);
25+
), cssModule)
2726

2827
return (
29-
<Tag {...attributes} aria-label="Close" className={classes} ref={innerRef}>{children||iconHtml}</Tag>
30-
);
28+
<button
29+
className={classes}
30+
aria-label="Close"
31+
{...attributes}
32+
ref={innerRef}
33+
>
34+
{ children || String.fromCharCode(215) }
35+
</button>
36+
)
3137

3238
}
3339

3440
CButtonClose.propTypes = {
35-
tag: tagPropType,
3641
children: PropTypes.node,
3742
className: PropTypes.string,
3843
cssModule: PropTypes.object,
3944
//
45+
buttonClass: PropTypes.string,
4046
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
41-
iconHtml: PropTypes.oneOfType([PropTypes.node, PropTypes.string])//object
42-
};
47+
}
4348

4449
CButtonClose.defaultProps = {
45-
tag: 'button',
46-
iconHtml: <React.Fragment>&times;</React.Fragment>
47-
};
50+
buttonClass: 'close'
51+
}
4852

49-
export default CButtonClose;
53+
export default CButtonClose

src/CSidebarClose.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const CSidebarClose = props=>{
2020
);
2121

2222
return (
23-
<CButtonClose {...attributes} className={classes}>
23+
<CButtonClose {...attributes} buttonClass={classes}>
2424
<svg className="c-icon" width="24" height="24" viewBox="0 0 24 24">
2525
<title>x</title>
2626
<path d="M20.030 5.030l-1.061-1.061-6.97 6.97-6.97-6.97-1.061 1.061 6.97 6.97-6.97 6.97 1.061 1.061 6.97-6.97 6.97 6.97 1.061-1.061-6.97-6.97 6.97-6.97z"></path>

0 commit comments

Comments
 (0)