| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { TabControls } from "../../components"; |
| 4 |
import { |
| 5 |
MoreResultGeneralTab, |
| 6 |
PopupCanvasGeneralTab, |
| 7 |
PresetTab, |
| 8 |
QueryFilterGeneralTab, |
| 9 |
SearchButtonGeneralTab, |
| 10 |
SearchResultGeneralTab, |
| 11 |
} from "./generalTab"; |
| 12 |
import { |
| 13 |
MoreResultStyleTab, |
| 14 |
PopupCanvasStyleTab, |
| 15 |
PresetStyleTab, |
| 16 |
SearchButtonStyleTab, |
| 17 |
SearchResultStyleTab, |
| 18 |
} from "./styleTab"; |
| 19 |
import { usePanelBodyContext } from "../../context"; |
| 20 |
|
| 21 |
export const Inspector = ({ attributes, setAttributes }) => { |
| 22 |
const { openPanel, togglePanelBody } = usePanelBodyContext(); |
| 23 |
const { blockName, displayType } = attributes; |
| 24 |
|
| 25 |
return ( |
| 26 |
<> |
| 27 |
<PanelBody |
| 28 |
title={__("General", "post-carousel")} |
| 29 |
opened={"general" === openPanel} |
| 30 |
onToggle={() => togglePanelBody("general")} |
| 31 |
> |
| 32 |
{openPanel === "general" && ( |
| 33 |
<TabControls |
| 34 |
attributes={attributes} |
| 35 |
setAttributes={setAttributes} |
| 36 |
GeneralTab={PresetTab} |
| 37 |
StyleTab={PresetStyleTab} |
| 38 |
displayIcon={true} |
| 39 |
blockName={blockName} |
| 40 |
initialTab={"general"} |
| 41 |
/> |
| 42 |
)} |
| 43 |
</PanelBody> |
| 44 |
<PanelBody |
| 45 |
title={__("Query & Filter", "post-carousel")} |
| 46 |
opened={"query_filter" === openPanel} |
| 47 |
onToggle={() => togglePanelBody("query_filter")} |
| 48 |
> |
| 49 |
{openPanel === "query_filter" && ( |
| 50 |
<QueryFilterGeneralTab attributes={attributes} setAttributes={setAttributes} /> |
| 51 |
)} |
| 52 |
</PanelBody> |
| 53 |
|
| 54 |
<PanelBody |
| 55 |
title={__("Search Button", "post-carousel")} |
| 56 |
opened={"search_button" === openPanel} |
| 57 |
onToggle={() => togglePanelBody("search_button")} |
| 58 |
> |
| 59 |
{openPanel === "search_button" && ( |
| 60 |
<TabControls |
| 61 |
attributes={attributes} |
| 62 |
setAttributes={setAttributes} |
| 63 |
GeneralTab={SearchButtonGeneralTab} |
| 64 |
StyleTab={SearchButtonStyleTab} |
| 65 |
displayIcon={true} |
| 66 |
blockName={blockName} |
| 67 |
initialTab={"general"} |
| 68 |
/> |
| 69 |
)} |
| 70 |
</PanelBody> |
| 71 |
|
| 72 |
{displayType === "popup" && ( |
| 73 |
<PanelBody |
| 74 |
title={__("Popup Canvas", "post-carousel")} |
| 75 |
opened={"popup_canvas" === openPanel} |
| 76 |
onToggle={() => togglePanelBody("popup_canvas")} |
| 77 |
> |
| 78 |
{openPanel === "popup_canvas" && ( |
| 79 |
<TabControls |
| 80 |
attributes={attributes} |
| 81 |
setAttributes={setAttributes} |
| 82 |
GeneralTab={PopupCanvasGeneralTab} |
| 83 |
StyleTab={PopupCanvasStyleTab} |
| 84 |
displayIcon={true} |
| 85 |
blockName={blockName} |
| 86 |
initialTab={"general"} |
| 87 |
/> |
| 88 |
)} |
| 89 |
</PanelBody> |
| 90 |
)} |
| 91 |
|
| 92 |
<PanelBody |
| 93 |
title={__("Search Result", "post-carousel")} |
| 94 |
opened={"search_result" === openPanel} |
| 95 |
onToggle={() => togglePanelBody("search_result")} |
| 96 |
> |
| 97 |
{openPanel === "search_result" && ( |
| 98 |
<TabControls |
| 99 |
attributes={attributes} |
| 100 |
setAttributes={setAttributes} |
| 101 |
GeneralTab={SearchResultGeneralTab} |
| 102 |
StyleTab={SearchResultStyleTab} |
| 103 |
displayIcon={true} |
| 104 |
blockName={blockName} |
| 105 |
initialTab={"general"} |
| 106 |
/> |
| 107 |
)} |
| 108 |
</PanelBody> |
| 109 |
|
| 110 |
<PanelBody |
| 111 |
title={__("More Result", "post-carousel")} |
| 112 |
opened={"more_result" === openPanel} |
| 113 |
onToggle={() => togglePanelBody("more_result")} |
| 114 |
> |
| 115 |
{openPanel === "more_result" && ( |
| 116 |
<TabControls |
| 117 |
attributes={attributes} |
| 118 |
setAttributes={setAttributes} |
| 119 |
GeneralTab={MoreResultGeneralTab} |
| 120 |
StyleTab={MoreResultStyleTab} |
| 121 |
displayIcon={true} |
| 122 |
blockName={blockName} |
| 123 |
initialTab={"general"} |
| 124 |
/> |
| 125 |
)} |
| 126 |
</PanelBody> |
| 127 |
</> |
| 128 |
); |
| 129 |
}; |
| 130 |
|