-
Notifications
You must be signed in to change notification settings - Fork 50
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
Showing
13 changed files
with
268 additions
and
116 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import styles from '@/styles/Gallery.scss'; | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import CSSModules from 'react-css-modules'; | ||
import EventListener from 'react-event-listener'; | ||
import SearchIcon from '@material-ui/icons/Search'; | ||
|
||
@CSSModules(styles, { allowMultiple: true }) | ||
export default class SearchInput extends React.Component { | ||
static propTypes = { | ||
onSearch: PropTypes.func | ||
}; | ||
|
||
static defaultProps = { | ||
onSearch() {} | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
@autobind | ||
onKeyDown(event) { | ||
if (event.keyCode === 13 && document.activeElement === this.inputRef) { | ||
this.inputRef.blur(); | ||
this.onSearch(); | ||
} | ||
} | ||
|
||
onSearch() { | ||
this.props.onSearch(this.inputRef.value); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div styleName="search-root"> | ||
<div styleName="search"> | ||
<SearchIcon /> | ||
</div> | ||
<input ref={ref => (this.inputRef = ref)} styleName="search-input" /> | ||
<EventListener target="window" onKeyDown={this.onKeyDown} /> | ||
</div> | ||
); | ||
} | ||
} |
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
Oops, something went wrong.