
13 changed files with 184 additions and 49 deletions
@ -0,0 +1,17 @@
|
||||
.control-bar { |
||||
display: flex; |
||||
line-height: 2em; |
||||
} |
||||
|
||||
.control-bar .refresh-btn { |
||||
flex: 0 0 100px; |
||||
color: black; |
||||
background-color: rgba(255,255,255,.9); |
||||
border-radius: 5px; |
||||
text-align: center; |
||||
} |
||||
.control-bar input { |
||||
flex: auto; |
||||
color: black; |
||||
background-color: rgba(255,255,255,.9); |
||||
} |
@ -0,0 +1,42 @@
|
||||
import React, {Component} from 'react'; |
||||
import './ControlBar.css'; |
||||
|
||||
export class ControlBar extends Component { |
||||
constructor(props) { |
||||
super(props); |
||||
this.state={ |
||||
search_text: '', |
||||
}; |
||||
this.set_search_text=props.set_search_text; |
||||
} |
||||
|
||||
on_change(event) { |
||||
this.setState({ |
||||
search_text: event.target.value, |
||||
}); |
||||
} |
||||
|
||||
on_keypress(event) { |
||||
if(event.key==='Enter') |
||||
this.set_search_text(this.state.search_text); |
||||
} |
||||
|
||||
do_refresh() { |
||||
this.setState({ |
||||
search_text: '', |
||||
}); |
||||
this.set_search_text(null); |
||||
} |
||||
|
||||
render() { |
||||
return ( |
||||
<div className="control-bar aux-margin"> |
||||
<a className="refresh-btn" onClick={this.do_refresh.bind(this)}>最新树洞</a> |
||||
|
||||
<input value={this.state.search_text} placeholder="搜索" |
||||
onChange={this.on_change.bind(this)} onKeyPress={this.on_keypress.bind(this)} |
||||
/> |
||||
</div> |
||||
) |
||||
} |
||||
} |
Loading…
Reference in new issue