forked from AOEpeople/aoe_technology_radar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd029da
commit ad2b0e3
Showing
7 changed files
with
101 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,52 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export default function Search({ value, onChange, onClose, open = false, onSubmit = () => {} }) { | ||
const closable = typeof onClose === 'function'; | ||
class Search extends React.Component { | ||
focus() { | ||
this.input.focus(); | ||
} | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
onSubmit(); | ||
}; | ||
render() { | ||
const { value, onChange, onClose, open = false, onSubmit = () => {} } = this.props; | ||
|
||
const handleClose = (e) => { | ||
e.preventDefault(); | ||
onClose(); | ||
} | ||
const closable = typeof onClose === 'function'; | ||
|
||
const handleSubmit = (e) => { | ||
e.preventDefault(); | ||
onSubmit(); | ||
}; | ||
|
||
return ( | ||
<form className={classNames('search', { 'search--closable': closable })} onSubmit={handleSubmit}> | ||
<input | ||
value={value} | ||
type="text" | ||
onChange={(e) => { onChange(e.target.value); }} | ||
className="search__field" | ||
placeholder="What are you looking for?" | ||
/> | ||
<span className={classNames('search__button', { 'is-open': open })}> | ||
<button type="submit" className="button"> | ||
<span className="icon icon--search button__icon" /> | ||
Search | ||
</button> | ||
</span> | ||
{ | ||
closable && ( | ||
<a href="#" className={classNames('search__close', { 'is-open': open })} onClick={handleClose}> | ||
<span className="icon icon--close" /> | ||
</a> | ||
) | ||
} | ||
</form> | ||
); | ||
const handleClose = (e) => { | ||
e.preventDefault(); | ||
onClose(); | ||
} | ||
|
||
return ( | ||
<form className={classNames('search', { 'search--closable': closable })} onSubmit={handleSubmit}> | ||
<input | ||
value={value} | ||
type="text" | ||
onChange={(e) => { onChange(e.target.value); }} | ||
className="search__field" | ||
placeholder="What are you looking for?" | ||
ref={(input) => { this.input = input; }} | ||
/> | ||
<span className={classNames('search__button', { 'is-open': open })}> | ||
<button type="submit" className="button"> | ||
<span className="icon icon--search button__icon" /> | ||
Search | ||
</button> | ||
</span> | ||
{ | ||
closable && ( | ||
<a href="#" className={classNames('search__close', { 'is-open': open })} onClick={handleClose}> | ||
<span className="icon icon--close" /> | ||
</a> | ||
) | ||
} | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
export default Search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters