| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { InspectorControls } from '@wordpress/block-editor'; |
| 3 |
import { |
| 4 |
PanelBody, |
| 5 |
TextControl, |
| 6 |
BaseControl, |
| 7 |
TabPanel, |
| 8 |
ButtonGroup, |
| 9 |
Button, |
| 10 |
ToggleControl, |
| 11 |
SelectControl |
| 12 |
} from '@wordpress/components'; |
| 13 |
|
| 14 |
import { SOCIAL_SHARE_TITLE_PADDING, SOCIAL_SHARE_TITLE_MARGIN, SOCIAL_SHARE_BOX_HEIGHT, SOCIAL_SHARE_BOX_WIDTH, SOCIAL_SHARE_BOX_PADDING, SOCIAL_SHARE_BOX_MARGIN, SOCIAL_SHARE_BOX_BORDER, SOCIAL_SHARE_CONTENT_ALIGN, SOCIAL_SHARE_ICON_PADDING, SOCIAL_SHARE_ICON_MARGIN, BETTERDOCS_SOCIAL_SHARE_LAYOUTS, SOCIAL_SHARE_TITLE_PADDING_LAYOUT_2, SOCIAL_SHARE_TITLE_MARGIN_LAYOUT_2, SOCIAL_SHARE_BOX_HEIGHT_LAYOUT_2, SOCIAL_SHARE_BOX_WIDTH_LAYOUT_2, SOCIAL_SHARE_BOX_PADDING_LAYOUT_2, SOCIAL_SHARE_BOX_MARGIN_LAYOUT_2, SOCIAL_SHARE_BOX_BORDER_LAYOUT_2, SOCIAL_SHARE_ICON_PADDING_LAYOUT_2, SOCIAL_SHARE_ICON_MARGIN_LAYOUT_2, SOCIAL_SHARE_ICON_WIDTH_LAYOUT_2, SOCIAL_SHARE_ICON_HEIGHT_LAYOUT_2, SOCIAL_SHARE_ICON_OUTER_HEIGHT_LAYOUT_2, SOCIAL_SHARE_ICON_OUTER_WIDTH_LAYOUT_2 } from './constants'; |
| 15 |
import { typoShareTitle, typoShareTitle_Layout_2 } from './typographyPrefixConstants'; |
| 16 |
import ColorControl from "../../../util/color-control"; |
| 17 |
import objAttributes from './attributes'; |
| 18 |
import ResponsiveRangeController from '../../../util/responsive-range-control'; |
| 19 |
import ResponsiveDimensionsControl from "../../../util/dimensions-control-v2"; |
| 20 |
import BorderShadowControl from '../../../util/border-shadow-control'; |
| 21 |
import TypographyDropdown from '../../../util/typography-control-v2'; |
| 22 |
|
| 23 |
const Inspector = ({attributes, setAttributes}) => { |
| 24 |
const { share_title, share_title_tag, share_title_color, share_title_hover_color, share_title_color_layout_2, share_title_hover_color_layout_2, share_content_align_layout_2, share_box_wrapper_color_layout_2, resOption, share_box_wrapper_color, share_content_align, show_facebook_icon, show_twitter_icon, show_linkedin_icon, show_pinterest_icon, layout } = attributes; |
| 25 |
const resRequiredProps = { |
| 26 |
setAttributes, |
| 27 |
resOption, |
| 28 |
attributes, |
| 29 |
objAttributes |
| 30 |
}; |
| 31 |
|
| 32 |
return ( <InspectorControls key="controls"> |
| 33 |
<div className="eb-panel-control"> |
| 34 |
<TabPanel className="eb-parent-tab-panel" activeClass="active-tab" tabs={[ |
| 35 |
{ |
| 36 |
name:"general", |
| 37 |
title:__("General", "betterdocs"), |
| 38 |
className:"eb-tab styles" |
| 39 |
}, |
| 40 |
{ |
| 41 |
name:"styles", |
| 42 |
title:__("Styles", "betterdocs"), |
| 43 |
className:"eb-tab styles" |
| 44 |
} |
| 45 |
]}> |
| 46 |
{ |
| 47 |
(tab) => { |
| 48 |
return ( |
| 49 |
<div className={"eb-tab-controls " + tab.name}> |
| 50 |
{ |
| 51 |
tab?.name == 'general' && ( |
| 52 |
<PanelBody title={__("General", "betterdocs")} initialOpen={true}> |
| 53 |
<SelectControl |
| 54 |
label={__( |
| 55 |
"Select Layout", |
| 56 |
"betterdocs", |
| 57 |
)} |
| 58 |
value={layout} |
| 59 |
options={BETTERDOCS_SOCIAL_SHARE_LAYOUTS} |
| 60 |
onChange={(newLayout) => |
| 61 |
setAttributes({ |
| 62 |
layout: newLayout, |
| 63 |
}) |
| 64 |
} |
| 65 |
/> |
| 66 |
</PanelBody> |
| 67 |
) |
| 68 |
} |
| 69 |
{ |
| 70 |
( tab.name === "styles" && ( |
| 71 |
<> |
| 72 |
<PanelBody title={__("Social Share Title", "betterdocs")} initialOpen={true}> |
| 73 |
<TextControl |
| 74 |
label={(__("Share Title Content", "betterdocs"))} |
| 75 |
value={share_title} |
| 76 |
onChange={((value) => setAttributes({share_title:value}))} |
| 77 |
/> |
| 78 |
<SelectControl |
| 79 |
label={__("Title Tag", "betterdocs")} |
| 80 |
value={share_title_tag} |
| 81 |
options={[ |
| 82 |
{ label: 'H1', value: 'h1' }, |
| 83 |
{ label: 'H2', value: 'h2' }, |
| 84 |
{ label: 'H3', value: 'h3' }, |
| 85 |
{ label: 'H4', value: 'h4' }, |
| 86 |
{ label: 'H5', value: 'h5' }, |
| 87 |
{ label: 'H6', value: 'h6' }, |
| 88 |
]} |
| 89 |
onChange={(value) => setAttributes({share_title_tag: value})} |
| 90 |
/> |
| 91 |
<TypographyDropdown |
| 92 |
baseLabel={__("Title Typography", "betterdocs")} |
| 93 |
resRequiredProps={resRequiredProps} |
| 94 |
typographyPrefixConstant={layout== 'layout-1' ? typoShareTitle : typoShareTitle_Layout_2} |
| 95 |
defaultFontSize={layout== 'layout-1' ? 15 : 32} |
| 96 |
/> |
| 97 |
<BaseControl label={__("Content Alignment", "betterdocs")} id="eb-advance-heading-alignment"> |
| 98 |
<ButtonGroup id="eb-advance-heading-alignment"> |
| 99 |
{SOCIAL_SHARE_CONTENT_ALIGN.map((item, key) => ( |
| 100 |
<Button |
| 101 |
key={key} |
| 102 |
isPrimary={layout == 'layout-1' ? share_content_align === item.value : typoShareTitle_Layout_2 == item.value} |
| 103 |
isSecondary={layout == 'layout-1' ? share_content_align !== item.value : typoShareTitle_Layout_2 != item.value} |
| 104 |
onClick={() => { |
| 105 |
if( layout == 'layout-1' ) { |
| 106 |
setAttributes({ |
| 107 |
share_content_align: item.value, |
| 108 |
}) |
| 109 |
} else { |
| 110 |
setAttributes({ |
| 111 |
share_content_align_layout_2: item.value, |
| 112 |
}) |
| 113 |
} |
| 114 |
}} |
| 115 |
> |
| 116 |
{item.label} |
| 117 |
</Button> |
| 118 |
))} |
| 119 |
</ButtonGroup> |
| 120 |
</BaseControl> |
| 121 |
<ColorControl |
| 122 |
label={__('Title Color', 'betterdocs')} |
| 123 |
color={layout == 'layout-1' ? share_title_color : share_title_color_layout_2} |
| 124 |
onChange={(color) => { |
| 125 |
if( layout == 'layout-1') { |
| 126 |
setAttributes({share_title_color: color}) |
| 127 |
}else { |
| 128 |
setAttributes({share_title_color_layout_2: color}) |
| 129 |
} |
| 130 |
}} |
| 131 |
/> |
| 132 |
<ColorControl |
| 133 |
label={__('Title Hover Color', 'betterdocs')} |
| 134 |
color={layout == 'layout-1' ? share_title_hover_color : share_title_hover_color_layout_2} |
| 135 |
onChange={(color) => { |
| 136 |
if( layout == 'layout-1') { |
| 137 |
setAttributes({share_title_hover_color: color}) |
| 138 |
}else { |
| 139 |
setAttributes({share_title_hover_color_layout_2: color}) |
| 140 |
} |
| 141 |
}} |
| 142 |
/> |
| 143 |
<ResponsiveDimensionsControl |
| 144 |
baseLabel={__("Title Padding", "betterdocs")} |
| 145 |
resRequiredProps={resRequiredProps} |
| 146 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_TITLE_PADDING : SOCIAL_SHARE_TITLE_PADDING_LAYOUT_2} |
| 147 |
/> |
| 148 |
<ResponsiveDimensionsControl |
| 149 |
baseLabel={__("Title Margin", "betterdocs")} |
| 150 |
resRequiredProps={resRequiredProps} |
| 151 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_TITLE_MARGIN : SOCIAL_SHARE_TITLE_MARGIN_LAYOUT_2} |
| 152 |
/> |
| 153 |
</PanelBody> |
| 154 |
<PanelBody title={__("Social Box Wrapper", "betterdocs")} initialOpen={false}> |
| 155 |
<ColorControl |
| 156 |
label={__("Box Background Color")} |
| 157 |
color={layout == 'layout-1' ? share_box_wrapper_color : share_box_wrapper_color_layout_2} |
| 158 |
onChange={(color) => { |
| 159 |
if( layout == 'layout-1' ) { |
| 160 |
setAttributes({share_box_wrapper_color:color}) |
| 161 |
} else { |
| 162 |
setAttributes({share_box_wrapper_color_layout_2:color}) |
| 163 |
} |
| 164 |
}} |
| 165 |
/> |
| 166 |
<ResponsiveRangeController |
| 167 |
baseLabel={__("Box Height", "betterdocs")} |
| 168 |
resRequiredProps={resRequiredProps} |
| 169 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_BOX_HEIGHT : SOCIAL_SHARE_BOX_HEIGHT_LAYOUT_2} |
| 170 |
min={0} |
| 171 |
max={500} |
| 172 |
step={1} |
| 173 |
/> |
| 174 |
<ResponsiveRangeController |
| 175 |
baseLabel={__("Box Width", "betterdocs")} |
| 176 |
resRequiredProps={resRequiredProps} |
| 177 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_BOX_WIDTH : SOCIAL_SHARE_BOX_WIDTH_LAYOUT_2} |
| 178 |
min={0} |
| 179 |
max={1000} |
| 180 |
step={1} |
| 181 |
/> |
| 182 |
<ResponsiveDimensionsControl |
| 183 |
baseLabel={__("Box Padding", "betterdocs")} |
| 184 |
resRequiredProps={resRequiredProps} |
| 185 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_BOX_PADDING : SOCIAL_SHARE_BOX_PADDING_LAYOUT_2} |
| 186 |
/> |
| 187 |
<ResponsiveDimensionsControl |
| 188 |
baseLabel={__("Box Margin", "betterdocs")} |
| 189 |
resRequiredProps={resRequiredProps} |
| 190 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_BOX_MARGIN : SOCIAL_SHARE_BOX_MARGIN_LAYOUT_2} |
| 191 |
/> |
| 192 |
<BorderShadowControl |
| 193 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_BOX_BORDER : SOCIAL_SHARE_BOX_BORDER_LAYOUT_2} |
| 194 |
resRequiredProps={resRequiredProps} |
| 195 |
/> |
| 196 |
</PanelBody> |
| 197 |
<PanelBody title={__("Social Icons", "betterdocs")} initialOpen={false}> |
| 198 |
<ToggleControl |
| 199 |
label={__("Show Facebook Icon", "betterdocs")} |
| 200 |
checked={show_facebook_icon} |
| 201 |
onChange={() => { |
| 202 |
setAttributes({ |
| 203 |
show_facebook_icon: !show_facebook_icon |
| 204 |
}); |
| 205 |
}} |
| 206 |
/> |
| 207 |
<ToggleControl |
| 208 |
label={__("Show Twitter Icon", "betterdocs")} |
| 209 |
checked={show_twitter_icon} |
| 210 |
onChange={() => { |
| 211 |
setAttributes({ |
| 212 |
show_twitter_icon: !show_twitter_icon |
| 213 |
}); |
| 214 |
}} |
| 215 |
/> |
| 216 |
<ToggleControl |
| 217 |
label={__("Show LinkedIn Icon", "betterdocs")} |
| 218 |
checked={show_linkedin_icon} |
| 219 |
onChange={() => { |
| 220 |
setAttributes({ |
| 221 |
show_linkedin_icon: !show_linkedin_icon |
| 222 |
}); |
| 223 |
}} |
| 224 |
/> |
| 225 |
<ToggleControl |
| 226 |
label={__("Show Pinterest Icon", "betterdocs")} |
| 227 |
checked={show_pinterest_icon} |
| 228 |
onChange={() => { |
| 229 |
setAttributes({ |
| 230 |
show_pinterest_icon: !show_pinterest_icon |
| 231 |
}); |
| 232 |
}} |
| 233 |
/> |
| 234 |
<ResponsiveDimensionsControl |
| 235 |
baseLabel={__("Icon Padding", "betterdocs")} |
| 236 |
resRequiredProps={resRequiredProps} |
| 237 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_ICON_PADDING : SOCIAL_SHARE_ICON_PADDING_LAYOUT_2} |
| 238 |
/> |
| 239 |
<ResponsiveDimensionsControl |
| 240 |
baseLabel={__("Icon Margin", "betterdocs")} |
| 241 |
resRequiredProps={resRequiredProps} |
| 242 |
controlName={layout == 'layout-1' ? SOCIAL_SHARE_ICON_MARGIN : SOCIAL_SHARE_ICON_MARGIN_LAYOUT_2} |
| 243 |
/> |
| 244 |
{layout == 'layout-2' && <> |
| 245 |
<ResponsiveRangeController |
| 246 |
baseLabel={__('Icon Width', 'betterdocs')} |
| 247 |
controlName={SOCIAL_SHARE_ICON_WIDTH_LAYOUT_2} |
| 248 |
resRequiredProps={resRequiredProps} |
| 249 |
min={0} |
| 250 |
max={100} |
| 251 |
step={1} |
| 252 |
/> |
| 253 |
<ResponsiveRangeController |
| 254 |
baseLabel={__('Icon Height', 'betterdocs')} |
| 255 |
controlName={SOCIAL_SHARE_ICON_HEIGHT_LAYOUT_2} |
| 256 |
resRequiredProps={resRequiredProps} |
| 257 |
min={0} |
| 258 |
max={100} |
| 259 |
step={1} |
| 260 |
/> |
| 261 |
<ResponsiveRangeController |
| 262 |
baseLabel={__('Icon Outer Width', 'betterdocs')} |
| 263 |
controlName={SOCIAL_SHARE_ICON_OUTER_WIDTH_LAYOUT_2} |
| 264 |
resRequiredProps={resRequiredProps} |
| 265 |
min={0} |
| 266 |
max={100} |
| 267 |
step={1} |
| 268 |
/> |
| 269 |
<ResponsiveRangeController |
| 270 |
baseLabel={__('Icon Outer Height', 'betterdocs')} |
| 271 |
controlName={SOCIAL_SHARE_ICON_OUTER_HEIGHT_LAYOUT_2} |
| 272 |
resRequiredProps={resRequiredProps} |
| 273 |
min={0} |
| 274 |
max={100} |
| 275 |
step={1} |
| 276 |
/> |
| 277 |
</>} |
| 278 |
</PanelBody> |
| 279 |
</> |
| 280 |
) |
| 281 |
) |
| 282 |
} |
| 283 |
</div> |
| 284 |
) |
| 285 |
} |
| 286 |
} |
| 287 |
</TabPanel> |
| 288 |
</div> |
| 289 |
</InspectorControls> |
| 290 |
); |
| 291 |
} |
| 292 |
|
| 293 |
export default Inspector; |
| 294 |
|