| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { useEffect, useState } from "@wordpress/element"; |
| 3 |
import { PanelBody } from "@wordpress/components"; |
| 4 |
import { TabControls } from "../../components"; |
| 5 |
import { |
| 6 |
ContainerAdvancedGeneralTab, |
| 7 |
ContainerFlexProperties, |
| 8 |
ContainerGeneralTab, |
| 9 |
ContainerShapeDivider, |
| 10 |
} from "./generalTab"; |
| 11 |
import { ContainerAdvanceAdvancedTab, ContainerStyleTab, ContainerVisibilityTab } from "./styleTab"; |
| 12 |
|
| 13 |
const Inspector = ({ attributes, setAttributes, isSelected }) => { |
| 14 |
const [togglePanel, setTogglePanel] = useState("container"); |
| 15 |
|
| 16 |
const toggleHandler = (toggleVal, tabName) => { |
| 17 |
setTogglePanel(toggleVal ? tabName : ""); |
| 18 |
}; |
| 19 |
useEffect(() => { |
| 20 |
setTogglePanel("container"); |
| 21 |
}, [isSelected]); |
| 22 |
|
| 23 |
return ( |
| 24 |
<> |
| 25 |
<PanelBody |
| 26 |
title={__("Container Type", "post-carousel")} |
| 27 |
opened={togglePanel === "container"} |
| 28 |
onToggle={(value) => toggleHandler(value, "container")} |
| 29 |
initialOpen={true} |
| 30 |
> |
| 31 |
<TabControls |
| 32 |
attributes={attributes} |
| 33 |
setAttributes={setAttributes} |
| 34 |
GeneralTab={ContainerGeneralTab} |
| 35 |
StyleTab={ContainerStyleTab} |
| 36 |
/> |
| 37 |
</PanelBody> |
| 38 |
<PanelBody |
| 39 |
title={__("Flex Properties", "post-carousel")} |
| 40 |
opened={togglePanel === "flex"} |
| 41 |
onToggle={(value) => toggleHandler(value, "flex")} |
| 42 |
> |
| 43 |
<ContainerFlexProperties attributes={attributes} setAttributes={setAttributes} /> |
| 44 |
</PanelBody> |
| 45 |
<PanelBody |
| 46 |
title={__("Shape Divider", "post-carousel")} |
| 47 |
opened={togglePanel === "shape-divider"} |
| 48 |
onToggle={(value) => toggleHandler(value, "shape-divider")} |
| 49 |
> |
| 50 |
<ContainerShapeDivider attributes={attributes} setAttributes={setAttributes} /> |
| 51 |
</PanelBody> |
| 52 |
<PanelBody |
| 53 |
title={__("Advanced", "post-carousel")} |
| 54 |
opened={togglePanel === "advance"} |
| 55 |
onToggle={(value) => toggleHandler(value, "advance")} |
| 56 |
> |
| 57 |
<TabControls |
| 58 |
attributes={attributes} |
| 59 |
setAttributes={setAttributes} |
| 60 |
displayIcon={false} |
| 61 |
GeneralTab={ContainerAdvancedGeneralTab} |
| 62 |
VisibilityTab={ContainerVisibilityTab} |
| 63 |
AdvancedTab={ContainerAdvanceAdvancedTab} |
| 64 |
/> |
| 65 |
</PanelBody> |
| 66 |
</> |
| 67 |
); |
| 68 |
}; |
| 69 |
|
| 70 |
export default Inspector; |
| 71 |
|