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

Categories block: use supports flag for alignment + wide alignment support #10666

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 5 additions & 18 deletions packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import { times, unescape } from 'lodash';
/**
* WordPress dependencies
*/
import { Component, Fragment } from '@wordpress/element';
import { PanelBody, Placeholder, Spinner, ToggleControl } from '@wordpress/components';
import { compose, withInstanceId } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { InspectorControls } from '@wordpress/editor';
import { Component, Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { withInstanceId, compose } from '@wordpress/compose';
import {
InspectorControls,
BlockControls,
BlockAlignmentToolbar,
} from '@wordpress/editor';

class CategoriesEdit extends Component {
constructor() {
Expand Down Expand Up @@ -149,8 +145,8 @@ class CategoriesEdit extends Component {
}

render() {
const { attributes, setAttributes, isRequesting } = this.props;
const { align, displayAsDropdown, showHierarchy, showPostCounts } = attributes;
const { attributes, isRequesting } = this.props;
const { displayAsDropdown, showHierarchy, showPostCounts } = attributes;

const inspectorControls = (
<InspectorControls>
Expand Down Expand Up @@ -191,15 +187,6 @@ class CategoriesEdit extends Component {
return (
<Fragment>
{ inspectorControls }
<BlockControls>
ZebulanStanphill marked this conversation as resolved.
Show resolved Hide resolved
<BlockAlignmentToolbar
value={ align }
onChange={ ( nextAlign ) => {
setAttributes( { align: nextAlign } );
} }
controls={ [ 'left', 'center', 'right', 'full' ] }
/>
</BlockControls>
<div className={ this.props.className }>
{
displayAsDropdown ?
Expand Down
11 changes: 1 addition & 10 deletions packages/block-library/src/categories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export const settings = {
category: 'widgets',

attributes: {
align: {
type: 'string',
},
displayAsDropdown: {
type: 'boolean',
default: false,
Expand All @@ -39,16 +36,10 @@ export const settings = {
},

supports: {
align: [ 'left', 'center', 'right', 'wide', 'full' ],
html: false,
},

getEditWrapperProps( attributes ) {
const { align } = attributes;
if ( [ 'left', 'center', 'right', 'full' ].includes( align ) ) {
return { 'data-align': align };
}
},

edit,

save() {
Expand Down