insomnia/packages/insomnia-app/app/ui/components/base/indeterminate-checkbox.js
Gregory Schier 42e198bf75
Add Storybook with basic components (#1807)
* Gruvbox theme

* Added Storybook for all components that don't fail in browser
2019-11-26 12:22:21 -05:00

43 lines
761 B
JavaScript

// @flow
import * as React from 'react';
import autobind from 'autobind-decorator';
type Props = {
indeterminate: boolean,
checked: boolean,
};
@autobind
class IndeterminateCheckbox extends React.PureComponent<Props> {
input: ?HTMLInputElement;
_setRef(n: ?HTMLInputElement) {
this.input = n;
}
_update() {
if (this.input) {
this.input.indeterminate = this.props.indeterminate;
}
}
componentDidMount() {
this._update();
}
componentDidUpdate() {
this._update();
}
render() {
const {
indeterminate, // eslint-disable-line no-unused-vars
...otherProps
} = this.props;
return <input ref={this._setRef} type="checkbox" {...otherProps} />;
}
}
export default IndeterminateCheckbox;