| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { SPRangeControl, TabControls } from "../../components"; |
| 4 |
import { AdvancedTab, VisibilityTab } from "../shared/advancedTab"; |
| 5 |
|
| 6 |
import { PresetToc, TocCollapsibleGeneral, TocHeading, TocListBodyGeneral } from "./generalTabs"; |
| 7 |
import { StyleTab, TocCollapsibleStyleTab, TocHeadingStyleTab, TocListBodyStyleTab } from "./styleTab"; |
| 8 |
import { usePanelBodyContext } from "../../context"; |
| 9 |
import Toggle from "../../components/toggle/toggle"; |
| 10 |
|
| 11 |
const Inspector = ({ attributes, setAttributes }) => { |
| 12 |
const { openPanel, togglePanelBody } = usePanelBodyContext(); |
| 13 |
const { blockName, smoothScroll, backToTop, offsetTop } = attributes; |
| 14 |
|
| 15 |
return ( |
| 16 |
<> |
| 17 |
<PanelBody |
| 18 |
title={__("Preset", "post-carousel")} |
| 19 |
opened={openPanel === "preset"} |
| 20 |
onToggle={() => togglePanelBody("preset")} |
| 21 |
> |
| 22 |
{openPanel === "preset" && ( |
| 23 |
<TabControls |
| 24 |
attributes={attributes} |
| 25 |
setAttributes={setAttributes} |
| 26 |
Preset={PresetToc} |
| 27 |
StyleTab={StyleTab} |
| 28 |
displayIcon={true} |
| 29 |
blockName={blockName} |
| 30 |
initialTab={"preset"} |
| 31 |
/> |
| 32 |
)} |
| 33 |
</PanelBody> |
| 34 |
|
| 35 |
<PanelBody |
| 36 |
title={__("TOC Heading", "post-carousel")} |
| 37 |
className="sp-smart-post-section-heading-block-panel-body" |
| 38 |
opened={openPanel === "heading"} |
| 39 |
onToggle={() => togglePanelBody("heading")} |
| 40 |
> |
| 41 |
{openPanel === "heading" && ( |
| 42 |
<TabControls |
| 43 |
attributes={attributes} |
| 44 |
setAttributes={setAttributes} |
| 45 |
GeneralTab={TocHeading} |
| 46 |
StyleTab={TocHeadingStyleTab} |
| 47 |
displayIcon={true} |
| 48 |
blockName={blockName} |
| 49 |
/> |
| 50 |
)} |
| 51 |
</PanelBody> |
| 52 |
|
| 53 |
<PanelBody |
| 54 |
opened={openPanel === "tocBody"} |
| 55 |
onToggle={() => togglePanelBody("tocBody")} |
| 56 |
title={__("TOC List Body", "post-carousel")} |
| 57 |
className="sp-smart-post-section-heading-block-panel-body" |
| 58 |
> |
| 59 |
{openPanel === "tocBody" && ( |
| 60 |
<TabControls |
| 61 |
attributes={attributes} |
| 62 |
setAttributes={setAttributes} |
| 63 |
GeneralTab={TocListBodyGeneral} |
| 64 |
StyleTab={TocListBodyStyleTab} |
| 65 |
displayIcon={true} |
| 66 |
blockName={blockName} |
| 67 |
/> |
| 68 |
)} |
| 69 |
</PanelBody> |
| 70 |
|
| 71 |
<PanelBody |
| 72 |
opened={openPanel === "collapsible"} |
| 73 |
onToggle={() => togglePanelBody("collapsible")} |
| 74 |
title={__("Collapsible", "post-carousel")} |
| 75 |
className="sp-smart-post-section-heading-block-panel-body" |
| 76 |
> |
| 77 |
{openPanel === "collapsible" && ( |
| 78 |
<TabControls |
| 79 |
attributes={attributes} |
| 80 |
setAttributes={setAttributes} |
| 81 |
GeneralTab={TocCollapsibleGeneral} |
| 82 |
StyleTab={TocCollapsibleStyleTab} |
| 83 |
displayIcon={true} |
| 84 |
blockName={blockName} |
| 85 |
/> |
| 86 |
)} |
| 87 |
</PanelBody> |
| 88 |
|
| 89 |
<PanelBody |
| 90 |
opened={openPanel === "scroll"} |
| 91 |
onToggle={() => togglePanelBody("scroll")} |
| 92 |
title={__("Scroll", "post-carousel")} |
| 93 |
className="sp-smart-post-section-heading-block-panel-body" |
| 94 |
> |
| 95 |
<Toggle |
| 96 |
label={__("Smooth Scroll", "post-carousel")} |
| 97 |
attributes={smoothScroll} |
| 98 |
attributesKey={"smoothScroll"} |
| 99 |
setAttributes={setAttributes} |
| 100 |
/> |
| 101 |
|
| 102 |
<SPRangeControl |
| 103 |
label={__("Offset Top", "post-carousel")} |
| 104 |
setAttributes={setAttributes} |
| 105 |
attributes={offsetTop} |
| 106 |
max={200} |
| 107 |
min={1} |
| 108 |
attributesKey={"offsetTop"} |
| 109 |
defaultValue={{ unit: "", value: 50 }} |
| 110 |
/> |
| 111 |
{/* <Toggle |
| 112 |
label={__("Back to Top", "post-carousel")} |
| 113 |
attributes={backToTop} |
| 114 |
attributesKey={"backToTop"} |
| 115 |
setAttributes={setAttributes} |
| 116 |
/> */} |
| 117 |
|
| 118 |
</PanelBody> |
| 119 |
|
| 120 |
<PanelBody |
| 121 |
opened={openPanel === "advanced"} |
| 122 |
onToggle={() => togglePanelBody("advanced")} |
| 123 |
title={__("Advanced", "post-carousel")} |
| 124 |
> |
| 125 |
<TabControls |
| 126 |
attributes={attributes} |
| 127 |
setAttributes={setAttributes} |
| 128 |
AdvancedTab={AdvancedTab} |
| 129 |
VisibilityTab={VisibilityTab} |
| 130 |
displayIcon={false} |
| 131 |
initialTab={"visibility"} |
| 132 |
/> |
| 133 |
</PanelBody> |
| 134 |
</> |
| 135 |
); |
| 136 |
}; |
| 137 |
|
| 138 |
export default Inspector; |
| 139 |
|