Files
superset2/superset/assets/javascripts/explore/components/controls/CheckboxControl.jsx
Maxime Beauchemin 254645773c Better looking checkboxes (#3345)
Also showing icon only on hover on control headers
2017-08-21 13:47:50 -07:00

44 lines
1.0 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import ControlHeader from '../ControlHeader';
const propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.bool,
label: PropTypes.string,
description: PropTypes.string,
onChange: PropTypes.func,
};
const defaultProps = {
value: false,
onChange: () => {},
};
export default class CheckboxControl extends React.Component {
onToggle() {
this.props.onChange(!this.props.value);
}
render() {
return (
<ControlHeader
{...this.props}
onClick={this.onToggle.bind(this)}
leftNode={
<span>
<i
className={`fa fa-check ${this.props.value ? 'text-primary' : 'text-transparent'}`}
onClick={this.onToggle.bind(this)}
style={{ border: '1px solid #aaa', borderRadius: '2px', cursor: 'pointer' }}
/>
&nbsp;&nbsp;
</span>
}
/>
);
}
}
CheckboxControl.propTypes = propTypes;
CheckboxControl.defaultProps = defaultProps;