| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { useContext, WPElement } from '@wordpress/element'; |
| 5 |
|
| 6 |
/** |
| 7 |
* Internal dependencies. |
| 8 |
*/ |
| 9 |
import { facets } from '../config'; |
| 10 |
import Context from '../context'; |
| 11 |
import Facet from './facets/facet'; |
| 12 |
import SearchTermFacet from './facets/search-term-facet'; |
| 13 |
import Results from './layout/results'; |
| 14 |
import Sidebar from './layout/sidebar'; |
| 15 |
import Toolbar from './layout/toolbar'; |
| 16 |
import ActiveConstraints from './tools/active-constraints'; |
| 17 |
import ClearConstraints from './tools/clear-constraints'; |
| 18 |
import SidebarToggle from './tools/sidebar-toggle'; |
| 19 |
import Sort from './tools/sort'; |
| 20 |
|
| 21 |
/** |
| 22 |
* Search dialog. |
| 23 |
* |
| 24 |
* @returns {WPElement} Component element. |
| 25 |
*/ |
| 26 |
export default () => { |
| 27 |
const { |
| 28 |
state: { isLoading }, |
| 29 |
} = useContext(Context); |
| 30 |
|
| 31 |
return ( |
| 32 |
<div className={`ep-search-page ${isLoading ? 'is-loading' : ''}`}> |
| 33 |
<div className="ep-search-page__header"> |
| 34 |
<SearchTermFacet /> |
| 35 |
|
| 36 |
<Toolbar> |
| 37 |
<ActiveConstraints /> |
| 38 |
<ClearConstraints /> |
| 39 |
<SidebarToggle /> |
| 40 |
</Toolbar> |
| 41 |
</div> |
| 42 |
|
| 43 |
<div className="ep-search-page__body"> |
| 44 |
<Sidebar> |
| 45 |
<Sort /> |
| 46 |
{facets.map(({ label, name, postTypes, type }, index) => ( |
| 47 |
<Facet |
| 48 |
index={index} |
| 49 |
key={name} |
| 50 |
label={label} |
| 51 |
name={name} |
| 52 |
postTypes={postTypes} |
| 53 |
type={type} |
| 54 |
/> |
| 55 |
))} |
| 56 |
</Sidebar> |
| 57 |
|
| 58 |
<Results /> |
| 59 |
</div> |
| 60 |
</div> |
| 61 |
); |
| 62 |
}; |
| 63 |
|