Skip to content

Instantly share code, notes, and snippets.

@aduth
Created April 8, 2019 18:05
Show Gist options
  • Save aduth/4e2574991edf62766834cd941b32065e to your computer and use it in GitHub Desktop.
Save aduth/4e2574991edf62766834cd941b32065e to your computer and use it in GitHub Desktop.
registerBlockType( 'core/colorable', {
abstract: true,
attributes: {
color: {
type: 'string',
},
},
edit: () => (
<InspectorControls>
<PanelColorSettings /* ... */ />
</InspectorControls
),
save( { children, attributes } ) {
const child = Children.only( children );
return cloneElement( child, {
style: {
...child.props.style,
color: attributes.color,
},
} );
},
} );
registerBlockType( 'core/paragraph', {
uses: [ 'core/colorable' ],
// ...
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment