Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# MainDashboardButton

This slot allows replacing the default main dashboard button that's used for closing
the editor in fullscreen mode.
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.

## Example
## Examples

Basic usage:

```js
import { registerPlugin } from '@wordpress/plugins';
Expand All @@ -22,8 +25,8 @@ registerPlugin( 'main-dashboard-button-test', {
} );
```

If your goal is just to replace the icon of the existing button, that can be achieved
in the following way:
If your goal is just to replace the icon of the existing button in
the post editor, that can be achieved in the following way:

```js
import { registerPlugin } from '@wordpress/plugins';
Expand All @@ -46,3 +49,29 @@ registerPlugin( 'main-dashboard-button-icon-test', {
render: MainDashboardButtonIconTest,
} );
```

Site editor example:

```js
import { registerPlugin } from '@wordpress/plugins';
import {
__experimentalMainDashboardButton as MainDashboardButton,
} from '@wordpress/interface';
import {
__experimentalNavigationBackButton as NavigationBackButton,
} from '@wordpress/components';

const MainDashboardButtonIconTest = () => (
<MainDashboardButton>
<NavigationBackButton
backButtonLabel={ __( 'Back to dashboard' ) }
className="edit-site-navigation-panel__back-to-dashboard"
href="index.php"
/>
</MainDashboardButton>
);

registerPlugin( 'main-dashboard-button-icon-test', {
render: MainDashboardButtonIconTest,
} );
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
__experimentalNavigationItem as NavigationItem,
__experimentalNavigationBackButton as NavigationBackButton,
} from '@wordpress/components';
import { __experimentalMainDashboardButton as MainDashboardButton } from '@wordpress/interface';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -50,11 +51,13 @@ export default function TemplatesNavigation() {
onActivateMenu={ setNavigationPanelActiveMenu }
>
{ activeMenu === MENU_ROOT && (
<NavigationBackButton
backButtonLabel={ __( 'Dashboard' ) }
className="edit-site-navigation-panel__back-to-dashboard"
href="index.php"
/>
<MainDashboardButton.Slot>
<NavigationBackButton
backButtonLabel={ __( 'Dashboard' ) }
className="edit-site-navigation-panel__back-to-dashboard"
href="index.php"
/>
</MainDashboardButton.Slot>
) }

<NavigationMenu title={ __( 'Theme' ) }>
Expand Down