WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

Feature: Customise color picker 'Text' label #41877

Open loopmasta opened 2 years ago

loopmasta commented 2 years ago

What problem does this address?

The hardcoded label 'Text' of the color picker component generated by the supports API is misleading if the output of a block is not text but a font icon or some other output which is not recognised by the user as text. This patch enables a Gutenberg block developer to add a optional label to the otherwise hardcoded label 'Text' of the color picker.

What is your proposed solution?

The supports API for the color section is extended by a new key e.g. experimentalTextLabel. If this key exists and has a value the default label 'Text' is replaced by this value. To use it register a block with the supports API color feature and add the key experimentalTextLabel with a I18N string. See example below.

registerBlockType( 'loopmasta/icon', {
    ...
    supports: {
        color: {
            text: true,
            background: true,
            link: false,
            __experimentalTextLabel: __( 'Icon', 'loopmasta-icon' ),
        }
    },
    ...
} );

pull __experimentalTextColorLabel

loopmasta commented 2 years ago

@kathrynwp 👍

richtabor commented 1 year ago

Was coming here to suggest the same general idea. I like the idea of tailoring existing controls.

loopmasta commented 1 year ago

@skorasaurus This issue is not about inserting settings to a Color panel that you add to your code (e.g. InspectorControls) and have control over but a Color panel that is controlled and rendered via the supports API and therefor excludes the possibility to change its settings. The proposed patch allows a developer to do just that.