Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Rename to MainDashboardButton
  • Loading branch information
vindl committed May 4, 2020
commit 566c91a563d15bac8e23f16ae66b17478c83d733
34 changes: 0 additions & 34 deletions packages/edit-site/src/components/header/close-area/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/edit-site/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { PinnedItems } from '@wordpress/interface';
* Internal dependencies
*/
import { useEditorContext } from '../editor';
import __experimentalSiteEditorCloseArea from './close-area';
import MainDashboardButton from './main-dashboard-button';
import MoreMenu from './more-menu';
import TemplateSwitcher from '../template-switcher';
import SaveButton from '../save-button';
Expand Down Expand Up @@ -62,7 +62,7 @@ export default function Header( { openEntitiesSavedStates } ) {

return (
<div className="edit-site-header">
<__experimentalSiteEditorCloseArea.Slot />
<MainDashboardButton.Slot />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #22027

We're moving away from regular slots. Would you mind doing a small refactor here (bubblesVirtually slots don't support children render function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youknowriad Actually I'm not sure how to achieve the same effect with this, given that it relies on children render function to handle the default case when no fills are provided?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, refactored this in #22179.

<div className="edit-site-header__toolbar">
<Inserter
position="bottom right"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
import { createSlotFill } from '@wordpress/components';

/**
* Internal dependencies
*/
import FullscreenModeClose from '../fullscreen-mode-close';

const { Fill: MainDashboardButton, Slot } = createSlotFill(
'SiteEditorMainDashboardButton'
);

MainDashboardButton.Slot = () => (
<Slot>
{ ( fills ) => {
// Return default Close button if no fills are provided, otherwise replace it with available fills.
if ( isEmpty( fills ) ) {
return <FullscreenModeClose />;
}

return <> { fills } </>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These spaces are significant, and cause React to create two additional text node children.

https://codepen.io/aduth/pen/ZEbrOYY

Suggested change
return <> { fills } </>;
return <>{ fills }</>;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out! I removed this code in #22179.

} }
</Slot>
);

export default MainDashboardButton;
2 changes: 2 additions & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ export function initialize( id, settings ) {
}
render( <Editor settings={ settings } />, document.getElementById( id ) );
}

export { default as MainDashboardButton } from './components/header/main-dashboard-button';