add toolbaritem button
This commit is contained in:
parent
2d4e04211b
commit
be412544ee
12
src/index.js
12
src/index.js
|
@ -45,6 +45,10 @@ registerBlockType(`${NAMESPACE}/${SLUG}`, {
|
|||
type: 'string',
|
||||
default: 'rgba(0, 0, 0, 1)',
|
||||
},
|
||||
toggle: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
edit({ attributes, setAttributes, className }) {
|
||||
|
@ -70,11 +74,11 @@ registerBlockType(`${NAMESPACE}/${SLUG}`, {
|
|||
<ToolbarGroup>
|
||||
<ToolbarItem
|
||||
as={Button}
|
||||
onClick={() =>
|
||||
console.log('Toolbar Button go brrrr!')
|
||||
}
|
||||
onClick={() => {
|
||||
setAttributes({ toggle: !attributes.toggle });
|
||||
}}
|
||||
>
|
||||
Toolbar Button
|
||||
Toggle {attributes.toggle ? 'On' : 'Off'}
|
||||
</ToolbarItem>
|
||||
</ToolbarGroup>
|
||||
</BlockControls>
|
||||
|
|
Loading…
Reference in New Issue