UNPKG

1.04 kBJavaScriptView Raw
1import React from 'react';
2import PropTypes from 'prop-types';
3import classNames from 'classnames';
4import { mapToCssModules } from './utils';
5
6const propTypes = {
7 /** Disable the button if needed */
8 active: PropTypes.bool,
9 /** Aria label */
10 'aria-label': PropTypes.string,
11 /** Function to be triggered on click */
12 onClick: PropTypes.func,
13 /** Change the variant to white */
14 variant: PropTypes.oneOf(['white']),
15 className: PropTypes.string,
16 cssModule: PropTypes.object,
17 innerRef: PropTypes.oneOfType([
18 PropTypes.object,
19 PropTypes.string,
20 PropTypes.func,
21 ]),
22};
23
24function CloseButton(props) {
25 const { className, cssModule, variant, innerRef, ...attributes } = props;
26
27 const classes = mapToCssModules(
28 classNames(className, 'btn-close', variant && `btn-close-${variant}`),
29 );
30
31 return (
32 <button
33 ref={innerRef}
34 type="button"
35 className={classes}
36 {...{ 'aria-label': 'close', ...attributes }}
37 />
38 );
39}
40
41CloseButton.propTypes = propTypes;
42
43export default CloseButton;