MCPcopy Create free account
hub / github.com/emwalker/digraph / SearchBox

Class SearchBox

client/src/components/Homepage/SearchBox/index.tsx:14–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14class SearchBox extends Component<Props> {
15 static defaultProps = {
16 className: '',
17 }
18
19 onKeyPress = (event: KeyboardEvent<HTMLInputElement>) => {
20 if (event.key === 'Enter') {
21 const { value } = event.currentTarget
22 this.onSearch(value)
23 }
24 }
25
26 onSearch = (query: string) => {
27 if (query === '') {
28 this.props.router.push({ pathname: topicPath(everythingTopicId) })
29 return
30 }
31
32 this.props.router.push({ pathname: topicPath(everythingTopicId), query: { q: query } })
33 }
34
35 render = () => (
36 <p className={classNames(this.props.className, 'form-group text-center')}>
37 <input
38 aria-label="Search"
39 className="searchBoxInput form-control p-3"
40 onKeyPress={this.onKeyPress}
41 placeholder="Start with a search"
42 type="search"
43 />
44 </p>
45 )
46}
47
48export default SearchBox

Callers

nothing calls this directly

Calls 1

topicPathFunction · 0.90

Tested by

no test coverage detected