Skip to content

Commit

Permalink
Buttons block: remove block alignment options.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed Jun 15, 2020
1 parent 60ef323 commit 5174a52
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/patterns/two-buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

return array(
'title' => __( 'Two Buttons', 'gutenberg' ),
'content' => "<!-- wp:buttons {\"align\":\"center\"} -->\n<div class=\"wp-block-buttons aligncenter\"><!-- wp:button {\"backgroundColor\":\"very-dark-gray\",\"borderRadius\":0} -->\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-background has-very-dark-gray-background-color no-border-radius\">Button One</a></div>\n<!-- /wp:button -->\n\n<!-- wp:button {\"textColor\":\"very-dark-gray\",\"borderRadius\":0,\"className\":\"is-style-outline\"} -->\n<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link has-text-color has-very-dark-gray-color no-border-radius\">Button Two</a></div>\n<!-- /wp:button --></div>\n<!-- /wp:buttons -->",
'content' => "<!-- wp:buttons -->\n<div class=\"wp-block-buttons\"><!-- wp:button {\"backgroundColor\":\"very-dark-gray\",\"borderRadius\":0} -->\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-background has-very-dark-gray-background-color no-border-radius\">Button One</a></div>\n<!-- /wp:button -->\n\n<!-- wp:button {\"textColor\":\"very-dark-gray\",\"borderRadius\":0,\"className\":\"is-style-outline\"} -->\n<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link has-text-color has-very-dark-gray-color no-border-radius\">Button Two</a></div>\n<!-- /wp:button --></div>\n<!-- /wp:buttons -->",
'viewportWidth' => 500,
'categories' => array( 'buttons' ),
);
2 changes: 0 additions & 2 deletions packages/block-library/src/buttons/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"name": "core/buttons",
"category": "design",
"supports": {
"align": true,
"alignWide": false,
"lightBlockWrapper": true
}
}
30 changes: 30 additions & 0 deletions packages/block-library/src/buttons/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* External dependencies
*/
import { omit } from 'lodash';

/**
* WordPress dependencies
*/
import { InnerBlocks } from '@wordpress/block-editor';

const deprecated = [
{
supports: {
align: true,
alignWide: false,
},
save() {
return (
<div>
<InnerBlocks.Content />
</div>
);
},
migrate( attributes ) {
return omit( attributes, [ 'align' ] );
},
},
];

export default deprecated;
3 changes: 0 additions & 3 deletions packages/block-library/src/buttons/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ const BUTTONS_TEMPLATE = [ [ 'core/button' ] ];

