| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { TabControls } from "../../components"; |
| 4 |
import { |
| 5 |
SocialSingleContentAreaTab, |
| 6 |
SocialSingleGeneralTab, |
| 7 |
SocialSingleIconGeneralTab, |
| 8 |
SocialSingleLabelGeneralTab, |
| 9 |
} from "./generalTab"; |
| 10 |
import { useState } from "@wordpress/element"; |
| 11 |
import { SocialSingleIconStyleTab, SocialSingleLabelStyleTab } from "./styleTab"; |
| 12 |
import { AdvancedTab, VisibilityTab } from "../shared/advancedTab"; |
| 13 |
|
| 14 |
export const Inspector = ({ attributes, setAttributes }) => { |
| 15 |
const { labelEnableParent, subTextEnableParent } = attributes; |
| 16 |
const [togglePanel, setTogglePanel] = useState("general"); |
| 17 |
const toggleHandler = (toggleVal, tabName) => { |
| 18 |
setTogglePanel(toggleVal ? tabName : ""); |
| 19 |
}; |
| 20 |
|
| 21 |
return ( |
| 22 |
<> |
| 23 |
<PanelBody |
| 24 |
title={__("General", "post-carousel")} |
| 25 |
opened={"general" === togglePanel} |
| 26 |
onToggle={(value) => toggleHandler(value, "general")} |
| 27 |
> |
| 28 |
<SocialSingleGeneralTab attributes={attributes} setAttributes={setAttributes} /> |
| 29 |
</PanelBody> |
| 30 |
<PanelBody |
| 31 |
title={__("Icon", "post-carousel")} |
| 32 |
opened={"icon" === togglePanel} |
| 33 |
onToggle={(value) => toggleHandler(value, "icon")} |
| 34 |
> |
| 35 |
<TabControls |
| 36 |
attributes={attributes} |
| 37 |
setAttributes={setAttributes} |
| 38 |
GeneralTab={SocialSingleIconGeneralTab} |
| 39 |
StyleTab={SocialSingleIconStyleTab} |
| 40 |
/> |
| 41 |
</PanelBody> |
| 42 |
{(labelEnableParent || subTextEnableParent) && ( |
| 43 |
<> |
| 44 |
<PanelBody |
| 45 |
title={__("Social Label", "post-carousel")} |
| 46 |
opened={"social-label" === togglePanel} |
| 47 |
onToggle={(value) => toggleHandler(value, "social-label")} |
| 48 |
> |
| 49 |
<TabControls |
| 50 |
attributes={attributes} |
| 51 |
setAttributes={setAttributes} |
| 52 |
GeneralTab={SocialSingleLabelGeneralTab} |
| 53 |
StyleTab={SocialSingleLabelStyleTab} |
| 54 |
/> |
| 55 |
</PanelBody> |
| 56 |
</> |
| 57 |
)} |
| 58 |
<PanelBody |
| 59 |
title={__("Content Area", "post-carousel")} |
| 60 |
opened={"content-area" === togglePanel} |
| 61 |
onToggle={(value) => toggleHandler(value, "content-area")} |
| 62 |
> |
| 63 |
<SocialSingleContentAreaTab attributes={attributes} setAttributes={setAttributes} /> |
| 64 |
</PanelBody> |
| 65 |
<PanelBody |
| 66 |
title={__("Advanced", "post-carousel")} |
| 67 |
opened={togglePanel === "advanced"} |
| 68 |
onToggle={(value) => toggleHandler(value, "advanced")} |
| 69 |
> |
| 70 |
{togglePanel === "advanced" && ( |
| 71 |
<TabControls |
| 72 |
attributes={attributes} |
| 73 |
setAttributes={setAttributes} |
| 74 |
AdvancedTab={AdvancedTab} |
| 75 |
VisibilityTab={VisibilityTab} |
| 76 |
displayIcon={false} |
| 77 |
initialTab={"visibility"} |
| 78 |
/> |
| 79 |
)} |
| 80 |
</PanelBody> |
| 81 |
</> |
| 82 |
); |
| 83 |
}; |
| 84 |
|