Skip to content

Commit

Permalink
Remove horizontal and vertical navigation block variations from inser…
Browse files Browse the repository at this point in the history
…ter (#34614)

* Remove horizontal/vertical nav block variations from inserter

* update fixtures

* Remove default variation

* Update fixtures

Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
talldan and ntsekouras authored Sep 8, 2021
1 parent f20ad34 commit 5d21c21
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion packages/block-library/src/navigation/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"textdomain": "default",
"attributes": {
"orientation": {
"type": "string"
"type": "string",
"default": "horizontal"
},
"textColor": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function Navigation( {
},
{
allowedBlocks: ALLOWED_BLOCKS,
orientation: attributes.orientation || 'horizontal',
orientation: attributes.orientation,
renderAppender:
( isImmediateParentOfSelectedBlock &&
! selectedBlockHasDescendants ) ||
Expand Down
5 changes: 2 additions & 3 deletions packages/block-library/src/navigation/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import { __ } from '@wordpress/i18n';
const variations = [
{
name: 'horizontal',
isDefault: true,
title: __( 'Navigation (horizontal)' ),
description: __( 'Links shown in a row.' ),
attributes: { orientation: 'horizontal' },
scope: [ 'inserter', 'transform' ],
scope: [ 'transform' ],
},
{
name: 'vertical',
title: __( 'Navigation (vertical)' ),
description: __( 'Links shown in a column.' ),
attributes: { orientation: 'vertical' },
scope: [ 'inserter', 'transform' ],
scope: [ 'transform' ],
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Navigation Creating from existing Menus allows a navigation block to be created from existing menus 1`] = `
"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
"<!-- wp:navigation -->
<!-- wp:navigation-link {\\"label\\":\\"Home\\",\\"type\\":\\"custom\\",\\"url\\":\\"http://localhost:8889/\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
<!-- wp:navigation-link {\\"label\\":\\"Accusamus quo repellat illum magnam quas\\",\\"type\\":\\"page\\",\\"id\\":41,\\"url\\":\\"http://localhost:8889/?page_id=41\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} -->
Expand Down Expand Up @@ -36,30 +36,30 @@ exports[`Navigation Creating from existing Menus allows a navigation block to be
<!-- /wp:navigation -->"
`;

exports[`Navigation Creating from existing Menus creates an empty navigation block when the selected existing menu is also empty 1`] = `"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} /-->"`;
exports[`Navigation Creating from existing Menus creates an empty navigation block when the selected existing menu is also empty 1`] = `"<!-- wp:navigation /-->"`;

exports[`Navigation Creating from existing Pages allows a navigation block to be created using existing pages 1`] = `
"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
"<!-- wp:navigation -->
<!-- wp:page-list {\\"isNavigationChild\\":true} /-->
<!-- /wp:navigation -->"
`;

exports[`Navigation allows an empty navigation block to be created and manually populated using a mixture of internal and external links 1`] = `
"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
"<!-- wp:navigation -->
<!-- wp:navigation-link {\\"label\\":\\"WP\\",\\"url\\":\\"https://wordpress.org\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
<!-- wp:navigation-link {\\"label\\":\\"Contact\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/search/get-in-touch\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
<!-- /wp:navigation -->"
`;

exports[`Navigation allows pages to be created from the navigation block and their links added to menu 1`] = `
"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
"<!-- wp:navigation -->
<!-- wp:navigation-link {\\"label\\":\\"A really long page name that will not exist\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/create/page/my-new-page\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
<!-- /wp:navigation -->"
`;

exports[`Navigation encodes URL when create block if needed 1`] = `
"<!-- wp:navigation {\\"orientation\\":\\"horizontal\\"} -->
"<!-- wp:navigation -->
<!-- wp:navigation-link {\\"label\\":\\"wordpress.org/шеллы\\",\\"url\\":\\"https://wordpress.org/%D1%88%D0%B5%D0%BB%D0%BB%D1%8B\\",\\"kind\\":\\"custom\\",\\"isTopLevelLink\\":true} /-->
<!-- wp:navigation-link {\\"label\\":\\"お問い合わせ\\",\\"type\\":\\"page\\",\\"id\\":1,\\"url\\":\\"https://this/is/a/test/search/%E3%81%8A%E5%95%8F%E3%81%84%E5%90%88%E3%82%8F%E3%81%9B\\",\\"kind\\":\\"post-type\\",\\"isTopLevelLink\\":true} /-->
Expand Down
1 change: 1 addition & 0 deletions test/integration/fixtures/blocks/core__navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"name": "core/navigation",
"isValid": true,
"attributes": {
"orientation": "horizontal",
"showSubmenuIcon": true,
"isResponsive": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- wp:navigation {"orientation":"horizontal","style":{"typography":{"textTransform":"lowercase","textDecoration":"line-through","fontStyle":"italic","fontWeight":"100"}}} -->
<!-- wp:navigation {"style":{"typography":{"textTransform":"lowercase","textDecoration":"line-through","fontStyle":"italic","fontWeight":"100"}}} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://www.wordpress.org/"} /-->
<!-- /wp:navigation -->

0 comments on commit 5d21c21

Please sign in to comment.