-
Notifications
You must be signed in to change notification settings - Fork 6
OpacityControl Component
Josh_soporte edited this page Jul 15, 2020
·
1 revision
Include opacity options on Inspector Control for the Block.
'/src/components/opacity-control'
Renders OpacityControl on Inspector Control:
const { __ } = wp.i18n;
const { InspectorControls } = wp.blockEditor;
const { registerBlockType } = wp.blocks;
#Component
import OpacityControl from '../components/opacity-control/';
registerBlockType( 'maxi-blocks/example-block', {
title: __('Example block', 'maxi-blocks'),
icon: icon,
category: 'maxi-blocks',
attributes: {
opacityExample: {
type: 'string',
default: JSON.stringify(mainObject)
}
},
edit: (props) => {
return (
<InspectorControls>
<OpacityControl
opacity={props.attributes.opacityExample}
onChange={value => props.setAttributes({ props.attributes.opacityrExample: value })}
breakpoint={deviceType}
/>
</InspectorControls>
)
}
save: () => {
return null;
}
} );
Name | Type | Default | Required | Description |
---|---|---|---|---|
opacity | string |
none |
Y | Block property with stringified object saved value |
className | string |
maxi-opacity-control |
N | Retrieve a class for the component |
onChange | function |
undefined |
Y | Retrieve input value to be saved |
breakpoint | string |
none |
Y | Responsive stage |