Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make link color control opt-in #23049

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,21 @@ function gutenberg_extend_settings_custom_spacing( $settings ) {
}
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_custom_spacing' );


/**
* Extends block editor settings to determine whether to use custom spacing controls.
* Currently experimental.
*
* @param array $settings Default editor settings.
*
* @return array Filtered editor settings.
*/
function gutenberg_extend_settings_link_color( $settings ) {
$settings['__experimentalEnableLinkColor'] = get_theme_support( 'experimental-link-color' );
return $settings;
}
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_link_color' );

/*
* Register default patterns if not registered in Core already.
*/
Expand Down
13 changes: 9 additions & 4 deletions packages/block-editor/src/hooks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ const getLinkColorFromAttributeValue = ( colors, value ) => {
*/
export function ColorEdit( props ) {
const { name: blockName, attributes } = props;
const { colors, gradients } = useSelect( ( select ) => {
return select( 'core/block-editor' ).getSettings();
}, [] );
const { colors, gradients, __experimentalEnableLinkColor } = useSelect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it's possible to use the useFeature hook introduced by @gziolo or is it only for theme.json for now?

Copy link
Member Author

@oandregal oandregal Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it only reads from theme.json at the moment and not yet from add_theme_support

( select ) => {
return select( 'core/block-editor' ).getSettings();
},
[]
);

// Shouldn't be needed but right now the ColorGradientsPanel
// can trigger both onChangeColor and onChangeBackground
// synchronously causing our two callbacks to override changes
Expand Down Expand Up @@ -310,7 +314,8 @@ export function ColorEdit( props ) {
? onChangeGradient
: undefined,
},
...( hasLinkColorSupport( blockName )
...( __experimentalEnableLinkColor &&
hasLinkColorSupport( blockName )
? [
{
label: __( 'Link Color' ),
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class EditorProvider extends Component {
'__experimentalDisableCustomLineHeight',
'__experimentalEnableCustomSpacing',
'__experimentalEnableLegacyWidgetBlock',
'__experimentalEnableLinkColor',
'__experimentalEnableFullSiteEditing',
'__experimentalEnableFullSiteEditingDemo',
'__experimentalFeatures',
Expand Down