From 285cd07e50e0dccadb00bb23bbd5e75efc6d5f1f Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 12 Apr 2019 01:39:24 +0800 Subject: [PATCH] Rename section block to group (#14920) * Rename section block to group * Update transforms test for rename of section block to group * Alphabeticalize --- assets/stylesheets/_variables.scss | 4 +-- packages/block-library/src/editor.scss | 2 +- .../src/{section => group}/block.json | 2 +- .../src/{section => group}/edit.js | 4 +-- .../src/{section => group}/editor.scss | 28 +++++++++---------- .../src/{section => group}/index.js | 6 ++-- .../src/{section => group}/theme.scss | 3 +- packages/block-library/src/index.js | 4 +-- packages/block-library/src/theme.scss | 2 +- .../e2e-tests/fixtures/block-transforms.js | 8 +++--- .../fixtures/blocks/core__group.html | 10 +++++++ .../{core__section.json => core__group.json} | 12 ++++---- ...on.parsed.json => core__group.parsed.json} | 14 +++++----- .../blocks/core__group.serialized.html | 9 ++++++ .../fixtures/blocks/core__section.html | 10 ------- .../blocks/core__section.serialized.html | 9 ------ .../blocks/__snapshots__/group.test.js.snap | 17 +++++++++++ .../blocks/__snapshots__/section.test.js.snap | 17 ----------- .../blocks/{section.test.js => group.test.js} | 12 ++++---- 19 files changed, 86 insertions(+), 87 deletions(-) rename packages/block-library/src/{section => group}/block.json (85%) rename packages/block-library/src/{section => group}/edit.js (86%) rename packages/block-library/src/{section => group}/editor.scss (61%) rename packages/block-library/src/{section => group}/index.js (88%) rename packages/block-library/src/{section => group}/theme.scss (88%) create mode 100644 packages/e2e-tests/fixtures/blocks/core__group.html rename packages/e2e-tests/fixtures/blocks/{core__section.json => core__group.json} (64%) rename packages/e2e-tests/fixtures/blocks/{core__section.parsed.json => core__group.parsed.json} (60%) create mode 100644 packages/e2e-tests/fixtures/blocks/core__group.serialized.html delete mode 100644 packages/e2e-tests/fixtures/blocks/core__section.html delete mode 100644 packages/e2e-tests/fixtures/blocks/core__section.serialized.html create mode 100644 packages/e2e-tests/specs/blocks/__snapshots__/group.test.js.snap delete mode 100644 packages/e2e-tests/specs/blocks/__snapshots__/section.test.js.snap rename packages/e2e-tests/specs/blocks/{section.test.js => group.test.js} (67%) diff --git a/assets/stylesheets/_variables.scss b/assets/stylesheets/_variables.scss index f10eeb6152776..6e9a40c31034e 100644 --- a/assets/stylesheets/_variables.scss +++ b/assets/stylesheets/_variables.scss @@ -58,8 +58,8 @@ $block-spacing: 4px; // Vertical space between blocks. $block-side-ui-width: 28px; // Width of the movers/drag handle UI. $block-side-ui-clearance: 2px; // Space between movers/drag handle UI, and block. $block-container-side-padding: $block-side-ui-width + $block-padding + 2 * $block-side-ui-clearance; // Total space left and right of the block footprint. -$block-bg-padding--v: $block-padding + $block-spacing + $block-side-ui-clearance; // padding for Blocks with a background color (eg: paragraph or section) -$block-bg-padding--h: $block-side-ui-width + $block-side-ui-clearance; // padding for Blocks with a background color (eg: paragraph or section) +$block-bg-padding--v: $block-padding + $block-spacing + $block-side-ui-clearance; // padding for Blocks with a background color (eg: paragraph or group) +$block-bg-padding--h: $block-side-ui-width + $block-side-ui-clearance; // padding for Blocks with a background color (eg: paragraph or group) // Buttons & UI Widgets $radius-round-rectangle: 4px; diff --git a/packages/block-library/src/editor.scss b/packages/block-library/src/editor.scss index bc8bbd83911ad..cbdcda4e203ac 100644 --- a/packages/block-library/src/editor.scss +++ b/packages/block-library/src/editor.scss @@ -9,6 +9,7 @@ @import "./file/editor.scss"; @import "./classic/editor.scss"; @import "./gallery/editor.scss"; +@import "./group/editor.scss"; @import "./heading/editor.scss"; @import "./html/editor.scss"; @import "./image/editor.scss"; @@ -25,7 +26,6 @@ @import "./quote/editor.scss"; @import "./rss/editor.scss"; @import "./search/editor.scss"; -@import "./section/editor.scss"; @import "./shortcode/editor.scss"; @import "./spacer/editor.scss"; @import "./subhead/editor.scss"; diff --git a/packages/block-library/src/section/block.json b/packages/block-library/src/group/block.json similarity index 85% rename from packages/block-library/src/section/block.json rename to packages/block-library/src/group/block.json index dfd7ef8320cbd..d8b417099f8fd 100644 --- a/packages/block-library/src/section/block.json +++ b/packages/block-library/src/group/block.json @@ -1,5 +1,5 @@ { - "name": "core/section", + "name": "core/group", "category": "layout", "attributes": { "backgroundColor": { diff --git a/packages/block-library/src/section/edit.js b/packages/block-library/src/group/edit.js similarity index 86% rename from packages/block-library/src/section/edit.js rename to packages/block-library/src/group/edit.js index fcf17c40c48bc..b97ddbad17b8a 100644 --- a/packages/block-library/src/section/edit.js +++ b/packages/block-library/src/group/edit.js @@ -15,7 +15,7 @@ import { withColors, } from '@wordpress/block-editor'; -function SectionEdit( { className, setBackgroundColor, backgroundColor } ) { +function GroupEdit( { className, setBackgroundColor, backgroundColor } ) { const styles = { backgroundColor: backgroundColor.color, }; @@ -45,4 +45,4 @@ function SectionEdit( { className, setBackgroundColor, backgroundColor } ) { ); } -export default withColors( 'backgroundColor' )( SectionEdit ); +export default withColors( 'backgroundColor' )( GroupEdit ); diff --git a/packages/block-library/src/section/editor.scss b/packages/block-library/src/group/editor.scss similarity index 61% rename from packages/block-library/src/section/editor.scss rename to packages/block-library/src/group/editor.scss index f8cb11319ca0b..d3b83213bff0a 100644 --- a/packages/block-library/src/section/editor.scss +++ b/packages/block-library/src/group/editor.scss @@ -1,7 +1,7 @@ /** - * Section: All Alignment Settings + * Group: All Alignment Settings */ -.wp-block[data-type="core/section"] { +.wp-block[data-type="core/group"] { // Ensure not rendering outside the element // as -1px causes overflow-x scrollbars @@ -11,14 +11,14 @@ } // Only applied when background is added to cancel out padding - > .editor-block-list__block-edit > div > .wp-block-section.has-background > .editor-inner-blocks { + > .editor-block-list__block-edit > div > .wp-block-group.has-background > .editor-inner-blocks { margin-top: -#{$block-padding*2 + $block-spacing}; margin-bottom: -#{$block-padding*2 + $block-spacing}; } // Full Width Blocks - // specificity required to only target immediate child Blocks of Section - > .editor-block-list__block-edit > div > .wp-block-section > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { + // specificity required to only target immediate child Blocks of a Group + > .editor-block-list__block-edit > div > .wp-block-group > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { margin-left: auto; margin-right: auto; padding-left: $block-padding*2; @@ -31,7 +31,7 @@ } // Full Width Blocks with a background (ie: has padding) - > .editor-block-list__block-edit > div > .wp-block-section.has-background > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { + > .editor-block-list__block-edit > div > .wp-block-group.has-background > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { // note: using position `left` causes hoz scrollbars so // we opt to use margin instead // the 30px matches the hoz padding applied in `theme.scss` @@ -40,18 +40,18 @@ // 60px here is x2 the hoz padding from `theme.scss` added when // the Block has a background set - // note: also duplicated below for full width Sections + // note: also duplicated below for full width Groups width: calc(100% + 60px); } } /** - * Section: Full Width Alignment + * Group: Full Width Alignment */ -.wp-block[data-type="core/section"][data-align="full"] { +.wp-block[data-type="core/group"][data-align="full"] { // First tier of InnerBlocks must act like the container of the standard canvas - > .editor-block-list__block-edit > div > .wp-block-section > .editor-inner-blocks { + > .editor-block-list__block-edit > div > .wp-block-group > .editor-inner-blocks { margin-left: auto; margin-right: auto; padding-left: 0; @@ -64,8 +64,8 @@ } // Full Width Blocks - // specificity required to only target immediate child Blocks of Section - > .editor-block-list__block-edit > div > .wp-block-section > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { + // specificity required to only target immediate child Blocks of Group + > .editor-block-list__block-edit > div > .wp-block-group > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { padding-right: 0; padding-left: 0; left: 0; @@ -80,8 +80,8 @@ } // Full Width Blocks with a background (ie: has padding) - // note: also duplicated above for all Section widths - > .editor-block-list__block-edit > div > .wp-block-section.has-background > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { + // note: also duplicated above for all Group widths + > .editor-block-list__block-edit > div > .wp-block-group.has-background > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] { width: calc(100% + 60px); } } diff --git a/packages/block-library/src/section/index.js b/packages/block-library/src/group/index.js similarity index 88% rename from packages/block-library/src/section/index.js rename to packages/block-library/src/group/index.js index cc2511a0bda3a..13c02c9c955c7 100644 --- a/packages/block-library/src/section/index.js +++ b/packages/block-library/src/group/index.js @@ -21,13 +21,13 @@ const { name } = metadata; export { metadata, name }; export const settings = { - title: __( 'Section' ), + title: __( 'Group' ), icon: , - description: __( 'A wrapping section acting as a container for other blocks.' ), + description: __( 'A block that groups other blocks.' ), - keywords: [ __( 'container' ), __( 'wrapper' ), __( 'row' ) ], + keywords: [ __( 'container' ), __( 'wrapper' ), __( 'row' ), __( 'section' ) ], supports: { align: [ 'wide', 'full' ], diff --git a/packages/block-library/src/section/theme.scss b/packages/block-library/src/group/theme.scss similarity index 88% rename from packages/block-library/src/section/theme.scss rename to packages/block-library/src/group/theme.scss index fc3a7edd3bbcd..61e711c3aaa2f 100644 --- a/packages/block-library/src/section/theme.scss +++ b/packages/block-library/src/group/theme.scss @@ -1,5 +1,4 @@ -.wp-block-section { - +.wp-block-group { &.has-background { // Matches paragraph Block padding // Todo: normalise with variables diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index da1ab153a4e5f..38e6b27230962 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -45,7 +45,7 @@ import * as pullquote from './pullquote'; import * as reusableBlock from './block'; import * as rss from './rss'; import * as search from './search'; -import * as section from './section'; +import * as group from './group'; import * as separator from './separator'; import * as shortcode from './shortcode'; import * as spacer from './spacer'; @@ -95,6 +95,7 @@ export const registerCoreBlocks = () => { ...embed.common, ...embed.others, file, + group, window.wp && window.wp.oldEditor ? classic : null, // Only add the classic block in WP Context html, mediaText, @@ -108,7 +109,6 @@ export const registerCoreBlocks = () => { pullquote, rss, search, - section, separator, reusableBlock, spacer, diff --git a/packages/block-library/src/theme.scss b/packages/block-library/src/theme.scss index 501240a4a9bbd..691a7c53e9b4b 100644 --- a/packages/block-library/src/theme.scss +++ b/packages/block-library/src/theme.scss @@ -6,7 +6,7 @@ @import "./pullquote/theme.scss"; @import "./quote/theme.scss"; @import "./search/theme.scss"; -@import "./section/theme.scss"; +@import "./group/theme.scss"; @import "./separator/theme.scss"; @import "./table/theme.scss"; @import "./video/theme.scss"; diff --git a/packages/e2e-tests/fixtures/block-transforms.js b/packages/e2e-tests/fixtures/block-transforms.js index b1b8949b851ae..79d4d7bc80456 100644 --- a/packages/e2e-tests/fixtures/block-transforms.js +++ b/packages/e2e-tests/fixtures/block-transforms.js @@ -129,6 +129,10 @@ export const EXPECTED_TRANSFORMS = { 'Image', ], }, + core__group: { + originalBlock: 'Group', + availableTransforms: [], + }, 'core__heading__h2-em': { originalBlock: 'Heading', availableTransforms: [ @@ -303,10 +307,6 @@ export const EXPECTED_TRANSFORMS = { originalBlock: 'Search', availableTransforms: [], }, - core__section: { - originalBlock: 'Section', - availableTransforms: [], - }, core__separator: { originalBlock: 'Separator', availableTransforms: [], diff --git a/packages/e2e-tests/fixtures/blocks/core__group.html b/packages/e2e-tests/fixtures/blocks/core__group.html new file mode 100644 index 0000000000000..2c8055434700d --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__group.html @@ -0,0 +1,10 @@ + +
+ +

This is a group block.

+ + + +

Group block content.

+
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__section.json b/packages/e2e-tests/fixtures/blocks/core__group.json similarity index 64% rename from packages/e2e-tests/fixtures/blocks/core__section.json rename to packages/e2e-tests/fixtures/blocks/core__group.json index 7f27655f472cd..ec8f4ca9ad64d 100644 --- a/packages/e2e-tests/fixtures/blocks/core__section.json +++ b/packages/e2e-tests/fixtures/blocks/core__group.json @@ -1,7 +1,7 @@ [ { "clientId": "_clientId_0", - "name": "core/section", + "name": "core/group", "isValid": true, "attributes": { "backgroundColor": "secondary", @@ -13,24 +13,24 @@ "name": "core/paragraph", "isValid": true, "attributes": { - "content": "This is a section block.", + "content": "This is a group block.", "dropCap": false }, "innerBlocks": [], - "originalContent": "

This is a section block.

" + "originalContent": "

This is a group block.

" }, { "clientId": "_clientId_1", "name": "core/paragraph", "isValid": true, "attributes": { - "content": "Section block content.", + "content": "Group block content.", "dropCap": false }, "innerBlocks": [], - "originalContent": "

Section block content.

" + "originalContent": "

Group block content.

" } ], - "originalContent": "
\n\t\n\n\t
" + "originalContent": "
\n\t\n\n\t
" } ] diff --git a/packages/e2e-tests/fixtures/blocks/core__section.parsed.json b/packages/e2e-tests/fixtures/blocks/core__group.parsed.json similarity index 60% rename from packages/e2e-tests/fixtures/blocks/core__section.parsed.json rename to packages/e2e-tests/fixtures/blocks/core__group.parsed.json index 7cdcbf0c9c6ec..06718c82d85f1 100644 --- a/packages/e2e-tests/fixtures/blocks/core__section.parsed.json +++ b/packages/e2e-tests/fixtures/blocks/core__group.parsed.json @@ -1,6 +1,6 @@ [ { - "blockName": "core/section", + "blockName": "core/group", "attrs": { "backgroundColor": "secondary", "align": "full" @@ -10,24 +10,24 @@ "blockName": "core/paragraph", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\t

This is a section block.

\n\t", + "innerHTML": "\n\t

This is a group block.

\n\t", "innerContent": [ - "\n\t

This is a section block.

\n\t" + "\n\t

This is a group block.

\n\t" ] }, { "blockName": "core/paragraph", "attrs": {}, "innerBlocks": [], - "innerHTML": "\n\t

Section block content.

\n\t", + "innerHTML": "\n\t

Group block content.

\n\t", "innerContent": [ - "\n\t

Section block content.

\n\t" + "\n\t

Group block content.

\n\t" ] } ], - "innerHTML": "\n
\n\t\n\n\t
\n", + "innerHTML": "\n
\n\t\n\n\t
\n", "innerContent": [ - "\n
\n\t", + "\n
\n\t", null, "\n\n\t", null, diff --git a/packages/e2e-tests/fixtures/blocks/core__group.serialized.html b/packages/e2e-tests/fixtures/blocks/core__group.serialized.html new file mode 100644 index 0000000000000..bcc69c0e89009 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__group.serialized.html @@ -0,0 +1,9 @@ + +
+

This is a group block.

+ + + +

Group block content.

+
+ diff --git a/packages/e2e-tests/fixtures/blocks/core__section.html b/packages/e2e-tests/fixtures/blocks/core__section.html deleted file mode 100644 index cf21a46b87991..0000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__section.html +++ /dev/null @@ -1,10 +0,0 @@ - -
- -

This is a section block.

- - - -

Section block content.

-
- diff --git a/packages/e2e-tests/fixtures/blocks/core__section.serialized.html b/packages/e2e-tests/fixtures/blocks/core__section.serialized.html deleted file mode 100644 index 79f0c5eb54cc1..0000000000000 --- a/packages/e2e-tests/fixtures/blocks/core__section.serialized.html +++ /dev/null @@ -1,9 +0,0 @@ - -
-

This is a section block.

- - - -

Section block content.

-
- diff --git a/packages/e2e-tests/specs/blocks/__snapshots__/group.test.js.snap b/packages/e2e-tests/specs/blocks/__snapshots__/group.test.js.snap new file mode 100644 index 0000000000000..4de439b09327f --- /dev/null +++ b/packages/e2e-tests/specs/blocks/__snapshots__/group.test.js.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Group can be created using the block inserter 1`] = ` +" +
+

Group block

+
+" +`; + +exports[`Group can be created using the slash inserter 1`] = ` +" +
+

Group block

+
+" +`; diff --git a/packages/e2e-tests/specs/blocks/__snapshots__/section.test.js.snap b/packages/e2e-tests/specs/blocks/__snapshots__/section.test.js.snap deleted file mode 100644 index 1e36e894ba469..0000000000000 --- a/packages/e2e-tests/specs/blocks/__snapshots__/section.test.js.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Section can be created using the block inserter 1`] = ` -" -
-

Section block

-
-" -`; - -exports[`Section can be created using the slash inserter 1`] = ` -" -
-

Section block

-
-" -`; diff --git a/packages/e2e-tests/specs/blocks/section.test.js b/packages/e2e-tests/specs/blocks/group.test.js similarity index 67% rename from packages/e2e-tests/specs/blocks/section.test.js rename to packages/e2e-tests/specs/blocks/group.test.js index 90ae574d0fcbe..cb04ffdc64cd7 100644 --- a/packages/e2e-tests/specs/blocks/section.test.js +++ b/packages/e2e-tests/specs/blocks/group.test.js @@ -8,24 +8,24 @@ import { createNewPost, } from '@wordpress/e2e-test-utils'; -describe( 'Section', () => { +describe( 'Group', () => { beforeEach( async () => { await createNewPost(); } ); it( 'can be created using the block inserter', async () => { - await searchForBlock( 'Section' ); - await page.click( '.editor-block-list-item-section' ); - await page.keyboard.type( 'Section block' ); + await searchForBlock( 'Group' ); + await page.click( '.editor-block-list-item-group' ); + await page.keyboard.type( 'Group block' ); expect( await getEditedPostContent() ).toMatchSnapshot(); } ); it( 'can be created using the slash inserter', async () => { await clickBlockAppender(); - await page.keyboard.type( '/section' ); + await page.keyboard.type( '/group' ); await page.keyboard.press( 'Enter' ); - await page.keyboard.type( 'Section block' ); + await page.keyboard.type( 'Group block' ); expect( await getEditedPostContent() ).toMatchSnapshot(); } );