ETHReport/components/searchBar/index.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { PropTypes } from 'prop-types';
import getConfig from 'next/config';
import './style.scss';
2018-07-11 13:53:09 +00:00
const { publicRuntimeConfig } = getConfig();
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)` }}>
<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>
</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,
};
export default SearchBar;