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, coverUrl, coverAlt, coverId, coverSize, hasBackgroundColor, backgroundColor, backgroundOrientation, } = attributes; function onDispositionChange(disposition) { setAttributes({ disposition }); } function onCoverSizeChange(coverSize) { setAttributes({ coverSize }); } 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 onBackgroundOrientationChange(value) { setAttributes({ backgroundOrientation: value }); } return ( <> {coverUrl && {coverAlt}}
{coverUrl && ( <>
{hasBackgroundColor && ( <> )}
{hasBackgroundColor && backgroundColor && ( )}
{coverUrl && ( {coverAlt} )} {!coverUrl && ( )}
); }