49 lines
1.6 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 15:53:09 +02:00
const { publicRuntimeConfig } = getConfig();
const SearchBar = props => (
2018-07-11 15:53:09 +02:00
<div className="search-bar" style={{ backgroundImage: `url(${publicRuntimeConfig.subDirPath}/static/img/header-bg.jpg)` }}>
<div className="container">
2018-07-17 16:23:38 +02:00
<h3 className="main-heading">Archives</h3>
2018-07-09 16:29:57 +02:00
<form className="search-form">
<input
className="search-input"
type="search"
2018-07-17 15:07:07 +02:00
placeholder="Search"
2018-07-09 16:29:57 +02:00
value={props.term}
onChange={props.onSearchInputChange}
/>
2018-07-17 16:23:38 +02:00
<img className="search-icon" src={`${publicRuntimeConfig.subDirPath}/static/img/search-icon.svg`} alt="Search" />
2018-07-09 16:29:57 +02:00
{ props.isSearchActive && (
2018-07-11 11:18:07 +02:00
<button
2018-07-09 16:29:57 +02:00
className="search-clear-button"
onClick={props.clearSearchInput}
>
2018-07-17 16:23:38 +02:00
<img src={`${publicRuntimeConfig.subDirPath}/static/img/clear-search-icon.svg`} alt="Clear search" />
2018-07-11 11:18:07 +02:00
</button>
2018-07-09 16:29:57 +02:00
)
}
</form>
2018-07-18 12:34:35 +02:00
{props.numResults > 0 && props.numResults[0] !== null ?
// eslint-disable-next-line
<p style={{marginTop: '32px'}}>{ props.numMatchedTerms } search term matches | { props.numResults } interviews</p> :
''}
</div>
</div>
);
SearchBar.propTypes = {
term: PropTypes.string.isRequired,
2018-07-09 16:29:57 +02:00
isSearchActive: PropTypes.bool.isRequired,
onSearchInputChange: PropTypes.func.isRequired,
clearSearchInput: PropTypes.func.isRequired,
2018-07-18 12:34:35 +02:00
numResults: PropTypes.number.isRequired,
numMatchedTerms: PropTypes.number.isRequired,
2018-07-09 16:29:57 +02:00
};
export default SearchBar;