| 1 |
import { __ } from "@wordpress/i18n"; |
| 2 |
import { PanelBody } from "@wordpress/components"; |
| 3 |
import { Toggle, SPRangeControl, Spacing, TabControls } from "../../components"; |
| 4 |
import { |
| 5 |
FlexJustifyStart, |
| 6 |
FlexJustifyCenter, |
| 7 |
FlexJustifyEnd, |
| 8 |
FlexJustifySpaceBetween, |
| 9 |
FlexJustifySpaceAround, |
| 10 |
FlexJustifySpaceEvenly, |
| 11 |
AlignCenter, |
| 12 |
AlignLeft, |
| 13 |
AlignRight, |
| 14 |
} from "../../icons/icons"; |
| 15 |
import SPToggleGroupControl from "../../components/toggleGroupControl/toggleGroupControl"; |
| 16 |
import { useState } from "@wordpress/element"; |
| 17 |
import { AdvancedTab, VisibilityTab } from "../shared/advancedTab"; |
| 18 |
|
| 19 |
const Inspector = ({ attributes, setAttributes }) => { |
| 20 |
const { |
| 21 |
fullWidthBtnEnable, |
| 22 |
buttonGap, |
| 23 |
buttonsMargin, |
| 24 |
buttonsHorizontalAlignment, |
| 25 |
buttonsVerticalAlignment, |
| 26 |
buttonsAlignment, |
| 27 |
} = attributes; |
| 28 |
const [openPanel, setOpenPanel] = useState("general"); |
| 29 |
const toggleHandler = (value, panelName) => { |
| 30 |
if (value) { |
| 31 |
setOpenPanel(panelName); |
| 32 |
} else { |
| 33 |
setOpenPanel(""); |
| 34 |
} |
| 35 |
}; |
| 36 |
|
| 37 |
return ( |
| 38 |
<> |
| 39 |
<PanelBody |
| 40 |
// initialOpen={true} |
| 41 |
title={__("General", "post-carousel")} |
| 42 |
className="sp-smart-post-section-heading-block-panel-body" |
| 43 |
onToggle={(value) => toggleHandler(value, "general")} |
| 44 |
opened={openPanel === "general"} |
| 45 |
> |
| 46 |
<> |
| 47 |
<SPToggleGroupControl |
| 48 |
attributes={buttonsAlignment} |
| 49 |
items={[ |
| 50 |
{ label: "Horizontal", value: "horizontal" }, |
| 51 |
{ label: "Vertical", value: "vertical" }, |
| 52 |
]} |
| 53 |
onClick={(newVal) => { |
| 54 |
setAttributes({ buttonsAlignment: newVal }); |
| 55 |
}} |
| 56 |
/> |
| 57 |
|
| 58 |
<Toggle |
| 59 |
label={__("Full Width Buttons", "post-carousel")} |
| 60 |
attributes={fullWidthBtnEnable} |
| 61 |
attributesKey={"fullWidthBtnEnable"} |
| 62 |
setAttributes={setAttributes} |
| 63 |
pro={true} |
| 64 |
/> |
| 65 |
|
| 66 |
<SPRangeControl |
| 67 |
label={__("Button Gap", "post-carousel")} |
| 68 |
attributes={buttonGap} |
| 69 |
attributesKey={"buttonGap"} |
| 70 |
setAttributes={setAttributes} |
| 71 |
units={["px", "Em"]} |
| 72 |
defaultValue={{ unit: "px", value: 16 }} |
| 73 |
max={100} |
| 74 |
/> |
| 75 |
|
| 76 |
{"horizontal" === buttonsAlignment ? ( |
| 77 |
<> |
| 78 |
{!fullWidthBtnEnable && ( |
| 79 |
<SPToggleGroupControl |
| 80 |
attributes={buttonsHorizontalAlignment} |
| 81 |
attributesKey={"buttonsHorizontalAlignment"} |
| 82 |
label={__("Horizontal Alignment", "post-carousel")} |
| 83 |
setAttributes={setAttributes} |
| 84 |
extraClass=" sp-svg-rotate-90-reverse" |
| 85 |
showTooltip={true} |
| 86 |
items={[ |
| 87 |
{ |
| 88 |
label: <FlexJustifyStart />, |
| 89 |
value: "flex-start", |
| 90 |
tooltip: "Flex Start" |
| 91 |
}, |
| 92 |
{ |
| 93 |
label: <FlexJustifyCenter />, |
| 94 |
value: "center", |
| 95 |
tooltip: "Center" |
| 96 |
}, |
| 97 |
{ |
| 98 |
label: <FlexJustifyEnd />, |
| 99 |
value: "flex-end", |
| 100 |
tooltip: "Flex End" |
| 101 |
}, |
| 102 |
{ |
| 103 |
label: <FlexJustifySpaceBetween />, |
| 104 |
value: "space-between", |
| 105 |
tooltip: "Space Between" |
| 106 |
}, |
| 107 |
{ |
| 108 |
label: <FlexJustifySpaceAround />, |
| 109 |
value: "space-around", |
| 110 |
tooltip: "Space Around" |
| 111 |
}, |
| 112 |
{ |
| 113 |
label: <FlexJustifySpaceEvenly />, |
| 114 |
value: "space-evenly", |
| 115 |
tooltip: "Space Evenly" |
| 116 |
}, |
| 117 |
]} |
| 118 |
/> |
| 119 |
)} |
| 120 |
</> |
| 121 |
) : ( |
| 122 |
// Hover State |
| 123 |
<> |
| 124 |
{!fullWidthBtnEnable && ( |
| 125 |
<SPToggleGroupControl |
| 126 |
attributes={buttonsVerticalAlignment} |
| 127 |
attributesKey={"buttonsVerticalAlignment"} |
| 128 |
label={__("Vertical Alignment", "post-carousel")} |
| 129 |
setAttributes={setAttributes} |
| 130 |
showTooltip={true} |
| 131 |
items={[ |
| 132 |
{ |
| 133 |
label: <AlignLeft />, |
| 134 |
value: "flex-start", |
| 135 |
tooltip: "Flex Start" |
| 136 |
}, |
| 137 |
{ |
| 138 |
label: <AlignCenter />, |
| 139 |
value: "center", |
| 140 |
tooltip: "Center" |
| 141 |
}, |
| 142 |
{ |
| 143 |
label: <AlignRight />, |
| 144 |
value: "flex-end", |
| 145 |
tooltip: "Flex End" |
| 146 |
}, |
| 147 |
]} |
| 148 |
/> |
| 149 |
)} |
| 150 |
</> |
| 151 |
)} |
| 152 |
|
| 153 |
<Spacing |
| 154 |
label={__("Margin", "post-carousel")} |
| 155 |
attributes={buttonsMargin} |
| 156 |
attributesKey={"buttonsMargin"} |
| 157 |
setAttributes={setAttributes} |
| 158 |
units={["px", "%", "em"]} |
| 159 |
// labelItem={ { |
| 160 |
// top: __( 'Top', 'post-carousel' ), |
| 161 |
// right: __( 'Right', 'post-carousel' ), |
| 162 |
// bottom: __( 'Bottom', 'post-carousel' ), |
| 163 |
// left: __( 'Left', 'post-carousel' ), |
| 164 |
// } } |
| 165 |
defaultValue={{ |
| 166 |
unit: "px", |
| 167 |
value: { |
| 168 |
top: "0", |
| 169 |
right: "0", |
| 170 |
bottom: "0", |
| 171 |
left: "0", |
| 172 |
}, |
| 173 |
}} |
| 174 |
/> |
| 175 |
</> |
| 176 |
</PanelBody> |
| 177 |
<PanelBody |
| 178 |
title={__("Advanced", "post-carousel")} |
| 179 |
opened={openPanel === "advanced"} |
| 180 |
onToggle={(value) => toggleHandler(value, "advanced")} |
| 181 |
> |
| 182 |
{openPanel === "advanced" && ( |
| 183 |
<TabControls |
| 184 |
attributes={attributes} |
| 185 |
setAttributes={setAttributes} |
| 186 |
AdvancedTab={AdvancedTab} |
| 187 |
VisibilityTab={VisibilityTab} |
| 188 |
displayIcon={false} |
| 189 |
initialTab={"visibility"} |
| 190 |
/> |
| 191 |
)} |
| 192 |
</PanelBody> |
| 193 |
</> |
| 194 |
); |
| 195 |
}; |
| 196 |
|
| 197 |
export default Inspector; |
| 198 |
|