-
Notifications
You must be signed in to change notification settings - Fork 61
/
SearchInput.js
51 lines (45 loc) · 1.35 KB
/
SearchInput.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as React from "react";
import * as Scrivito from "scrivito";
class SearchInput extends React.Component {
constructor(props) {
super(props);
this.state = {
q: props.params.q || "",
};
}
render() {
return (
<section className="bg-nav-content">
<div className="container">
<div className="nav-centered">
<form onSubmit={e => this.handleSubmit(e)}>
<div className="input-group">
<input
className="form-control"
placeholder="Search for..."
value={this.state.q}
onChange={e => this.handleChange(e)}
/>
<span className="input-group-btn">
<button className="btn btn-primary" type="submit">
<span className="d-none d-sm-inline">Search again</span>
<i className="fa fa-search fa-1" aria-hidden="true" />
</button>
</span>
</div>
</form>
</div>
</div>
</section>
);
}
handleChange(event) {
this.setState({ q: event.target.value });
}
handleSubmit(event) {
event.preventDefault();
event.stopPropagation();
Scrivito.navigateTo(() => Scrivito.currentPage(), { q: this.state.q });
}
}
export default SearchInput;