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 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 15:07:07 +02:00
<h3>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}
/>
{ 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}
>
Clear search
2018-07-11 11:18:07 +02:00
</button>
2018-07-09 16:29:57 +02:00
)
}
</form>
</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,
};
export default SearchBar;