Skip to content

Inspector component hooks #307

Description

@tomjn

I had an idea of using hooks to provide super quick to create block inspector controls. You'd call the hook with an attribute and attribute name, and it would return the value and an inspector component ready to slot into a block inspector slot

Something like this:

const { title, titleControl }  = useTextField( 'title', attributes.title );
const { headerImageSrc, headerImageId, headerImageControl } = useImageField( 'headerImageId' attributes.headerImageId );
<InspectorControls>
    { titleControl }
    { headerImageControl }
</InspectorControls>

I can see this being a super easy way to spin up a blocks attributes and their UI for checkboxes, images, etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions