diff --git a/lib/blocks.php b/lib/blocks.php index be49a0a2a7696..6e973dc820ab3 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -26,7 +26,7 @@ function gutenberg_reregister_core_block_types() { 'group', 'heading', 'html', - 'home', + 'home-link', 'image', 'list', 'media-text', @@ -60,7 +60,7 @@ function gutenberg_reregister_core_block_types() { 'loginout.php' => 'core/loginout', 'navigation.php' => 'core/navigation', 'navigation-link.php' => 'core/navigation-link', - 'home.php' => 'core/home', + 'home-link.php' => 'core/home-link', 'rss.php' => 'core/rss', 'search.php' => 'core/search', 'shortcode.php' => 'core/shortcode', diff --git a/packages/block-library/src/home/block.json b/packages/block-library/src/home-link/block.json similarity index 80% rename from packages/block-library/src/home/block.json rename to packages/block-library/src/home-link/block.json index 73ac8945a24a3..39d0e0f5539ee 100644 --- a/packages/block-library/src/home/block.json +++ b/packages/block-library/src/home-link/block.json @@ -1,6 +1,6 @@ { "apiVersion": 2, - "name": "core/home", + "name": "core/home-link", "category": "design", "parent": [ "core/navigation" ], "attributes": { @@ -26,6 +26,6 @@ "reusable": false, "html": false }, - "editorStyle": "wp-block-home-editor", - "style": "wp-block-home" + "editorStyle": "wp-block-home-link-editor", + "style": "wp-block-home-link" } diff --git a/packages/block-library/src/home/edit.js b/packages/block-library/src/home-link/edit.js similarity index 81% rename from packages/block-library/src/home/edit.js rename to packages/block-library/src/home-link/edit.js index 1572a16a55481..71f5fca8645f4 100644 --- a/packages/block-library/src/home/edit.js +++ b/packages/block-library/src/home-link/edit.js @@ -5,6 +5,7 @@ import { RichText, useBlockProps } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; +import { useEffect } from '@wordpress/element'; const preventDefault = ( event ) => event.preventDefault(); @@ -24,16 +25,22 @@ export default function HomeEdit( { attributes, setAttributes, clientId } ) { const { label } = attributes; + useEffect( () => { + if ( label === undefined ) { + setAttributes( { label: __( 'Home' ) } ); + } + }, [ clientId, label ] ); + return (
  • { setAttributes( { label: labelValue } ); diff --git a/packages/block-library/src/home/index.js b/packages/block-library/src/home-link/index.js similarity index 91% rename from packages/block-library/src/home/index.js rename to packages/block-library/src/home-link/index.js index 4349462e71f5f..026fc3269c1dc 100644 --- a/packages/block-library/src/home/index.js +++ b/packages/block-library/src/home-link/index.js @@ -30,7 +30,7 @@ export const settings = { example: { attributes: { - label: _x( 'Home', 'Home preview example' ), + label: _x( 'Home', 'Home Link preview example' ), }, }, }; diff --git a/packages/block-library/src/home/index.php b/packages/block-library/src/home-link/index.php similarity index 95% rename from packages/block-library/src/home/index.php rename to packages/block-library/src/home-link/index.php index 34bd64a55b8f9..0d93604975873 100644 --- a/packages/block-library/src/home/index.php +++ b/packages/block-library/src/home-link/index.php @@ -1,7 +1,7 @@ 'render_block_core_home', ) diff --git a/packages/block-library/src/home/save.js b/packages/block-library/src/home-link/save.js similarity index 100% rename from packages/block-library/src/home/save.js rename to packages/block-library/src/home-link/save.js diff --git a/packages/block-library/src/home-link/style.scss b/packages/block-library/src/home-link/style.scss new file mode 100644 index 0000000000000..22d530bce3abd --- /dev/null +++ b/packages/block-library/src/home-link/style.scss @@ -0,0 +1,29 @@ +.wp-block-navigation { + // Force links to inherit text decoration applied to navigation block. + // The extra selector adds specificity to ensure it works when user-set. + &[style*="text-decoration"] { + .wp-block-home-link { + text-decoration: inherit; + } + + .wp-block-home-link__content { + text-decoration: inherit; + + &:focus, + &:active { + text-decoration: inherit; + } + } + } + + &:not([style*="text-decoration"]) { + .wp-block-home-link__content { + text-decoration: none; + + &:focus, + &:active { + text-decoration: none; + } + } + } +} diff --git a/packages/block-library/src/home/style.scss b/packages/block-library/src/home/style.scss deleted file mode 100644 index 9bff7c1d58082..0000000000000 --- a/packages/block-library/src/home/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -.wp-block-home .wp-block-home__content { - text-decoration: inherit; -} diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index e40a9be2fa4cd..a5cfd8889c6d8 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -36,7 +36,7 @@ import * as html from './html'; import * as mediaText from './media-text'; import * as navigation from './navigation'; import * as navigationLink from './navigation-link'; -import * as home from './home'; +import * as homeLink from './home-link'; import * as latestComments from './latest-comments'; import * as latestPosts from './latest-posts'; import * as legacyWidget from './legacy-widget'; @@ -216,7 +216,7 @@ export const __experimentalRegisterExperimentalCoreBlocks = [ navigation, navigationLink, - home, + homeLink, // Register Legacy Widget block. ...( enableLegacyWidgetBlock ? [ legacyWidget ] : [] ), diff --git a/packages/block-library/src/navigation/edit.js b/packages/block-library/src/navigation/edit.js index f66015225de6c..b086931cb8bec 100644 --- a/packages/block-library/src/navigation/edit.js +++ b/packages/block-library/src/navigation/edit.js @@ -35,7 +35,7 @@ const ALLOWED_BLOCKS = [ 'core/social-links', 'core/page-list', 'core/spacer', - 'core/home', + 'core/home-link', ]; const LAYOUT = {