Skip to content

Commit

Permalink
Cover block: use supports flag for block align (#10758)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill authored and youknowriad committed Mar 6, 2019
1 parent 7434733 commit d2633a1
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions packages/block-library/src/cover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { compose } from '@wordpress/compose';
import {
BlockControls,
InspectorControls,
BlockAlignmentToolbar,
MediaPlaceholder,
MediaUpload,
MediaUploadCheck,
Expand All @@ -34,8 +33,6 @@ import {
getColorClassName,
} from '@wordpress/editor';

const validAlignments = [ 'left', 'center', 'right', 'wide', 'full' ];

const blockAttributes = {
title: {
type: 'string',
Expand All @@ -45,9 +42,6 @@ const blockAttributes = {
url: {
type: 'string',
},
align: {
type: 'string',
},
contentAlign: {
type: 'string',
default: 'center',
Expand Down Expand Up @@ -92,6 +86,10 @@ export const settings = {

attributes: blockAttributes,

supports: {
align: true,
},

transforms: {
from: [
{
Expand Down Expand Up @@ -168,20 +166,12 @@ export const settings = {
],
},

getEditWrapperProps( attributes ) {
const { align } = attributes;
if ( -1 !== validAlignments.indexOf( align ) ) {
return { 'data-align': align };
}
},

edit: compose( [
withColors( { overlayColor: 'background-color' } ),
withNotices,
] )(
( { attributes, setAttributes, isSelected, className, noticeOperations, noticeUI, overlayColor, setOverlayColor } ) => {
const {
align,
backgroundType,
contentAlign,
dimRatio,
Expand All @@ -190,7 +180,6 @@ export const settings = {
title,
url,
} = attributes;
const updateAlignment = ( nextAlign ) => setAttributes( { align: nextAlign } );
const onSelectMedia = ( media ) => {
if ( ! media || ! media.url ) {
setAttributes( { url: undefined, id: undefined } );
Expand Down Expand Up @@ -238,10 +227,6 @@ export const settings = {
const controls = (
<Fragment>
<BlockControls>
<BlockAlignmentToolbar
value={ align }
onChange={ updateAlignment }
/>
{ !! url && (
<Fragment>
<AlignmentToolbar
Expand Down Expand Up @@ -381,7 +366,6 @@ export const settings = {

save( { attributes } ) {
const {
align,
backgroundType,
contentAlign,
customOverlayColor,
Expand All @@ -407,7 +391,6 @@ export const settings = {
'has-parallax': hasParallax,
[ `has-${ contentAlign }-content` ]: contentAlign !== 'center',
},
align ? `align${ align }` : null,
);

return (
Expand All @@ -429,6 +412,9 @@ export const settings = {
deprecated: [ {
attributes: {
...blockAttributes,
align: {
type: 'string',
},
},

supports: {
Expand Down Expand Up @@ -466,6 +452,9 @@ export const settings = {
}, {
attributes: {
...blockAttributes,
align: {
type: 'string',
},
title: {
type: 'string',
source: 'html',
Expand Down

0 comments on commit d2633a1

Please sign in to comment.