2018-07-09 08:22:48 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { PropTypes } from 'prop-types';
|
2018-07-11 13:47:26 +00:00
|
|
|
import getConfig from 'next/config';
|
2018-07-09 08:22:48 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2018-07-11 13:53:09 +00:00
|
|
|
const { publicRuntimeConfig } = getConfig();
|
|
|
|
|
2018-07-09 08:22:48 +00:00
|
|
|
const SearchBar = props => (
|
2018-07-11 13:53:09 +00:00
|
|
|
<div className="search-bar" style={{ backgroundImage: `url(${publicRuntimeConfig.subDirPath}/static/img/header-bg.jpg)` }}>
|
2018-07-09 08:22:48 +00:00
|
|
|
<div className="container">
|
2018-07-11 09:18:07 +00:00
|
|
|
<h3>Browse</h3>
|
2018-07-09 14:29:57 +00:00
|
|
|
<form className="search-form">
|
|
|
|
<input
|
|
|
|
className="search-input"
|
|
|
|
type="search"
|
|
|
|
placeholder="Search archives"
|
|
|
|
value={props.term}
|
|
|
|
onChange={props.onSearchInputChange}
|
|
|
|
/>
|
|
|
|
{ props.isSearchActive && (
|
2018-07-11 09:18:07 +00:00
|
|
|
<button
|
2018-07-09 14:29:57 +00:00
|
|
|
className="search-clear-button"
|
|
|
|
onClick={props.clearSearchInput}
|
|
|
|
>
|
|
|
|
Clear search
|
2018-07-11 09:18:07 +00:00
|
|
|
</button>
|
2018-07-09 14:29:57 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
</form>
|
2018-07-09 08:22:48 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
SearchBar.propTypes = {
|
|
|
|
term: PropTypes.string.isRequired,
|
2018-07-09 14:29:57 +00:00
|
|
|
isSearchActive: PropTypes.bool.isRequired,
|
|
|
|
onSearchInputChange: PropTypes.func.isRequired,
|
|
|
|
clearSearchInput: PropTypes.func.isRequired,
|
|
|
|
};
|
2018-07-09 08:22:48 +00:00
|
|
|
|
|
|
|
export default SearchBar;
|