| 1 |
/** |
| 2 |
* WordPress dependencies |
| 3 |
*/ |
| 4 |
const { __ } = wp.i18n; |
| 5 |
const { ToggleControl } = wp.components; |
| 6 |
|
| 7 |
/** |
| 8 |
* Internal dependencies |
| 9 |
*/ |
| 10 |
import OverlayControl from "./overlayControl"; |
| 11 |
import BgControl from "./bgControl"; |
| 12 |
|
| 13 |
export default function BackgroundControl({ |
| 14 |
resRequiredProps, |
| 15 |
controlName, |
| 16 |
noOverlay = false, |
| 17 |
noMainBgi = false, |
| 18 |
noOverlayBgi = false, |
| 19 |
noTransition = false, |
| 20 |
|
| 21 |
// |
| 22 |
forButton = false, |
| 23 |
}) { |
| 24 |
const { setAttributes, attributes } = resRequiredProps; |
| 25 |
|
| 26 |
const { [`${controlName}isBgOverlay`]: isBgOverlay } = attributes; |
| 27 |
|
| 28 |
return ( |
| 29 |
<> |
| 30 |
<BgControl |
| 31 |
resRequiredProps={resRequiredProps} |
| 32 |
controlName={controlName} |
| 33 |
noMainBgi={forButton === true ? true : noMainBgi} |
| 34 |
noTransition={noTransition} |
| 35 |
/> |
| 36 |
|
| 37 |
{noOverlay === false && forButton == false && ( |
| 38 |
<> |
| 39 |
<hr /> |
| 40 |
|
| 41 |
<ToggleControl |
| 42 |
label={__("Enable Overlay", "betterdocs")} |
| 43 |
checked={isBgOverlay} |
| 44 |
onChange={() => |
| 45 |
setAttributes({ |
| 46 |
[`${controlName}isBgOverlay`]: !isBgOverlay, |
| 47 |
}) |
| 48 |
} |
| 49 |
/> |
| 50 |
|
| 51 |
{isBgOverlay && ( |
| 52 |
<OverlayControl |
| 53 |
resRequiredProps={resRequiredProps} |
| 54 |
controlName={controlName} |
| 55 |
noOverlayBgi={noOverlayBgi} |
| 56 |
noTransition={noTransition} |
| 57 |
/> |
| 58 |
)} |
| 59 |
</> |
| 60 |
)} |
| 61 |
</> |
| 62 |
); |
| 63 |
} |
| 64 |
|