| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { useState } from "@wordpress/element"; |
| 4 |
import { TabControls } from "../../components"; |
| 5 |
import { AdvancedTab, VisibilityTab } from "../shared/advancedTab"; |
| 6 |
import { SmartBtnGeneralTab, SmartBtnIconTab, SmartBtnLabelTab } from "./sidebarControl"; |
| 7 |
|
| 8 |
const Inspector = ({ attributes, setAttributes }) => { |
| 9 |
const [togglePanel, setTogglePanel] = useState("general"); |
| 10 |
|
| 11 |
const toggleHandler = (toggleVal, tabName) => { |
| 12 |
setTogglePanel(toggleVal ? tabName : ""); |
| 13 |
}; |
| 14 |
|
| 15 |
return ( |
| 16 |
<> |
| 17 |
<PanelBody |
| 18 |
title={__("General", "post-carousel")} |
| 19 |
opened={togglePanel === "general"} |
| 20 |
onToggle={(value) => toggleHandler(value, "general")} |
| 21 |
> |
| 22 |
<SmartBtnGeneralTab attributes={attributes} setAttributes={setAttributes} /> |
| 23 |
</PanelBody> |
| 24 |
<PanelBody |
| 25 |
title={__("Button Label", "post-carousel")} |
| 26 |
opened={togglePanel === "buttonLabel"} |
| 27 |
onToggle={(value) => toggleHandler(value, "buttonLabel")} |
| 28 |
> |
| 29 |
<SmartBtnLabelTab attributes={attributes} setAttributes={setAttributes} /> |
| 30 |
</PanelBody> |
| 31 |
|
| 32 |
<PanelBody |
| 33 |
title={__("Icon", "post-carousel")} |
| 34 |
className="sp-button-icon-panel-body" |
| 35 |
opened={togglePanel === "icon"} |
| 36 |
onToggle={(value) => toggleHandler(value, "icon")} |
| 37 |
> |
| 38 |
<SmartBtnIconTab attributes={attributes} setAttributes={setAttributes} /> |
| 39 |
</PanelBody> |
| 40 |
<PanelBody |
| 41 |
title={__("Advanced", "post-carousel")} |
| 42 |
opened={togglePanel === "advanced"} |
| 43 |
onToggle={(value) => toggleHandler(value, "advanced")} |
| 44 |
> |
| 45 |
{togglePanel === "advanced" && ( |
| 46 |
<TabControls |
| 47 |
attributes={attributes} |
| 48 |
setAttributes={setAttributes} |
| 49 |
AdvancedTab={AdvancedTab} |
| 50 |
VisibilityTab={VisibilityTab} |
| 51 |
displayIcon={false} |
| 52 |
initialTab={"visibility"} |
| 53 |
/> |
| 54 |
)} |
| 55 |
</PanelBody> |
| 56 |
</> |
| 57 |
); |
| 58 |
}; |
| 59 |
|
| 60 |
export default Inspector; |
| 61 |
|