Created
April 8, 2019 18:05
-
-
Save aduth/4e2574991edf62766834cd941b32065e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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