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

Block library: Refactor color supports handling for mobile #22502

Merged
merged 1 commit into from
May 26, 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
6 changes: 5 additions & 1 deletion packages/block-editor/src/hooks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ import ColorPanel from './color-panel';
export const COLOR_SUPPORT_KEY = '__experimentalColor';

const hasColorSupport = ( blockType ) =>
hasBlockSupport( blockType, COLOR_SUPPORT_KEY );
Platform.OS === 'web' && hasBlockSupport( blockType, COLOR_SUPPORT_KEY );

const hasGradientSupport = ( blockType ) => {
if ( Platform.OS !== 'web' ) {
return false;
}

const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );

return isObject( colorSupport ) && !! colorSupport.gradients;
Expand Down
11 changes: 11 additions & 0 deletions packages/block-library/src/columns/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,16 @@
"verticalAlignment": {
"type": "string"
}
},
"supports": {
"align": [
"wide",
"full"
],
"html": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"gradients": true
}
}
}
8 changes: 1 addition & 7 deletions packages/block-library/src/columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { columns as icon } from '@wordpress/icons';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
*/
Expand All @@ -23,12 +23,6 @@ export const settings = {
description: __(
'Add a block that displays content in multiple columns, then add whatever content blocks you’d like.'
),
supports: {
align: [ 'wide', 'full' ],
html: false,
lightBlockWrapper: true,
__experimentalColor: Platform.OS === 'web' && { gradients: true },
},
variations,
example: {
innerBlocks: [
Expand Down
12 changes: 12 additions & 0 deletions packages/block-library/src/group/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,17 @@
"type": "string",
"default": "div"
}
},
"supports": {
"align": [
"wide",
"full"
],
"anchor": true,
"html": false,
"lightBlockWrapper": true,
"__experimentalColor": {
"gradients": true
}
}
}
9 changes: 0 additions & 9 deletions packages/block-library/src/group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { __ } from '@wordpress/i18n';
import { createBlock } from '@wordpress/blocks';
import { group as icon } from '@wordpress/icons';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -88,13 +87,6 @@ export const settings = {
},
],
},
supports: {
align: [ 'wide', 'full' ],
anchor: true,
html: false,
lightBlockWrapper: true,
__experimentalColor: Platform.OS === 'web' && { gradients: true },
},
transforms: {
from: [
{
Expand Down Expand Up @@ -148,7 +140,6 @@ export const settings = {
},
],
},

edit,
save,
deprecated,
Expand Down
9 changes: 9 additions & 0 deletions packages/block-library/src/heading/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,14 @@
"placeholder": {
"type": "string"
}
},
"supports": {
"className": false,
"anchor": true,
"__unstablePasteTextInline": true,
"lightBlockWrapper": true,
"__experimentalColor": true,
"__experimentalLineHeight": true,
"__experimentalFontSize": true
}
}
10 changes: 0 additions & 10 deletions packages/block-library/src/heading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { isEmpty } from 'lodash';
*/
import { heading as icon } from '@wordpress/icons';
import { __, sprintf } from '@wordpress/i18n';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -30,15 +29,6 @@ export const settings = {
),
icon,
keywords: [ __( 'title' ), __( 'subtitle' ) ],
supports: {
className: false,
anchor: true,
__unstablePasteTextInline: true,
lightBlockWrapper: true,
__experimentalColor: Platform.OS === 'web',
__experimentalLineHeight: true,
__experimentalFontSize: true,
},
example: {
attributes: {
content: __( 'Code is Poetry' ),
Expand Down
10 changes: 10 additions & 0 deletions packages/block-library/src/media-text/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,15 @@
"focalPoint": {
"type": "object"
}
},
"supports": {
"align": [
"wide",
"full"
],
"html": false,
"__experimentalColor": {
"gradients": true
}
}
}
6 changes: 0 additions & 6 deletions packages/block-library/src/media-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { __ } from '@wordpress/i18n';
import { mediaAndText as icon } from '@wordpress/icons';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -23,11 +22,6 @@ export const settings = {
description: __( 'Set media and words side-by-side for a richer layout.' ),
icon,
keywords: [ __( 'image' ), __( 'video' ) ],
supports: {
align: [ 'wide', 'full' ],
html: false,
__experimentalColor: Platform.OS === 'web' && { gradients: true },
},
example: {
attributes: {
mediaType: 'image',
Expand Down
8 changes: 8 additions & 0 deletions packages/block-library/src/paragraph/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,13 @@
"rtl"
]
}
},
"supports": {
"className": false,
"__unstablePasteTextInline": true,
"lightBlockWrapper": true,
"__experimentalColor": true,
"__experimentalLineHeight": true,
"__experimentalFontSize": true
}
}
9 changes: 0 additions & 9 deletions packages/block-library/src/paragraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { isEmpty } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { paragraph as icon } from '@wordpress/icons';
import { Platform } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -41,14 +40,6 @@ export const settings = {
dropCap: true,
},
},
supports: {
className: false,
__unstablePasteTextInline: true,
lightBlockWrapper: true,
__experimentalColor: Platform.OS === 'web',
__experimentalLineHeight: true,
__experimentalFontSize: true,
},
__experimentalLabel( attributes, { context } ) {
if ( context === 'accessibility' ) {
const { content } = attributes;
Expand Down