From c746b673b28dc927eabe6d7d8445e29ee095ce5d Mon Sep 17 00:00:00 2001 From: Zebulan Stanphill Date: Wed, 17 Oct 2018 15:54:41 -0500 Subject: [PATCH] Archives block: use align supports flag + wide/full align support --- packages/block-library/src/archives/edit.js | 23 ++++--------------- packages/block-library/src/archives/index.js | 8 +------ packages/block-library/src/archives/index.php | 1 + .../full-content/server-registered.json | 2 +- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/packages/block-library/src/archives/edit.js b/packages/block-library/src/archives/edit.js index b59f4dd04d930f..a529b00151c301 100644 --- a/packages/block-library/src/archives/edit.js +++ b/packages/block-library/src/archives/edit.js @@ -1,26 +1,20 @@ /** * WordPress dependencies */ -import { Fragment } from '@wordpress/element'; import { + Disabled, PanelBody, ToggleControl, - Disabled, } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ import { InspectorControls, - BlockAlignmentToolbar, - BlockControls, ServerSideRender, } from '@wordpress/editor'; +import { Fragment } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; export default function ArchivesEdit( { attributes, setAttributes } ) { - const { align, showPostCounts, displayAsDropdown } = attributes; + const { displayAsDropdown, showPostCounts } = attributes; return ( @@ -38,15 +32,6 @@ export default function ArchivesEdit( { attributes, setAttributes } ) { /> - - { - setAttributes( { align: nextAlign } ); - } } - controls={ [ 'left', 'center', 'right' ] } - /> - diff --git a/packages/block-library/src/archives/index.js b/packages/block-library/src/archives/index.js index 8dfca64a8823cd..8b34f786c4c484 100644 --- a/packages/block-library/src/archives/index.js +++ b/packages/block-library/src/archives/index.js @@ -21,16 +21,10 @@ export const settings = { category: 'widgets', supports: { + align: true, html: false, }, - getEditWrapperProps( attributes ) { - const { align } = attributes; - if ( [ 'left', 'center', 'right' ].includes( align ) ) { - return { 'data-align': align }; - } - }, - edit, save() { diff --git a/packages/block-library/src/archives/index.php b/packages/block-library/src/archives/index.php index 3d7b5b42f4ae43..7e557fec126c7f 100644 --- a/packages/block-library/src/archives/index.php +++ b/packages/block-library/src/archives/index.php @@ -126,6 +126,7 @@ function register_block_core_archives() { 'attributes' => array( 'align' => array( 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), ), 'className' => array( 'type' => 'string', diff --git a/test/integration/full-content/server-registered.json b/test/integration/full-content/server-registered.json index 65eb48d6d53f28..a87bd4ef5cecbb 100644 --- a/test/integration/full-content/server-registered.json +++ b/test/integration/full-content/server-registered.json @@ -1 +1 @@ -{"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/latest-comments":{"attributes":{"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true},"align":{"type":"string","enum":["center","left","right","wide","full",""]}}},"core\/archives":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/latest-posts":{"attributes":{"categories":{"type":"string"},"className":{"type":"string"},"postsToShow":{"type":"number","default":5},"displayPostDate":{"type":"boolean","default":false},"postLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":3},"align":{"type":"string"},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"}}}} \ No newline at end of file +{"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/archives":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/latest-comments":{"attributes":{"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true},"align":{"type":"string","enum":["center","left","right","wide","full",""]}}},"core\/latest-posts":{"attributes":{"categories":{"type":"string"},"className":{"type":"string"},"postsToShow":{"type":"number","default":5},"displayPostDate":{"type":"boolean","default":false},"postLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":3},"align":{"type":"string"},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"}}}} \ No newline at end of file