import { __ } from "@wordpress/i18n";
import {
InnerBlocks,
useBlockProps,
InspectorControls,
MediaReplaceFlow,
MediaPlaceholder,
useSetting,
} from "@wordpress/block-editor";
import { lock, trash } from "@wordpress/icons";
import { ColorPalette } from "@wordpress/components";
import {
PanelBody,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
Button,
CheckboxControl,
} from "@wordpress/components";
import "./editor.scss";
export default function Edit({ attributes, setAttributes, ...props }) {
const colors = useSetting("color.palette.theme");
const {
disposition,
coverType,
coverUrl,
coverAlt,
coverId,
coverSize,
hasBackgroundColor,
backgroundColor,
backgroundOrientation,
blockWidth,
textColor,
} = attributes;
function onDispositionChange(disposition) {
setAttributes({ disposition });
}
function setCoverAttributes(cover) {
setAttributes({
coverId: cover.id,
coverAlt: cover.alt,
coverUrl: cover.url,
});
}
function removeCoverAttributes() {
setAttributes({
coverId: null,
coverAlt: null,
coverUrl: null,
});
}
function onBackgroundColorChange(value) {
setAttributes({ backgroundColor: value });
}
function onHasBackgroundColorChange(value) {
setAttributes({ hasBackgroundColor: value });
if (!value) {
setAttributes({ backgroundColor: null });
}
}
function onCoverTypeChange(value) {
setAttributes({ coverType: value });
}
function onBackgroundOrientationChange(value) {
setAttributes({ backgroundOrientation: value });
}
return (
<>
setAttributes({ blockWidth: value })}
value={blockWidth}
>
{coverUrl &&
}
{coverUrl && (
<>
>
)}
setAttributes({ coverSize })}
value={coverSize}
>
{hasBackgroundColor && (
<>
>
)}
setAttributes({ textColor: value })}
/>
{hasBackgroundColor && backgroundColor && (
<>
>
)}
{coverUrl && (
)}
{!coverUrl && (
)}
>
);
}