diff --git a/docs/designers-developers/developers/slotfills/main-dashboard-button.md b/docs/designers-developers/developers/slotfills/main-dashboard-button.md index 43b3730a35bcf4..3392eed131218f 100644 --- a/docs/designers-developers/developers/slotfills/main-dashboard-button.md +++ b/docs/designers-developers/developers/slotfills/main-dashboard-button.md @@ -1,18 +1,19 @@ # MainDashboardButton -This slot allows replacing the default main dashboard button in the post editor -that's used for closing the editor in fullscreen mode. In the site editor this slot -refers to the "back to dashboard" button in the navigation sidebar. +This slot allows replacing the default main dashboard button in the post editor and site editor. +It's used for returning back to main wp-admin dashboard when editor is in fullscreen mode. ## Examples -Basic usage: +### Post editor example + +This will override the W icon button in the header. ```js import { registerPlugin } from '@wordpress/plugins'; import { __experimentalMainDashboardButton as MainDashboardButton, -} from '@wordpress/interface'; +} from '@wordpress/edit-post'; const MainDashboardButtonTest = () => ( @@ -32,16 +33,14 @@ the post editor, that can be achieved in the following way: import { registerPlugin } from '@wordpress/plugins'; import { __experimentalFullscreenModeClose as FullscreenModeClose, -} from '@wordpress/edit-post'; -import { __experimentalMainDashboardButton as MainDashboardButton, -} from '@wordpress/interface'; +} from '@wordpress/edit-post'; import { close } from '@wordpress/icons'; const MainDashboardButtonIconTest = () => ( - + ); @@ -50,13 +49,15 @@ registerPlugin( 'main-dashboard-button-icon-test', { } ); ``` -Site editor example: +### Site editor example + +In the site editor this slot refers to the "back to dashboard" button in the navigation sidebar. ```js import { registerPlugin } from '@wordpress/plugins'; import { __experimentalMainDashboardButton as MainDashboardButton, -} from '@wordpress/interface'; +} from '@wordpress/edit-site'; import { __experimentalNavigationBackButton as NavigationBackButton, } from '@wordpress/components'; diff --git a/packages/edit-post/src/components/header/fullscreen-mode-close/index.js b/packages/edit-post/src/components/header/fullscreen-mode-close/index.js index d7da08c758470f..93d7f680487930 100644 --- a/packages/edit-post/src/components/header/fullscreen-mode-close/index.js +++ b/packages/edit-post/src/components/header/fullscreen-mode-close/index.js @@ -12,7 +12,7 @@ import { __ } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; import { wordpress } from '@wordpress/icons'; -function FullscreenModeClose( { showTooltip } ) { +function FullscreenModeClose( { showTooltip, icon, href } ) { const { isActive, isRequestingSiteIcon, postType, siteIconUrl } = useSelect( ( select ) => { const { getCurrentPostType } = select( 'core/editor' ); @@ -50,16 +50,26 @@ function FullscreenModeClose( { showTooltip } ) { src={ siteIconUrl } /> ); - } else if ( isRequestingSiteIcon ) { + } + + if ( isRequestingSiteIcon ) { buttonIcon = null; } + // Override default icon if custom icon is provided via props. + if ( icon ) { + buttonIcon = ; + } + return (