| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { Divider, TabControls } from "../../components"; |
| 4 |
import { |
| 5 |
SocialProfilesContentTab, |
| 6 |
SocialProfilesGeneralTab, |
| 7 |
SocialProfilesIconGeneralTab, |
| 8 |
SocialProfilesLabelGeneralTab, |
| 9 |
} from "./generalTab"; |
| 10 |
import { useState } from "@wordpress/element"; |
| 11 |
import { SocialProfilesIconStyleTab, SocialProfilesLabelStyleTab } from "./styleTab"; |
| 12 |
import { AdvancedTab, VisibilityTab } from "../shared/advancedTab"; |
| 13 |
import Toggle from "../../components/toggle/toggle"; |
| 14 |
|
| 15 |
export const Inspector = ({ attributes, setAttributes }) => { |
| 16 |
const { socialIconEnable, socialLabelEnable, socialSubTextEnable } = attributes; |
| 17 |
const [togglePanel, setTogglePanel] = useState("general"); |
| 18 |
|
| 19 |
const toggleHandler = (toggleVal, tabName) => { |
| 20 |
setTogglePanel(toggleVal ? tabName : ""); |
| 21 |
}; |
| 22 |
|
| 23 |
return ( |
| 24 |
<> |
| 25 |
<PanelBody |
| 26 |
title={__("General", "post-carousel")} |
| 27 |
opened={"general" === togglePanel} |
| 28 |
onToggle={(value) => toggleHandler(value, "general")} |
| 29 |
> |
| 30 |
<SocialProfilesGeneralTab attributes={attributes} setAttributes={setAttributes} /> |
| 31 |
</PanelBody> |
| 32 |
<PanelBody |
| 33 |
title={__("Icon", "post-carousel")} |
| 34 |
opened={"icon" === togglePanel} |
| 35 |
onToggle={(value) => toggleHandler(value, "icon")} |
| 36 |
> |
| 37 |
<Toggle |
| 38 |
label={__("Social Icon", "post-carousel")} |
| 39 |
attributes={socialIconEnable} |
| 40 |
attributesKey={"socialIconEnable"} |
| 41 |
setAttributes={setAttributes} |
| 42 |
/> |
| 43 |
{socialIconEnable && ( |
| 44 |
<TabControls |
| 45 |
attributes={attributes} |
| 46 |
setAttributes={setAttributes} |
| 47 |
GeneralTab={SocialProfilesIconGeneralTab} |
| 48 |
StyleTab={SocialProfilesIconStyleTab} |
| 49 |
/> |
| 50 |
)} |
| 51 |
</PanelBody> |
| 52 |
<PanelBody |
| 53 |
title={__("Social Label", "post-carousel")} |
| 54 |
opened={"social-label" === togglePanel} |
| 55 |
onToggle={(value) => toggleHandler(value, "social-label")} |
| 56 |
> |
| 57 |
<Toggle |
| 58 |
label={__("Social Label", "post-carousel")} |
| 59 |
attributes={socialLabelEnable} |
| 60 |
attributesKey={"socialLabelEnable"} |
| 61 |
setAttributes={setAttributes} |
| 62 |
/> |
| 63 |
<Toggle |
| 64 |
label={__("Sub Text", "post-carousel")} |
| 65 |
attributes={socialSubTextEnable} |
| 66 |
attributesKey={"socialSubTextEnable"} |
| 67 |
setAttributes={setAttributes} |
| 68 |
pro={true} |
| 69 |
/> |
| 70 |
{(socialLabelEnable || (socialLabelEnable && socialSubTextEnable)) && ( |
| 71 |
<TabControls |
| 72 |
attributes={attributes} |
| 73 |
setAttributes={setAttributes} |
| 74 |
GeneralTab={SocialProfilesLabelGeneralTab} |
| 75 |
StyleTab={SocialProfilesLabelStyleTab} |
| 76 |
/> |
| 77 |
)} |
| 78 |
{socialSubTextEnable && ( |
| 79 |
<> |
| 80 |
<Divider position="sp-w-100pct" /> |
| 81 |
<SocialProfilesLabelStyleTab attributes={attributes} setAttributes={setAttributes} /> |
| 82 |
</> |
| 83 |
)} |
| 84 |
</PanelBody> |
| 85 |
<PanelBody |
| 86 |
title={__("Content Area", "post-carousel")} |
| 87 |
opened={"content-area" === togglePanel} |
| 88 |
onToggle={(value) => toggleHandler(value, "content-area")} |
| 89 |
> |
| 90 |
<SocialProfilesContentTab attributes={attributes} setAttributes={setAttributes} /> |
| 91 |
</PanelBody> |
| 92 |
<PanelBody |
| 93 |
title={__("Advanced", "post-carousel")} |
| 94 |
opened={togglePanel === "advanced"} |
| 95 |
onToggle={(value) => toggleHandler(value, "advanced")} |
| 96 |
> |
| 97 |
{togglePanel === "advanced" && ( |
| 98 |
<TabControls |
| 99 |
attributes={attributes} |
| 100 |
setAttributes={setAttributes} |
| 101 |
AdvancedTab={AdvancedTab} |
| 102 |
VisibilityTab={VisibilityTab} |
| 103 |
displayIcon={false} |
| 104 |
initialTab={"visibility"} |
| 105 |
/> |
| 106 |
)} |
| 107 |
</PanelBody> |
| 108 |
</> |
| 109 |
); |
| 110 |
}; |
| 111 |
|