diff --git a/packages/edit-site/src/new/index.js b/packages/edit-site/src/components/app/index.js
similarity index 89%
rename from packages/edit-site/src/new/index.js
rename to packages/edit-site/src/components/app/index.js
index e19e74c171003..2a87de5fc8154 100644
--- a/packages/edit-site/src/new/index.js
+++ b/packages/edit-site/src/components/app/index.js
@@ -8,8 +8,8 @@ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
/**
* Internal dependencies
*/
-import { Routes } from '../components/routes';
-import Layout from './layout';
+import { Routes } from '../routes';
+import Layout from '../layout';
export default function App() {
return (
diff --git a/packages/edit-site/src/components/block-editor/block-inspector-button.js b/packages/edit-site/src/components/block-editor/block-inspector-button.js
index 91b5f0665f757..758ca50272ade 100644
--- a/packages/edit-site/src/components/block-editor/block-inspector-button.js
+++ b/packages/edit-site/src/components/block-editor/block-inspector-button.js
@@ -13,7 +13,7 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
*/
import { store as editSiteStore } from '../../store';
import { STORE_NAME } from '../../store/constants';
-import { SIDEBAR_BLOCK } from '../sidebar/constants';
+import { SIDEBAR_BLOCK } from '../sidebar-edit-mode/constants';
export default function BlockInspectorButton( { onClick = () => {} } ) {
const { shortcut, isBlockInspectorOpen } = useSelect(
diff --git a/packages/edit-site/src/components/block-editor/index.js b/packages/edit-site/src/components/block-editor/index.js
index 82c560bc7ee04..36c69acbf65ea 100644
--- a/packages/edit-site/src/components/block-editor/index.js
+++ b/packages/edit-site/src/components/block-editor/index.js
@@ -29,7 +29,7 @@ import { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';
*/
import TemplatePartConverter from '../template-part-converter';
import NavigateToLink from '../navigate-to-link';
-import { SidebarInspectorFill } from '../sidebar';
+import { SidebarInspectorFill } from '../sidebar-edit-mode';
import { store as editSiteStore } from '../../store';
import BlockInspectorButton from './block-inspector-button';
import BackButton from './back-button';
diff --git a/packages/edit-site/src/new/canvas/index.js b/packages/edit-site/src/components/canvas/index.js
similarity index 89%
rename from packages/edit-site/src/new/canvas/index.js
rename to packages/edit-site/src/components/canvas/index.js
index 846c539187bee..26f47251324fe 100644
--- a/packages/edit-site/src/new/canvas/index.js
+++ b/packages/edit-site/src/components/canvas/index.js
@@ -26,16 +26,16 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
*/
import { store as editSiteStore } from '../../store';
import Header from '../header';
-import BlockEditor from '../../components/block-editor';
-import CodeEditor from '../../components/code-editor';
-import KeyboardShortcuts from '../../components/keyboard-shortcuts';
-import useInitEditedEntityFromURL from '../../components/use-init-edited-entity-from-url';
-import GlobalStylesRenderer from '../../components/global-styles-renderer';
-import { GlobalStylesProvider } from '../../components/global-styles/global-styles-provider';
-import ListViewSidebar from '../../components/secondary-sidebar/list-view-sidebar';
-import InserterSidebar from '../../components/secondary-sidebar/inserter-sidebar';
-import { SidebarComplementaryAreaFills } from '../../components/sidebar';
-import WelcomeGuide from '../../components/welcome-guide';
+import BlockEditor from '../block-editor';
+import CodeEditor from '../code-editor';
+import KeyboardShortcuts from '../keyboard-shortcuts';
+import useInitEditedEntityFromURL from '../use-init-edited-entity-from-url';
+import GlobalStylesRenderer from '../global-styles-renderer';
+import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
+import ListViewSidebar from '../secondary-sidebar/list-view-sidebar';
+import InserterSidebar from '../secondary-sidebar/inserter-sidebar';
+import { SidebarComplementaryAreaFills } from '../sidebar-edit-mode';
+import WelcomeGuide from '../welcome-guide';
const interfaceLabels = {
/* translators: accessibility text for the editor top bar landmark region. */
diff --git a/packages/edit-site/src/new/canvas/style.scss b/packages/edit-site/src/components/canvas/style.scss
similarity index 100%
rename from packages/edit-site/src/new/canvas/style.scss
rename to packages/edit-site/src/components/canvas/style.scss
diff --git a/packages/edit-site/src/components/header/document-actions/index.js b/packages/edit-site/src/components/header-edit-mode/document-actions/index.js
similarity index 100%
rename from packages/edit-site/src/components/header/document-actions/index.js
rename to packages/edit-site/src/components/header-edit-mode/document-actions/index.js
diff --git a/packages/edit-site/src/components/header/document-actions/style.scss b/packages/edit-site/src/components/header-edit-mode/document-actions/style.scss
similarity index 100%
rename from packages/edit-site/src/components/header/document-actions/style.scss
rename to packages/edit-site/src/components/header-edit-mode/document-actions/style.scss
diff --git a/packages/edit-site/src/components/header-edit-mode/index.js b/packages/edit-site/src/components/header-edit-mode/index.js
new file mode 100644
index 0000000000000..1447ba76c3ac9
--- /dev/null
+++ b/packages/edit-site/src/components/header-edit-mode/index.js
@@ -0,0 +1,285 @@
+/**
+ * External dependencies
+ */
+import classnames from 'classnames';
+
+/**
+ * WordPress dependencies
+ */
+import { useCallback, useRef } from '@wordpress/element';
+import { useViewportMatch } from '@wordpress/compose';
+import {
+ ToolSelector,
+ __experimentalPreviewOptions as PreviewOptions,
+ NavigableToolbar,
+ store as blockEditorStore,
+} from '@wordpress/block-editor';
+import { useSelect, useDispatch } from '@wordpress/data';
+import { PinnedItems } from '@wordpress/interface';
+import { _x, __ } from '@wordpress/i18n';
+import { listView, plus, external, chevronUpDown } from '@wordpress/icons';
+import {
+ Button,
+ ToolbarItem,
+ MenuGroup,
+ MenuItem,
+ VisuallyHidden,
+} from '@wordpress/components';
+import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
+import { store as preferencesStore } from '@wordpress/preferences';
+import { store as editorStore } from '@wordpress/editor';
+import { store as coreStore } from '@wordpress/core-data';
+
+/**
+ * Internal dependencies
+ */
+import MoreMenu from './more-menu';
+import SaveButton from '../save-button';
+import UndoButton from './undo-redo/undo';
+import RedoButton from './undo-redo/redo';
+import DocumentActions from './document-actions';
+import TemplateDetails from '../template-details';
+import { store as editSiteStore } from '../../store';
+
+const preventDefault = ( event ) => {
+ event.preventDefault();
+};
+
+export default function Header() {
+ const inserterButton = useRef();
+ const {
+ deviceType,
+ entityTitle,
+ template,
+ templateType,
+ isInserterOpen,
+ isListViewOpen,
+ listViewShortcut,
+ isLoaded,
+ isVisualMode,
+ settings,
+ blockEditorMode,
+ showIconLabels,
+ } = useSelect( ( select ) => {
+ const {
+ __experimentalGetPreviewDeviceType,
+ getEditedPostType,
+ getEditedPostId,
+ isInserterOpened,
+ isListViewOpened,
+ getEditorMode,
+ getSettings,
+ } = select( editSiteStore );
+ const { getEditedEntityRecord } = select( coreStore );
+ const { __experimentalGetTemplateInfo: getTemplateInfo } =
+ select( editorStore );
+ const { getShortcutRepresentation } = select( keyboardShortcutsStore );
+ const { __unstableGetEditorMode } = select( blockEditorStore );
+
+ const postType = getEditedPostType();
+ const postId = getEditedPostId();
+ const record = getEditedEntityRecord( 'postType', postType, postId );
+ const _isLoaded = !! postId;
+
+ return {
+ deviceType: __experimentalGetPreviewDeviceType(),
+ entityTitle: getTemplateInfo( record ).title,
+ isLoaded: _isLoaded,
+ template: record,
+ templateType: postType,
+ isInserterOpen: isInserterOpened(),
+ isListViewOpen: isListViewOpened(),
+ listViewShortcut: getShortcutRepresentation(
+ 'core/edit-site/toggle-list-view'
+ ),
+ isVisualMode: getEditorMode() === 'visual',
+ settings: getSettings(),
+ blockEditorMode: __unstableGetEditorMode(),
+ showIconLabels: select( preferencesStore ).get(
+ 'core/edit-site',
+ 'showIconLabels'
+ ),
+ };
+ }, [] );
+
+ const {
+ __experimentalSetPreviewDeviceType: setPreviewDeviceType,
+ setIsInserterOpened,
+ setIsListViewOpened,
+ } = useDispatch( editSiteStore );
+ const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
+
+ const isLargeViewport = useViewportMatch( 'medium' );
+
+ const openInserter = useCallback( () => {
+ if ( isInserterOpen ) {
+ // Focusing the inserter button closes the inserter popover.
+ inserterButton.current.focus();
+ } else {
+ setIsInserterOpened( true );
+ }
+ }, [ isInserterOpen, setIsInserterOpened ] );
+
+ const toggleListView = useCallback(
+ () => setIsListViewOpened( ! isListViewOpen ),
+ [ setIsListViewOpened, isListViewOpen ]
+ );
+
+ const isFocusMode = templateType === 'wp_template_part';
+
+ /* translators: button label text should, if possible, be under 16 characters. */
+ const longLabel = _x(
+ 'Toggle block inserter',
+ 'Generic label for block inserter button'
+ );
+ const shortLabel = ! isInserterOpen ? __( 'Add' ) : __( 'Close' );
+
+ const isZoomedOutViewExperimentEnabled =
+ window?.__experimentalEnableZoomedOutView && isVisualMode;
+ const isZoomedOutView = blockEditorMode === 'zoom-out';
+
+ return (
+
+
+
+
+ { isLargeViewport && (
+ <>
+
+
+
+
+ { isZoomedOutViewExperimentEnabled && (
+ {
+ setPreviewDeviceType( 'desktop' );
+ __unstableSetEditorMode(
+ isZoomedOutView
+ ? 'edit'
+ : 'zoom-out'
+ );
+ } }
+ />
+ ) }
+ >
+ ) }
+
+
+
+
+
+ { ( { onClose } ) => (
+
+ ) }
+
+
+
+
+
+ { ! isFocusMode && (
+
+
+
+
+
+
+
+ ) }
+
+
+
+
+
+
+ );
+}
diff --git a/packages/edit-site/src/components/header/mode-switcher/index.js b/packages/edit-site/src/components/header-edit-mode/mode-switcher/index.js
similarity index 100%
rename from packages/edit-site/src/components/header/mode-switcher/index.js
rename to packages/edit-site/src/components/header-edit-mode/mode-switcher/index.js
diff --git a/packages/edit-site/src/components/header/more-menu/copy-content-menu-item.js b/packages/edit-site/src/components/header-edit-mode/more-menu/copy-content-menu-item.js
similarity index 100%
rename from packages/edit-site/src/components/header/more-menu/copy-content-menu-item.js
rename to packages/edit-site/src/components/header-edit-mode/more-menu/copy-content-menu-item.js
diff --git a/packages/edit-site/src/components/header/more-menu/index.js b/packages/edit-site/src/components/header-edit-mode/more-menu/index.js
similarity index 100%
rename from packages/edit-site/src/components/header/more-menu/index.js
rename to packages/edit-site/src/components/header-edit-mode/more-menu/index.js
diff --git a/packages/edit-site/src/components/header/more-menu/site-export.js b/packages/edit-site/src/components/header-edit-mode/more-menu/site-export.js
similarity index 100%
rename from packages/edit-site/src/components/header/more-menu/site-export.js
rename to packages/edit-site/src/components/header-edit-mode/more-menu/site-export.js
diff --git a/packages/edit-site/src/components/header/more-menu/welcome-guide-menu-item.js b/packages/edit-site/src/components/header-edit-mode/more-menu/welcome-guide-menu-item.js
similarity index 100%
rename from packages/edit-site/src/components/header/more-menu/welcome-guide-menu-item.js
rename to packages/edit-site/src/components/header-edit-mode/more-menu/welcome-guide-menu-item.js
diff --git a/packages/edit-site/src/components/header/plugin-more-menu-item/index.js b/packages/edit-site/src/components/header-edit-mode/plugin-more-menu-item/index.js
similarity index 100%
rename from packages/edit-site/src/components/header/plugin-more-menu-item/index.js
rename to packages/edit-site/src/components/header-edit-mode/plugin-more-menu-item/index.js
diff --git a/packages/edit-site/src/components/header/plugin-sidebar-more-menu-item/index.js b/packages/edit-site/src/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js
similarity index 100%
rename from packages/edit-site/src/components/header/plugin-sidebar-more-menu-item/index.js
rename to packages/edit-site/src/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js
diff --git a/packages/edit-site/src/components/header-edit-mode/style.scss b/packages/edit-site/src/components/header-edit-mode/style.scss
new file mode 100644
index 0000000000000..1753589adf4e7
--- /dev/null
+++ b/packages/edit-site/src/components/header-edit-mode/style.scss
@@ -0,0 +1,222 @@
+$header-toolbar-min-width: 335px;
+
+.edit-site-header-edit-mode {
+ align-items: center;
+ background-color: $white;
+ display: flex;
+ height: $header-height;
+ box-sizing: border-box;
+ width: 100%;
+ justify-content: space-between;
+
+ .edit-site-header-edit-mode__start {
+ display: flex;
+ border: none;
+ }
+
+ .edit-site-header-edit-mode__end {
+ display: flex;
+ justify-content: flex-end;
+ }
+
+ .edit-site-header-edit-mode__center {
+ display: flex;
+ align-items: center;
+ height: 100%;
+ flex-grow: 1;
+ justify-content: center;
+ // Flex items will, by default, refuse to shrink below a minimum
+ // intrinsic width. In order to shrink this flexbox item, and
+ // subsequently truncate child text, we set an explicit min-width.
+ // See https://dev.w3.org/csswg/css-flexbox/#min-size-auto
+ min-width: 0;
+ }
+}
+
+.edit-site-header-edit-mode__toolbar {
+ display: flex;
+ align-items: center;
+ padding-left: $grid-unit-10;
+
+ @include break-small() {
+ padding-left: $grid-unit-30;
+ }
+
+ @include break-wide() {
+ padding-right: $grid-unit-10;
+ }
+
+ .edit-site-header-edit-mode-toolbar__inserter-toggle {
+ margin-right: $grid-unit-10;
+ min-width: $grid-unit-40;
+ width: $grid-unit-40;
+ height: $grid-unit-40;
+ padding: 0;
+
+ svg {
+ transition: transform cubic-bezier(0.165, 0.84, 0.44, 1) 0.2s;
+ @include reduce-motion("transition");
+ }
+
+ &.is-pressed {
+ svg {
+ transform: rotate(45deg);
+ }
+ }
+ }
+}
+
+.edit-site-header-edit-mode__toolbar-switchers {
+ align-items: center;
+ display: flex;
+}
+
+.edit-site-header-edit-mode__toolbar-switchers-separator {
+ margin: 0 -6px 0;
+}
+
+
+/**
+ * Buttons on the right side
+ */
+
+.edit-site-header-edit-mode__actions {
+ display: inline-flex;
+ align-items: center;
+ padding-right: $grid-unit-05;
+
+ @include break-small () {
+ padding-right: $grid-unit-20 - ($grid-unit-15 * 0.5);
+ }
+
+ gap: $grid-unit-05;
+
+ @include break-small() {
+ gap: $grid-unit-10;
+ }
+
+ // Pinned items.
+ .interface-pinned-items {
+ display: none;
+
+ @include break-medium() {
+ display: inline-flex;
+ }
+ }
+}
+
+.edit-site-header-edit-mode__actions__preview-options {
+ opacity: 1;
+ transition: opacity 0.3s;
+
+ &.is-zoomed-out {
+ opacity: 0;
+ }
+}
+
+.edit-site-header-edit-mode__actions-more-menu {
+ margin-left: -4px;
+
+ // The padding and margin of the more menu is intentionally non-standard.
+ .components-icon-button {
+ padding: 8px 2px;
+ width: auto;
+ }
+
+ @include break-small() {
+ margin-left: 4px;
+
+ .components-icon-button {
+ padding: 8px 4px;
+ }
+ }
+}
+
+.edit-site-header-edit-mode__start {
+ display: flex;
+ border: none;
+
+ // The Toolbar component adds different styles to buttons, so we reset them
+ // here to the original button styles
+ .edit-site-header-edit-mode__toolbar > .components-button.has-icon,
+ .edit-site-header-edit-mode__toolbar > .components-dropdown > .components-button.has-icon {
+ height: $button-size;
+ min-width: $button-size;
+ padding: 6px;
+
+ &.is-pressed {
+ background: $gray-900;
+ }
+
+ &:focus:not(:disabled) {
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 0 0 $border-width $white;
+ outline: 1px solid transparent;
+ }
+
+ &::before {
+ display: none;
+ }
+ }
+
+ .eedit-site-header-edit-mode__toolbar > .edit-site-header-edit-mode-toolbar__inserter-toggle.has-icon {
+ margin-right: $grid-unit-10;
+ // Special dimensions for this button.
+ min-width: 32px;
+ width: 32px;
+ height: 32px;
+ padding: 0;
+ }
+
+ .edit-site-header-edit-mode__toolbar > .edit-site-header-edit-mode-toolbar__inserter-toggle.has-text.has-icon {
+ width: auto;
+ padding: 0 $grid-unit-10;
+ }
+}
+
+// Button text label styles
+
+.edit-site-header-edit-mode.show-icon-labels {
+ .components-button.has-icon {
+ width: auto;
+
+ // Hide the button icons when labels are set to display...
+ svg {
+ display: none;
+ }
+ // ... and display labels.
+ &::after {
+ content: attr(aria-label);
+ }
+ &[aria-disabled="true"] {
+ background-color: transparent;
+ }
+ }
+ .is-tertiary {
+ &:active {
+ box-shadow: 0 0 0 1.5px var(--wp-admin-theme-color);
+ background-color: transparent;
+ }
+ }
+ // Some margins and padding have to be adjusted so the buttons can still fit on smaller screens.
+ .edit-site-save-button__button {
+ padding-left: 6px;
+ padding-right: 6px;
+ }
+
+ // The template details toggle has a custom label, different from its aria-label, so we don't want to display both.
+ .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info {
+ &::after {
+ content: none;
+ }
+ }
+
+ .edit-site-header-edit-mode-toolbar__inserter-toggle.edit-site-header-edit-mode-toolbar__inserter-toggle,
+ .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info {
+ height: 36px;
+ padding: 0 $grid-unit-10;
+ }
+
+ .edit-site-header-edit-mode__start .edit-site-header-edit-mode__toolbar > * + * {
+ margin-left: $grid-unit-10;
+ }
+}
diff --git a/packages/edit-site/src/components/header/tools-more-menu-group/index.js b/packages/edit-site/src/components/header-edit-mode/tools-more-menu-group/index.js
similarity index 100%
rename from packages/edit-site/src/components/header/tools-more-menu-group/index.js
rename to packages/edit-site/src/components/header-edit-mode/tools-more-menu-group/index.js
diff --git a/packages/edit-site/src/components/header/undo-redo/redo.js b/packages/edit-site/src/components/header-edit-mode/undo-redo/redo.js
similarity index 100%
rename from packages/edit-site/src/components/header/undo-redo/redo.js
rename to packages/edit-site/src/components/header-edit-mode/undo-redo/redo.js
diff --git a/packages/edit-site/src/components/header/undo-redo/undo.js b/packages/edit-site/src/components/header-edit-mode/undo-redo/undo.js
similarity index 100%
rename from packages/edit-site/src/components/header/undo-redo/undo.js
rename to packages/edit-site/src/components/header-edit-mode/undo-redo/undo.js
diff --git a/packages/edit-site/src/components/header/index.js b/packages/edit-site/src/components/header/index.js
index 2630236b36f5b..cfad86f05fb5b 100644
--- a/packages/edit-site/src/components/header/index.js
+++ b/packages/edit-site/src/components/header/index.js
@@ -1,285 +1,69 @@
-/**
- * External dependencies
- */
-import classnames from 'classnames';
-
/**
* WordPress dependencies
*/
-import { useCallback, useRef } from '@wordpress/element';
-import { useViewportMatch } from '@wordpress/compose';
-import {
- ToolSelector,
- __experimentalPreviewOptions as PreviewOptions,
- NavigableToolbar,
- store as blockEditorStore,
-} from '@wordpress/block-editor';
import { useSelect, useDispatch } from '@wordpress/data';
-import { PinnedItems } from '@wordpress/interface';
-import { _x, __ } from '@wordpress/i18n';
-import { listView, plus, external, chevronUpDown } from '@wordpress/icons';
import {
+ __unstableAnimatePresence as AnimatePresence,
+ __experimentalHStack as HStack,
+ __unstableMotion as motion,
Button,
- ToolbarItem,
- MenuGroup,
- MenuItem,
- VisuallyHidden,
+ FlexBlock,
} from '@wordpress/components';
-import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
-import { store as preferencesStore } from '@wordpress/preferences';
-import { store as editorStore } from '@wordpress/editor';
-import { store as coreStore } from '@wordpress/core-data';
+import { __ } from '@wordpress/i18n';
+import { useReducedMotion } from '@wordpress/compose';
/**
* Internal dependencies
*/
-import MoreMenu from './more-menu';
-import SaveButton from '../save-button';
-import UndoButton from './undo-redo/undo';
-import RedoButton from './undo-redo/redo';
-import DocumentActions from './document-actions';
-import TemplateDetails from '../template-details';
import { store as editSiteStore } from '../../store';
-
-const preventDefault = ( event ) => {
- event.preventDefault();
-};
+import EditorToolbars from '../header-edit-mode';
+import SiteIconAndTitle from '../site-icon-and-title';
export default function Header() {
- const inserterButton = useRef();
- const {
- deviceType,
- entityTitle,
- template,
- templateType,
- isInserterOpen,
- isListViewOpen,
- listViewShortcut,
- isLoaded,
- isVisualMode,
- settings,
- blockEditorMode,
- showIconLabels,
- } = useSelect( ( select ) => {
- const {
- __experimentalGetPreviewDeviceType,
- getEditedPostType,
- getEditedPostId,
- isInserterOpened,
- isListViewOpened,
- getEditorMode,
- getSettings,
- } = select( editSiteStore );
- const { getEditedEntityRecord } = select( coreStore );
- const { __experimentalGetTemplateInfo: getTemplateInfo } =
- select( editorStore );
- const { getShortcutRepresentation } = select( keyboardShortcutsStore );
- const { __unstableGetEditorMode } = select( blockEditorStore );
-
- const postType = getEditedPostType();
- const postId = getEditedPostId();
- const record = getEditedEntityRecord( 'postType', postType, postId );
- const _isLoaded = !! postId;
-
- return {
- deviceType: __experimentalGetPreviewDeviceType(),
- entityTitle: getTemplateInfo( record ).title,
- isLoaded: _isLoaded,
- template: record,
- templateType: postType,
- isInserterOpen: isInserterOpened(),
- isListViewOpen: isListViewOpened(),
- listViewShortcut: getShortcutRepresentation(
- 'core/edit-site/toggle-list-view'
- ),
- isVisualMode: getEditorMode() === 'visual',
- settings: getSettings(),
- blockEditorMode: __unstableGetEditorMode(),
- showIconLabels: select( preferencesStore ).get(
- 'core/edit-site',
- 'showIconLabels'
- ),
- };
- }, [] );
-
- const {
- __experimentalSetPreviewDeviceType: setPreviewDeviceType,
- setIsInserterOpened,
- setIsListViewOpened,
- } = useDispatch( editSiteStore );
- const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
-
- const isLargeViewport = useViewportMatch( 'medium' );
-
- const openInserter = useCallback( () => {
- if ( isInserterOpen ) {
- // Focusing the inserter button closes the inserter popover.
- inserterButton.current.focus();
- } else {
- setIsInserterOpened( true );
- }
- }, [ isInserterOpen, setIsInserterOpened ] );
-
- const toggleListView = useCallback(
- () => setIsListViewOpened( ! isListViewOpen ),
- [ setIsListViewOpened, isListViewOpen ]
+ const { canvasMode } = useSelect(
+ ( select ) => ( {
+ canvasMode: select( editSiteStore ).__unstableGetCanvasMode(),
+ } ),
+ []
);
-
- const isFocusMode = templateType === 'wp_template_part';
-
- /* translators: button label text should, if possible, be under 16 characters. */
- const longLabel = _x(
- 'Toggle block inserter',
- 'Generic label for block inserter button'
- );
- const shortLabel = ! isInserterOpen ? __( 'Add' ) : __( 'Close' );
-
- const isZoomedOutViewExperimentEnabled =
- window?.__experimentalEnableZoomedOutView && isVisualMode;
- const isZoomedOutView = blockEditorMode === 'zoom-out';
+ const { __unstableSetCanvasMode } = useDispatch( editSiteStore );
+ const disableMotion = useReducedMotion();
return (
-
-
+
-
-
-
- { ( { onClose } ) => (
-
- ) }
-
-
-
-
-
- { ! isFocusMode && (
-
+ ) }
+ { canvasMode === 'view' && __( 'Edit' ) }
+
+
+
+ { canvasMode === 'edit' && (
+
-
-
-
-
-
-
+
+
) }
-
-
-
-
-
-
+
+
+
);
}
diff --git a/packages/edit-site/src/components/header/style.scss b/packages/edit-site/src/components/header/style.scss
index bd6778426d8f5..c905c42fc5981 100644
--- a/packages/edit-site/src/components/header/style.scss
+++ b/packages/edit-site/src/components/header/style.scss
@@ -1,224 +1,3 @@
-$header-toolbar-min-width: 335px;
-
-.edit-site-header {
- align-items: center;
- background-color: $white;
- display: flex;
- height: $header-height;
- box-sizing: border-box;
- width: 100%;
- justify-content: space-between;
-
- .edit-site-header_start {
- display: flex;
- border: none;
- }
-
- .edit-site-header_end {
- display: flex;
- justify-content: flex-end;
- }
-
- .edit-site-header_center {
- display: flex;
- align-items: center;
- height: 100%;
- flex-grow: 1;
- justify-content: center;
- // Flex items will, by default, refuse to shrink below a minimum
- // intrinsic width. In order to shrink this flexbox item, and
- // subsequently truncate child text, we set an explicit min-width.
- // See https://dev.w3.org/csswg/css-flexbox/#min-size-auto
- min-width: 0;
- }
-}
-
-.edit-site-header__toolbar {
- display: flex;
- align-items: center;
- padding-left: $grid-unit-10;
-
- @include break-small() {
- padding-left: $grid-unit-30;
- }
-
- @include break-wide() {
- padding-right: $grid-unit-10;
- }
-
- .edit-site-header-toolbar__inserter-toggle {
- margin-right: $grid-unit-10;
- min-width: $grid-unit-40;
- width: $grid-unit-40;
- height: $grid-unit-40;
- padding: 0;
-
- svg {
- transition: transform cubic-bezier(0.165, 0.84, 0.44, 1) 0.2s;
- @include reduce-motion("transition");
- }
-
- &.is-pressed {
- svg {
- transform: rotate(45deg);
- }
- }
- }
-}
-
-.edit-site-header__toolbar-switchers {
- align-items: center;
- display: flex;
-}
-
-.edit-site-header__toolbar-switchers-separator {
- margin: 0 -6px 0;
-}
-
-
-/**
- * Buttons on the right side
- */
-
-.edit-site-header__actions {
- display: inline-flex;
- align-items: center;
- padding-right: $grid-unit-05;
-
- @include break-small () {
- padding-right: $grid-unit-20 - ($grid-unit-15 * 0.5);
- }
-
- gap: $grid-unit-05;
-
- @include break-small() {
- gap: $grid-unit-10;
- }
-
- // Pinned items.
- .interface-pinned-items {
- display: none;
-
- @include break-medium() {
- display: inline-flex;
- }
- }
-}
-
-.edit-site-header__actions__preview-options {
- opacity: 1;
- transition: opacity 0.3s;
-
- &.is-zoomed-out {
- opacity: 0;
- }
-}
-
-.edit-site-header__actions-more-menu {
- margin-left: -4px;
-
- // The padding and margin of the more menu is intentionally non-standard.
- .components-icon-button {
- padding: 8px 2px;
- width: auto;
- }
-
- @include break-small() {
- margin-left: 4px;
-
- .components-icon-button {
- padding: 8px 4px;
- }
- }
-}
-
-.edit-site-header_start {
- display: flex;
- border: none;
-
- // The Toolbar component adds different styles to buttons, so we reset them
- // here to the original button styles
- .edit-site-header__toolbar > .components-button.has-icon,
- .edit-site-header__toolbar > .components-dropdown > .components-button.has-icon {
- height: $button-size;
- min-width: $button-size;
- padding: 6px;
-
- &.is-pressed {
- background: $gray-900;
- }
-
- &:focus:not(:disabled) {
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 0 0 $border-width $white;
- outline: 1px solid transparent;
- }
-
- &::before {
- display: none;
- }
- }
-
- .edit-site-header__toolbar > .edit-site-header-toolbar__inserter-toggle.has-icon {
- margin-right: $grid-unit-10;
- // Special dimensions for this button.
- min-width: 32px;
- width: 32px;
- height: 32px;
- padding: 0;
- }
-
- .edit-site-header__toolbar > .edit-site-header-toolbar__inserter-toggle.has-text.has-icon {
- width: auto;
- padding: 0 $grid-unit-10;
- }
-
-
-}
-
-// Button text label styles
-
-.edit-site-header.show-icon-labels {
- .components-button.has-icon {
- width: auto;
-
- // Hide the button icons when labels are set to display...
- svg {
- display: none;
- }
- // ... and display labels.
- &::after {
- content: attr(aria-label);
- }
- &[aria-disabled="true"] {
- background-color: transparent;
- }
- }
- .is-tertiary {
- &:active {
- box-shadow: 0 0 0 1.5px var(--wp-admin-theme-color);
- background-color: transparent;
- }
- }
- // Some margins and padding have to be adjusted so the buttons can still fit on smaller screens.
- .edit-site-save-button__button {
- padding-left: 6px;
- padding-right: 6px;
- }
-
- // The template details toggle has a custom label, different from its aria-label, so we don't want to display both.
- .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info {
- &::after {
- content: none;
- }
- }
-
- .edit-site-header-toolbar__inserter-toggle.edit-site-header-toolbar__inserter-toggle,
- .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info {
- height: 36px;
- padding: 0 $grid-unit-10;
- }
-
- .edit-site-header_start .edit-site-header__toolbar > * + * {
- margin-left: $grid-unit-10;
- }
+.edit-site-header__toggle {
+ min-height: 60px;
}
diff --git a/packages/edit-site/src/components/keyboard-shortcuts/index.js b/packages/edit-site/src/components/keyboard-shortcuts/index.js
index 5937acc6d80db..3a2d82c842eab 100644
--- a/packages/edit-site/src/components/keyboard-shortcuts/index.js
+++ b/packages/edit-site/src/components/keyboard-shortcuts/index.js
@@ -15,7 +15,7 @@ import { store as interfaceStore } from '@wordpress/interface';
* Internal dependencies
*/
import { store as editSiteStore } from '../../store';
-import { SIDEBAR_BLOCK } from '../sidebar/constants';
+import { SIDEBAR_BLOCK } from '../sidebar-edit-mode/constants';
import { STORE_NAME } from '../../store/constants';
function KeyboardShortcuts() {
diff --git a/packages/edit-site/src/new/layout/index.js b/packages/edit-site/src/components/layout/index.js
similarity index 79%
rename from packages/edit-site/src/new/layout/index.js
rename to packages/edit-site/src/components/layout/index.js
index 8a02fcab469e2..81184fb2e06ec 100644
--- a/packages/edit-site/src/new/layout/index.js
+++ b/packages/edit-site/src/components/layout/index.js
@@ -15,8 +15,8 @@ import { useReducedMotion } from '@wordpress/compose';
*/
import { Sidebar } from '../sidebar';
import Canvas from '../canvas';
+import ErrorBoundary from '../error-boundary';
import { store as editSiteStore } from '../../store';
-import ErrorBoundary from '../../components/error-boundary';
export default function Layout() {
const { canvasMode } = useSelect(
@@ -31,16 +31,16 @@ export default function Layout() {
return (
-
+
-
+
diff --git a/packages/edit-site/src/new/layout/style.scss b/packages/edit-site/src/components/layout/style.scss
similarity index 70%
rename from packages/edit-site/src/new/layout/style.scss
rename to packages/edit-site/src/components/layout/style.scss
index 69c739618f1f8..5c99829c0d49a 100644
--- a/packages/edit-site/src/new/layout/style.scss
+++ b/packages/edit-site/src/components/layout/style.scss
@@ -1,30 +1,30 @@
-.edit-site-new__layout {
+.edit-site-layout {
background: $gray-900;
color: $white;
min-height: 100%;
display: flex;
}
-.edit-site-new__sidebar {
+.edit-site-layout__sidebar {
width: $sidebar-width;
padding: $grid-unit-20;
- .edit-site-new__layout.is-full-canvas & {
+ .edit-site-layout.is-full-canvas & {
display: none;
}
}
-.edit-site-new__canvas-container {
+.edit-site-layout__canvas-container {
flex-grow: 1;
padding: $grid-unit-30;
position: relative;
- .edit-site-new__layout.is-full-canvas & {
+ .edit-site-layout.is-full-canvas & {
padding: 0;
}
}
-.edit-site-new__canvas {
+.edit-site-layout__canvas {
background: $white;
color: $gray-900;
border-radius: $radius-block-ui * 2;
@@ -35,7 +35,7 @@
bottom: $grid-unit-30;
overflow-y: auto;
- .edit-site-new__layout.is-full-canvas & {
+ .edit-site-layout.is-full-canvas & {
top: 0;
left: 0;
right: 0;
@@ -45,7 +45,7 @@
}
// This shouldn't be necessary (we should have a way to say that a skeletton is relative
-.edit-site-new__canvas .interface-interface-skeleton {
+.edit-site-layout__canvas .interface-interface-skeleton {
position: relative !important;
max-height: auto !important;
min-height: 100% !important;
diff --git a/packages/edit-site/src/new/navigation-inspector/index.js b/packages/edit-site/src/components/navigation-inspector/index.js
similarity index 100%
rename from packages/edit-site/src/new/navigation-inspector/index.js
rename to packages/edit-site/src/components/navigation-inspector/index.js
diff --git a/packages/edit-site/src/new/navigation-inspector/navigation-menu.js b/packages/edit-site/src/components/navigation-inspector/navigation-menu.js
similarity index 100%
rename from packages/edit-site/src/new/navigation-inspector/navigation-menu.js
rename to packages/edit-site/src/components/navigation-inspector/navigation-menu.js
diff --git a/packages/edit-site/src/new/navigation-inspector/style.scss b/packages/edit-site/src/components/navigation-inspector/style.scss
similarity index 100%
rename from packages/edit-site/src/new/navigation-inspector/style.scss
rename to packages/edit-site/src/components/navigation-inspector/style.scss
diff --git a/packages/edit-site/src/components/sidebar/constants.js b/packages/edit-site/src/components/sidebar-edit-mode/constants.js
similarity index 100%
rename from packages/edit-site/src/components/sidebar/constants.js
rename to packages/edit-site/src/components/sidebar-edit-mode/constants.js
diff --git a/packages/edit-site/src/components/sidebar/default-sidebar.js b/packages/edit-site/src/components/sidebar-edit-mode/default-sidebar.js
similarity index 100%
rename from packages/edit-site/src/components/sidebar/default-sidebar.js
rename to packages/edit-site/src/components/sidebar-edit-mode/default-sidebar.js
diff --git a/packages/edit-site/src/components/sidebar/global-styles-sidebar.js b/packages/edit-site/src/components/sidebar-edit-mode/global-styles-sidebar.js
similarity index 100%
rename from packages/edit-site/src/components/sidebar/global-styles-sidebar.js
rename to packages/edit-site/src/components/sidebar-edit-mode/global-styles-sidebar.js
diff --git a/packages/edit-site/src/components/sidebar-edit-mode/index.js b/packages/edit-site/src/components/sidebar-edit-mode/index.js
new file mode 100644
index 0000000000000..e69989db1015e
--- /dev/null
+++ b/packages/edit-site/src/components/sidebar-edit-mode/index.js
@@ -0,0 +1,88 @@
+/**
+ * WordPress dependencies
+ */
+import { createSlotFill, PanelBody } from '@wordpress/components';
+import { __ } from '@wordpress/i18n';
+import { cog } from '@wordpress/icons';
+import { useEffect } from '@wordpress/element';
+import { useSelect, useDispatch } from '@wordpress/data';
+import { store as interfaceStore } from '@wordpress/interface';
+import { store as blockEditorStore } from '@wordpress/block-editor';
+
+/**
+ * Internal dependencies
+ */
+import DefaultSidebar from './default-sidebar';
+import GlobalStylesSidebar from './global-styles-sidebar';
+import { STORE_NAME } from '../../store/constants';
+import SettingsHeader from './settings-header';
+import TemplateCard from './template-card';
+import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';
+import { store as editSiteStore } from '../../store';
+
+const { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(
+ 'EditSiteSidebarInspector'
+);
+export const SidebarInspectorFill = InspectorFill;
+
+export function SidebarComplementaryAreaFills() {
+ const {
+ sidebar,
+ isEditorSidebarOpened,
+ hasBlockSelection,
+ supportsGlobalStyles,
+ } = useSelect( ( select ) => {
+ const _sidebar =
+ select( interfaceStore ).getActiveComplementaryArea( STORE_NAME );
+ const _isEditorSidebarOpened = [
+ SIDEBAR_BLOCK,
+ SIDEBAR_TEMPLATE,
+ ].includes( _sidebar );
+ const settings = select( editSiteStore ).getSettings();
+ return {
+ sidebar: _sidebar,
+ isEditorSidebarOpened: _isEditorSidebarOpened,
+ hasBlockSelection:
+ !! select( blockEditorStore ).getBlockSelectionStart(),
+ supportsGlobalStyles: ! settings?.supportsTemplatePartsMode,
+ };
+ }, [] );
+ const { enableComplementaryArea } = useDispatch( interfaceStore );
+
+ useEffect( () => {
+ if ( ! isEditorSidebarOpened ) return;
+ if ( hasBlockSelection ) {
+ enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );
+ } else {
+ enableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );
+ }
+ }, [ hasBlockSelection, isEditorSidebarOpened ] );
+
+ let sidebarName = sidebar;
+ if ( ! isEditorSidebarOpened ) {
+ sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;
+ }
+
+ return (
+ <>
+ }
+ headerClassName="edit-site-sidebar-edit-mode__panel-tabs"
+ >
+ { sidebarName === SIDEBAR_TEMPLATE && (
+
+
+
+ ) }
+ { sidebarName === SIDEBAR_BLOCK && (
+
+ ) }
+
+ { supportsGlobalStyles && }
+ >
+ );
+}
diff --git a/packages/edit-site/src/components/sidebar/plugin-sidebar/index.js b/packages/edit-site/src/components/sidebar-edit-mode/plugin-sidebar/index.js
similarity index 98%
rename from packages/edit-site/src/components/sidebar/plugin-sidebar/index.js
rename to packages/edit-site/src/components/sidebar-edit-mode/plugin-sidebar/index.js
index e617ae9ac0041..d705d0724af9f 100644
--- a/packages/edit-site/src/components/sidebar/plugin-sidebar/index.js
+++ b/packages/edit-site/src/components/sidebar-edit-mode/plugin-sidebar/index.js
@@ -83,7 +83,7 @@ export default function PluginSidebarEditSite( { className, ...props } ) {
return (
{