62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
import { __ } from '@wordpress/i18n';
|
|
|
|
/**
|
|
* React hook that is used to mark the block wrapper element.
|
|
* It provides all the necessary props like the class name.
|
|
*
|
|
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps
|
|
*/
|
|
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
|
import { ColorPicker } from '@wordpress/components';
|
|
|
|
/**
|
|
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files.
|
|
* Those files can contain any CSS code that gets applied to the editor.
|
|
*
|
|
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css
|
|
*/
|
|
import './editor.scss';
|
|
|
|
/**
|
|
* The edit function describes the structure of your block in the context of the
|
|
* editor. This represents what the editor will render when the block is used.
|
|
*
|
|
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit
|
|
*
|
|
* @return {WPElement} Element to render.
|
|
*/
|
|
export default function Edit({ attributes, setAttributes }) {
|
|
return (
|
|
<>
|
|
<InspectorControls>
|
|
<ColorPicker
|
|
color={attributes.backgroundColor}
|
|
onChange={(color) =>
|
|
setAttributes({backgroundColor: color})
|
|
}
|
|
enableAlpha
|
|
defaultValue="#000"
|
|
/>
|
|
</InspectorControls>
|
|
|
|
<li { ...useBlockProps({
|
|
className: 'orbital',
|
|
style: {
|
|
color: attributes.backgroundColor,
|
|
}
|
|
}) }>
|
|
<div className="orbital-content content-center anti-clockwise">
|
|
<div className="feature">
|
|
<div className="feature-item primary">
|
|
<img className="img" src={attributes.imgSrc} />
|
|
</div>
|
|
<div className="feature-item secondary">
|
|
<p>Hallo!</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
</>
|
|
);
|
|
}
|