mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 06:05:15 +00:00
Organize filestructure
This commit is contained in:
49
client/source/scripts/components/forms/SearchBox.js
Normal file
49
client/source/scripts/components/forms/SearchBox.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import classnames from'classnames';
|
||||
import React from'react';
|
||||
|
||||
import Search from '../icons/Search';
|
||||
import UIActions from '../../actions/UIActions';
|
||||
|
||||
const METHODS_TO_BIND = [
|
||||
'handleKeyUp'
|
||||
];
|
||||
|
||||
export default class SearchBox extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.state = {
|
||||
searchValue: ''
|
||||
};
|
||||
|
||||
METHODS_TO_BIND.forEach((method) => {
|
||||
this[method] = this[method].bind(this);
|
||||
});
|
||||
}
|
||||
|
||||
handleKeyUp(event) {
|
||||
let value = event.target.value;
|
||||
this.setState({
|
||||
searchValue: value
|
||||
});
|
||||
UIActions.setTorrentsSearchFilter(value);
|
||||
}
|
||||
|
||||
render() {
|
||||
let classSet = classnames({
|
||||
'sidebar__item': true,
|
||||
'sidebar__item--search': true,
|
||||
'is-in-use': this.state.searchValue !== ''
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={classSet}>
|
||||
<Search />
|
||||
<input className="textbox"
|
||||
type="text"
|
||||
placeholder="Search Torrents"
|
||||
onKeyUp={this.handleKeyUp} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user