import { __ } from "@wordpress/i18n"; import { useBlockProps, InnerBlocks, useSetting, InspectorControls, MediaReplaceFlow, MediaPlaceholder, } from "@wordpress/block-editor"; import "./editor.scss"; import { isColorLight } from "../../_utilities/utilities"; import { PanelBody, __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, Button, CheckboxControl, ColorPalette, } from "@wordpress/components"; export default function Edit({ attributes, setAttributes, ...props }) { const colors = useSetting("color.palette.theme"); const { hasBackgroundColor, backgroundColor, textColor, hasLightBackground } = attributes; function onBackgroundColorChange(value) { if (value === undefined) { setAttributes({ hasBackgroundColor: false }); setAttributes({ backgroundColor: "transparent" }); } const isLightBackgroundColor = isColorLight(backgroundColor); setAttributes({ hasLightBackground: isLightBackgroundColor }); setAttributes({ backgroundColor: value }); } function onHasBackgroundColorChange(value) { setAttributes({ hasBackgroundColor: value }); if (!value) { setAttributes({ backgroundColor: null }); } } function onTextColorChange(value) { setAttributes({ textColor: value }); } return ( <> {hasBackgroundColor && ( <> )} {hasBackgroundColor && ( <> )}
); }