import React, { PropTypes } from 'react' import ReactDOM from 'react-dom' import ExternalLink from 'boost/components/ExternalLink' import { setSearchFilter, clearSearch } from 'boost/actions' export default class ArticleTopBar extends React.Component { isInputFocused () { return document.activeElement === ReactDOM.findDOMNode(this.refs.searchInput) } escape () { let { status, dispatch } = this.props if (status.search.length > 0) { dispatch(clearSearch()) return } this.blurInput() } focusInput () { ReactDOM.findDOMNode(this.refs.searchInput).focus() } blurInput () { ReactDOM.findDOMNode(this.refs.searchInput).blur() } handleSearchChange (e) { let { dispatch } = this.props dispatch(setSearchFilter(e.target.value)) } handleSearchClearButton (e) { let { dispatch } = this.props dispatch(setSearchFilter('')) this.focusInput() } render () { return (
this.handleSearchChange(e)} placeholder='Search' type='text'/> { this.props.status.search != null && this.props.status.search.length > 0 ? : null }
) } } ArticleTopBar.propTypes = { search: PropTypes.string, dispatch: PropTypes.func, status: PropTypes.shape({ search: PropTypes.string }) }