PluginProbe
ElasticPress / 5.0.0
ElasticPress v5.0.0
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / assets / js / instant-results / components / layout.js

layout.js in ElasticPress 5.0.0, at assets/js/instant-results/components/layout.js

72 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies.
3 */
4 import { useState, WPElement } from '@wordpress/element';
5
6 /**
7 * Internal dependencies.
8 */
9 import { useApiSearch } from '../../api-search';
10 import { facets } from '../config';
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 { isLoading } = useApiSearch();
28
29 const [isSidebarOpen, setIsSidebarOpen] = useState(false);
30
31 /**
32 * Sidebar toggle click handler.
33 *
34 * @returns {void}
35 */
36 const onClickSidebarToggle = () => {
37 setIsSidebarOpen(!isSidebarOpen);
38 };
39
40 return (
41 <div className={`ep-search-page ${isLoading ? 'is-loading' : ''}`}>
42 <div className="ep-search-page__header">
43 <SearchTermFacet />
44
45 <Toolbar>
46 <ActiveConstraints />
47 <ClearConstraints />
48 <SidebarToggle isOpen={isSidebarOpen} onClick={onClickSidebarToggle} />
49 </Toolbar>
50 </div>
51
52 <div className="ep-search-page__body">
53 <Sidebar isOpen={isSidebarOpen}>
54 <Sort />
55 {facets.map(({ label, name, postTypes, type }, index) => (
56 <Facet
57 index={index}
58 key={name}
59 label={label}
60 name={name}
61 postTypes={postTypes}
62 type={type}
63 />
64 ))}
65 </Sidebar>
66
67 <Results />
68 </div>
69 </div>
70 );
71 };
72