mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 06:05:15 +00:00
Add move torrents option to context menu
This commit is contained in:
54
client/source/scripts/components/forms/Checkbox.js
Normal file
54
client/source/scripts/components/forms/Checkbox.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import classnames from 'classnames';
|
||||
import React from 'react';
|
||||
|
||||
import Checkmark from '../icons/Checkmark';
|
||||
|
||||
const METHODS_TO_BIND = ['handleCheckboxChange'];
|
||||
|
||||
export default class SearchBox extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.state = {checked: false};
|
||||
|
||||
METHODS_TO_BIND.forEach((method) => {
|
||||
this[method] = this[method].bind(this);
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (this.state.checked !== this.props.checked) {
|
||||
this.setState({checked: this.props.checked});
|
||||
}
|
||||
}
|
||||
|
||||
handleCheckboxChange() {
|
||||
let currentCheckedState = this.state.checked;
|
||||
let newCheckedState = !currentCheckedState;
|
||||
|
||||
this.setState({checked: newCheckedState})
|
||||
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange(newCheckedState);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let classes = classnames('checkbox', {
|
||||
'is-checked': this.state.checked
|
||||
});
|
||||
|
||||
return (
|
||||
<label className={classes}>
|
||||
<input type="checkbox" checked={this.state.checked}
|
||||
onChange={this.handleCheckboxChange} />
|
||||
<span className="checkbox__decoy">
|
||||
<Checkmark />
|
||||
</span>
|
||||
<span className="checkbox__label">
|
||||
{this.props.children}
|
||||
</span>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user