function ButtonsEdit( {
isSelected,
attributes,
onDelete,
onAddNextButton,
shouldDelete,
isInnerButtonSelected,
} ) {
const { align } = attributes;
const [ resizeObserver, sizes ] = useResizeObserver();
const [ maxWidth, setMaxWidth ] = useState( 0 );
const shouldRenderFooterAppender = isSelected || isInnerButtonSelected;
Expand Down Expand Up @@ -69,7 +67,6 @@ function ButtonsEdit( {
shouldRenderFooterAppender && renderFooterAppender.current
}
__experimentalMoverDirection="horizontal"
horizontalAlignment={ align }
onDeleteBlock={ shouldDelete ? onDelete : undefined }
onAddBlock={ onAddNextButton }
parentWidth={ maxWidth }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/buttons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { button as icon } from '@wordpress/icons';
/**
* Internal dependencies
*/
import deprecated from './deprecated';
import transforms from './transforms';
import edit from './edit';
import metadata from './block.json';
Expand All @@ -23,6 +24,7 @@ export const settings = {
),
icon,
keywords: [ __( 'link' ) ],
deprecated,
transforms,
edit,
save,
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/fixtures/blocks/core__buttons.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- wp:buttons -->
<div class="wp-block-buttons">
<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">My button 1</a></div>
<div class="wp-block-button"><a class="wp-block-button__link">first</a></div>
<!-- /wp:button -->

<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">My button 2</a></div>
<div class="wp-block-button"><a class="wp-block-button__link">second</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
8 changes: 4 additions & 4 deletions packages/e2e-tests/fixtures/blocks/core__buttons.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"name": "core/button",
"isValid": true,
"attributes": {
"text": "My button 1"
"text": "first"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 1</a></div>"
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">first</a></div>"
},
{
"clientId": "_clientId_1",
"name": "core/button",
"isValid": true,
"attributes": {
"text": "My button 2"
"text": "second"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 2</a></div>"
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">second</a></div>"
}
],
"originalContent": "<div class=\"wp-block-buttons\">\n\t\n\n\t\n</div>"
Expand Down
8 changes: 4 additions & 4 deletions packages/e2e-tests/fixtures/blocks/core__buttons.parsed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
"blockName": "core/button",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 1</a></div>\n\t",
"innerHTML": "\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">first</a></div>\n\t",
"innerContent": [
"\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 1</a></div>\n\t"
"\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">first</a></div>\n\t"
]
},
{
"blockName": "core/button",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 2</a></div>\n\t",
"innerHTML": "\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">second</a></div>\n\t",
"innerContent": [
"\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 2</a></div>\n\t"
"\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">second</a></div>\n\t"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">My button 1</a></div>
<div class="wp-block-button"><a class="wp-block-button__link">first</a></div>
<!-- /wp:button -->

<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">My button 2</a></div>
<div class="wp-block-button"><a class="wp-block-button__link">second</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->
11 changes: 11 additions & 0 deletions packages/e2e-tests/fixtures/blocks/core__buttons__deprecated.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- wp:buttons {"align":"center"} -->
<div class="wp-block-buttons aligncenter">
<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">first</a></div>
<!-- /wp:button -->

<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">second</a></div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
33 changes: 33 additions & 0 deletions packages/e2e-tests/fixtures/blocks/core__buttons__deprecated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"clientId": "_clientId_0",
"name": "core/buttons",
"isValid": true,
"attributes": {
"className": "aligncenter"
},
"innerBlocks": [
{
"clientId": "_clientId_0",
"name": "core/button",
"isValid": true,
"attributes": {
"text": "first"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">first</a></div>"
},
{
"clientId": "_clientId_1",
"name": "core/button",
"isValid": true,
"attributes": {
"text": "second"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">second</a></div>"
}
],
"originalContent": "<div class=\"wp-block-buttons aligncenter\">\n\t\n\n\t\n</div>"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"blockName": "core/buttons",
"attrs": {
"align": "center"
},
"innerBlocks": [
{
"blockName": "core/button",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">first</a></div>\n\t",
"innerContent": [
"\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">first</a></div>\n\t"
]
},
{
"blockName": "core/button",
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">second</a></div>\n\t",
"innerContent": [
"\n\t<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">second</a></div>\n\t"
]
}
],
"innerHTML": "\n<div class=\"wp-block-buttons aligncenter\">\n\t\n\n\t\n</div>\n",
"innerContent": [
"\n<div class=\"wp-block-buttons aligncenter\">\n\t",
null,
"\n\n\t",
null,
"\n</div>\n"
]
},
{
"blockName": null,
"attrs": {},
"innerBlocks": [],
"innerHTML": "\n",
"innerContent": [
"\n"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- wp:buttons {"className":"aligncenter"} -->
<div class="wp-block-buttons aligncenter"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">first</a></div>
<!-- /wp:button -->

<!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link">second</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`adding blocks should insert a block pattern 1`] = `
"<!-- wp:buttons {\\"align\\":\\"center\\"} -->
<div class=\\"wp-block-buttons aligncenter\\"><!-- wp:button {\\"borderRadius\\":0,\\"backgroundColor\\":\\"very-dark-gray\\"} -->
"<!-- wp:buttons -->
<div class=\\"wp-block-buttons\\"><!-- wp:button {\\"borderRadius\\":0,\\"backgroundColor\\":\\"very-dark-gray\\"} -->
<div class=\\"wp-block-button\\"><a class=\\"wp-block-button__link has-very-dark-gray-background-color has-background no-border-radius\\">Button One</a></div>
<!-- /wp:button -->
Expand Down

0 comments on commit 5174a52

Please sign in to comment.