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

[Mobile] - Remove usage of ColorEdit in the Button block #33103

Merged
merged 1 commit into from
Jul 1, 2021
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
4 changes: 0 additions & 4 deletions packages/block-editor/src/hooks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ const hasLinkColorSupport = ( blockType ) => {
};

const hasGradientSupport = ( blockType ) => {
if ( Platform.OS !== 'web' ) {
oandregal marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );

return isObject( colorSupport ) && !! colorSupport.gradients;
Expand Down
248 changes: 0 additions & 248 deletions packages/block-library/src/button/color-edit.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { link } from '@wordpress/icons';
import richTextStyle from './rich-text.scss';
import styles from './editor.scss';
import ColorBackground from './color-background';
import ColorEdit from './color-edit';

const MIN_BORDER_RADIUS_VALUE = 0;
const MAX_BORDER_RADIUS_VALUE = 50;
Expand Down Expand Up @@ -500,7 +499,6 @@ class ButtonEdit extends Component {
</ToolbarGroup>
</BlockControls>
{ this.getLinkSettings( false ) }
<ColorEdit { ...this.props } />
oandregal marked this conversation as resolved.
Show resolved Hide resolved
<InspectorControls>
<PanelBody title={ __( 'Border Settings' ) }>
<RangeControl
Expand Down
14 changes: 14 additions & 0 deletions packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ import * as socialLinks from './social-links';

import { transformationCategory } from './transformationCategories';

const ALLOWED_BLOCKS_GRADIENT_SUPPORT = [ 'core/button' ];
oandregal marked this conversation as resolved.
Show resolved Hide resolved

export const coreBlocks = [
// Common blocks are grouped at the top to prioritize their display
// in various contexts — like the inserter and auto-complete components.
Expand Down Expand Up @@ -127,10 +129,22 @@ const registerBlock = ( block ) => {
return;
}
const { metadata, settings, name } = block;
const { supports } = metadata;

registerBlockType(
{
name,
...metadata,
// Gradients support only available for blocks listed in ALLOWED_BLOCKS_GRADIENT_SUPPORT
...( ! ALLOWED_BLOCKS_GRADIENT_SUPPORT.includes( name ) &&
supports?.color?.gradients
? {
supports: {
...supports,
color: { ...supports.color, gradients: false },
},
}
: {} ),
},
settings
);
Expand Down