chayns-components
Version:
A set of beautiful React components for developing chayns® applications.
48 lines (47 loc) • 1.31 kB
JavaScript
/* eslint-disable jsx-a11y/click-events-have-key-events */
import classNames from 'clsx';
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
import Icon from '../../react-chayns-icon/component/Icon';
export default class ControlButton extends PureComponent {
render() {
const {
icon,
backgroundColor,
onClick,
className,
disabled,
color,
stopPropagation
} = this.props;
return /*#__PURE__*/React.createElement("div", {
onClick: e => {
if (!disabled) onClick(e);
if (stopPropagation) e.stopPropagation();
},
className: classNames(className, disabled && "disabled"),
style: {
backgroundColor
}
}, /*#__PURE__*/React.createElement(Icon, {
icon: icon,
style: color ? {
color
} : null
}));
}
}
ControlButton.propTypes = {
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
onClick: PropTypes.func.isRequired,
className: PropTypes.string.isRequired,
stopPropagation: PropTypes.bool.isRequired,
disabled: PropTypes.bool,
color: PropTypes.string
};
ControlButton.defaultProps = {
disabled: false,
color: null
};
ControlButton.displayName = 'ControlButton';
//# sourceMappingURL=ControlButton.js.map