-
Notifications
You must be signed in to change notification settings - Fork 8
Image Position Control Component
Josh_soporte edited this page Apr 25, 2020
·
1 revision
Include a selector with image position options Inspector Control for the Block.
'/src/components/image-position-control'
Renders a selector with image position options on Inspector Control:
const { __ } = wp.i18n;
const { InspectorControls } = wp.blockEditor;
const { registerBlockType } = wp.blocks;
#Component
import ImagePositionControl from '../components/image-position-control';
registerBlockType( 'gutenberg-extra/example-block', {
title: __('Example block', 'gutenberg-extra'),
icon: icon,
category: 'gutenberg-extra-blocks',
supports: {
align: true,
},
attributes: {
imagePosition: {
type: 'string',
default: 'top',
},
},
edit: (props) => {
return (
<InspectorControls>
<ImagePosition
value={props.attributes.imagePosition}
onChange={value => props.setAttributes({ props.attributes.imagePosition: value })}
/>
</InspectorControls>
)
}
save: () => {
return null;
}
} );
Name | Type | Default | Required | Description |
---|---|---|---|---|
value |
string |
top |
Y | Block property with saved value |
onChange |
function |
undefined |
N | Retrieve input value to be saved |
options |
array |
[{ label: __('Before', 'gutenbgerg-extra'), value: 'top' },{ label: __('After', 'gutenbgerg-extra'), value: 'bottom' },{ label: __('Left', 'gutenbgerg-extra'), value: 'left' },{ label: __('Right', 'gutenbgerg-extra'), value: 'right' },] |
N | Selector options, in default with options such as: Top , After , Left and Right
|