import { __ } from "@wordpress/i18n"; import { Button, GradientPicker } from "@wordpress/components"; import "./editor.scss"; import SpColorPicker from "../color/color"; import SPRangeControl from "../rangeControl/rangeControl"; import MediaPicker from "../mediaUpload/image"; import { useSelect } from "@wordpress/data"; import { priceLink } from "../../blocks/shared/helpFn"; const Background = ({ attributes, attributesKey, setAttributes, label, items, transition, colorLabel = "Background Color", defaultColor, colorType, imageObj = { imageKey: "", backgroundImage: "" } || {}, videoObj = { imageKey: "", backgroundImage: "" } || {}, onStateUpdate = false, pro = false, }) => { const { defaultGradients, customGradients } = useSelect((select) => { const settings = select("smartpost/global-settings"); return { customGradients: settings?.getCustomGradients() || [], defaultGradients: settings?.getDefaultGradient() || [], }; }, []); // Set background type const setBgType = (newValue) => { if (onStateUpdate && "color" === colorType) { onStateUpdate(attributesKey, { ...attributes, color: { ...attributes.color, style: newValue } }); } if (onStateUpdate && "hover" === colorType) { onStateUpdate(attributesKey, { ...attributes, hover: { ...attributes.hover, style: newValue } }); } if (!onStateUpdate && "color" === colorType) { setAttributes({ [attributesKey]: { ...attributes, color: { ...attributes.color, style: newValue }, }, }); } if (!onStateUpdate && "hover" === colorType) { setAttributes({ [attributesKey]: { ...attributes, hover: { ...attributes.hover, style: newValue }, }, }); } }; const gradientValue = attributes[colorType]?.gradient || "linear-gradient(90deg, rgba(0, 0, 0, 0.68) 0.09%, rgba(0, 0, 0, 0.07) 99.95%)"; return ( <>