const { __ } = wp.i18n; const { MediaUpload } = wp.blockEditor; const { SelectControl, Button, RangeControl, BaseControl, ButtonGroup } = wp.components; /** * Internal dependencies */ import GradientColorControl from "../gradient-color-controller"; import UnitControl from "../unit-control"; import ColorControl from "../color-control"; import ImageAvatar from "../image-avatar"; import WithResButtons from "../withResButtons"; export default function bgControl({ resRequiredProps, controlName, noMainBgi, noTransition, }) { const { setAttributes, attributes, resOption } = resRequiredProps; const { [`${controlName}bg_hoverType`]: bg_hoverType, [`${controlName}bg_transition`]: bg_transition, // attributes for bg_hoverType normal start ⬇ [`${controlName}backgroundType`]: backgroundType, [`${controlName}backgroundColor`]: backgroundColor, [`${controlName}gradientColor`]: gradientColor, [`${controlName}bgImageURL`]: bgImageURL, [`${controlName}bgImageID`]: bgImageID, [`${controlName}bgImgAttachment`]: bgImgAttachment, [`${controlName}backgroundSize`]: backgroundSize, [`${controlName}bgImgCustomSize`]: bgImgCustomSize, [`${controlName}bgImgCustomSizeUnit`]: bgImgCustomSizeUnit, [`${controlName}bgImgPos`]: bgImgPos, [`${controlName}bgImgcustomPosX`]: bgImgcustomPosX, [`${controlName}bgImgcustomPosXUnit`]: bgImgcustomPosXUnit, [`${controlName}bgImgcustomPosY`]: bgImgcustomPosY, [`${controlName}bgImgcustomPosYUnit`]: bgImgcustomPosYUnit, [`${controlName}bgImgRepeat`]: bgImgRepeat, [`TAB${controlName}backgroundSize`]: TABbackgroundSize, [`TAB${controlName}bgImgCustomSize`]: TABbgImgCustomSize, [`TAB${controlName}bgImgCustomSizeUnit`]: TABbgImgCustomSizeUnit, [`TAB${controlName}bgImgPos`]: TABbgImgPos, [`TAB${controlName}bgImgcustomPosX`]: TABbgImgcustomPosX, [`TAB${controlName}bgImgcustomPosXUnit`]: TABbgImgcustomPosXUnit, [`TAB${controlName}bgImgcustomPosY`]: TABbgImgcustomPosY, [`TAB${controlName}bgImgcustomPosYUnit`]: TABbgImgcustomPosYUnit, [`TAB${controlName}bgImgRepeat`]: TABbgImgRepeat, [`MOB${controlName}backgroundSize`]: MOBbackgroundSize, [`MOB${controlName}bgImgCustomSize`]: MOBbgImgCustomSize, [`MOB${controlName}bgImgCustomSizeUnit`]: MOBbgImgCustomSizeUnit, [`MOB${controlName}bgImgPos`]: MOBbgImgPos, [`MOB${controlName}bgImgcustomPosX`]: MOBbgImgcustomPosX, [`MOB${controlName}bgImgcustomPosXUnit`]: MOBbgImgcustomPosXUnit, [`MOB${controlName}bgImgcustomPosY`]: MOBbgImgcustomPosY, [`MOB${controlName}bgImgcustomPosYUnit`]: MOBbgImgcustomPosYUnit, [`MOB${controlName}bgImgRepeat`]: MOBbgImgRepeat, // attributes for bg_hoverType normal end // attributes for bg_hoverType hover start ⬇ [`hov_${controlName}backgroundType`]: hov_backgroundType, [`hov_${controlName}backgroundColor`]: hov_backgroundColor, [`hov_${controlName}gradientColor`]: hov_gradientColor, [`hov_${controlName}bgImageURL`]: hov_bgImageURL, [`hov_${controlName}bgImageID`]: hov_bgImageID, [`hov_${controlName}bgImgAttachment`]: hov_bgImgAttachment, [`hov_${controlName}backgroundSize`]: hov_backgroundSize, [`hov_${controlName}bgImgCustomSize`]: hov_bgImgCustomSize, [`hov_${controlName}bgImgCustomSizeUnit`]: hov_bgImgCustomSizeUnit, [`hov_${controlName}bgImgPos`]: hov_bgImgPos, [`hov_${controlName}bgImgcustomPosX`]: hov_bgImgcustomPosX, [`hov_${controlName}bgImgcustomPosXUnit`]: hov_bgImgcustomPosXUnit, [`hov_${controlName}bgImgcustomPosY`]: hov_bgImgcustomPosY, [`hov_${controlName}bgImgcustomPosYUnit`]: hov_bgImgcustomPosYUnit, [`hov_${controlName}bgImgRepeat`]: hov_bgImgRepeat, [`hov_TAB${controlName}backgroundSize`]: hov_TABbackgroundSize, [`hov_TAB${controlName}bgImgCustomSize`]: hov_TABbgImgCustomSize, [`hov_TAB${controlName}bgImgCustomSizeUnit`]: hov_TABbgImgCustomSizeUnit, [`hov_TAB${controlName}bgImgPos`]: hov_TABbgImgPos, [`hov_TAB${controlName}bgImgcustomPosX`]: hov_TABbgImgcustomPosX, [`hov_TAB${controlName}bgImgcustomPosXUnit`]: hov_TABbgImgcustomPosXUnit, [`hov_TAB${controlName}bgImgcustomPosY`]: hov_TABbgImgcustomPosY, [`hov_TAB${controlName}bgImgcustomPosYUnit`]: hov_TABbgImgcustomPosYUnit, [`hov_TAB${controlName}bgImgRepeat`]: hov_TABbgImgRepeat, [`hov_MOB${controlName}backgroundSize`]: hov_MOBbackgroundSize, [`hov_MOB${controlName}bgImgCustomSize`]: hov_MOBbgImgCustomSize, [`hov_MOB${controlName}bgImgCustomSizeUnit`]: hov_MOBbgImgCustomSizeUnit, [`hov_MOB${controlName}bgImgPos`]: hov_MOBbgImgPos, [`hov_MOB${controlName}bgImgcustomPosX`]: hov_MOBbgImgcustomPosX, [`hov_MOB${controlName}bgImgcustomPosXUnit`]: hov_MOBbgImgcustomPosXUnit, [`hov_MOB${controlName}bgImgcustomPosY`]: hov_MOBbgImgcustomPosY, [`hov_MOB${controlName}bgImgcustomPosYUnit`]: hov_MOBbgImgcustomPosYUnit, [`hov_MOB${controlName}bgImgRepeat`]: hov_MOBbgImgRepeat, // attributes for bg_hoverType hover end } = attributes; return ( <> {[ { label: __("Normal", "betterdocs"), value: "normal" }, { label: __("Hover", "betterdocs"), value: "hover" }, ].map(({ value, label }) => ( ))} {bg_hoverType === "normal" && ( <> {[ { label: __("Classic", "betterdocs"), value: "classic" }, { label: __("Gradient", "betterdocs"), value: "gradient" }, ].map(({ value, label }) => ( ))} {backgroundType === "classic" && ( <> setAttributes({ [`${controlName}backgroundColor`]: backgroundColor, }) } /> {noMainBgi === false && ( <> setAttributes({ [`${controlName}bgImageURL`]: url, [`${controlName}bgImageID`]: id, }) } type="image" value={bgImageID} render={({ open }) => !bgImageURL && ( <> ))} {hov_backgroundType === "classic" && ( <> setAttributes({ [`hov_${controlName}backgroundColor`]: hov_backgroundColor, }) } /> {noMainBgi === false && ( <> setAttributes({ [`hov_${controlName}bgImageURL`]: url, [`hov_${controlName}bgImageID`]: id, }) } type="image" value={hov_bgImageID} render={({ open }) => !hov_bgImageURL && ( <>