diff --git a/packages/block-library/src/navigation/editor.scss b/packages/block-library/src/navigation/editor.scss index eb796ae696541..0fc26721a3304 100644 --- a/packages/block-library/src/navigation/editor.scss +++ b/packages/block-library/src/navigation/editor.scss @@ -637,8 +637,6 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op } .wp-block-navigation__menu-inspector-controls { - overflow-x: auto; - @include custom-scrollbars-on-hover(transparent, $gray-600); } diff --git a/packages/components/src/navigator/styles.ts b/packages/components/src/navigator/styles.ts index 0203edbdf1816..096d7f89b4c22 100644 --- a/packages/components/src/navigator/styles.ts +++ b/packages/components/src/navigator/styles.ts @@ -5,12 +5,12 @@ import { css, keyframes } from '@emotion/react'; export const navigatorProviderWrapper = css` /* Prevents horizontal overflow while animating screen transitions */ - overflow-x: hidden; + overflow: visible; /* Mark this subsection of the DOM as isolated, providing performance benefits * by limiting calculations of layout, style and paint to a DOM subtree rather * than the entire page. */ - contain: content; + /* contain: content; */ `; const fadeInFromRight = keyframes( { @@ -62,8 +62,6 @@ const navigatorScreenAnimation = ( { }; export const navigatorScreen = ( props: NavigatorScreenAnimationProps ) => css` - /* Ensures horizontal overflow is visually accessible */ - overflow-x: auto; /* In case the root has a height, it should not be exceeded */ max-height: 100%; diff --git a/packages/edit-site/src/components/edit-overlay/index.js b/packages/edit-site/src/components/edit-overlay/index.js new file mode 100644 index 0000000000000..15b7045487588 --- /dev/null +++ b/packages/edit-site/src/components/edit-overlay/index.js @@ -0,0 +1,82 @@ +/** + * WordPress dependencies + */ +import { useState, useEffect } from '@wordpress/element'; +import { + Button, + SVG, + Path, + __unstableMotion as motion, + __unstableAnimatePresence as AnimatePresence, +} from '@wordpress/components'; +import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; + +/** + * Internal dependencies + */ +import { unlock } from '../../lock-unlock'; + +const { useGlobalStyle } = unlock( blockEditorPrivateApis ); + +const EditOverlay = ( { onClick, label } ) => { + const [ isVisible, setIsVisible ] = useState( true ); + const [ backgroundColor ] = useGlobalStyle( 'color.background' ); + + useEffect( () => { + const timeout = setTimeout( () => { + setIsVisible( false ); + }, 4000 ); + + return () => clearTimeout( timeout ); + }, [ backgroundColor ] ); + + return ( + + { isVisible && ( + + + + + { /* Your content here */ } + + ) } + + ); +}; + +export default EditOverlay; diff --git a/packages/edit-site/src/components/edit-overlay/style.scss b/packages/edit-site/src/components/edit-overlay/style.scss new file mode 100644 index 0000000000000..becafabea7116 --- /dev/null +++ b/packages/edit-site/src/components/edit-overlay/style.scss @@ -0,0 +1,40 @@ +.edit-site-layout__edit-overlay { + position: absolute; + z-index: 100; + top: 0; + left: 0; + right: 0; + bottom: 0; + display: flex; + justify-content: center; + align-items: flex-end; + padding-bottom: $grid-unit-40; + color: $white; + background: linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.4) 100%); + + .edit-site-layout__edit-overlay-button { + position: relative; + z-index: 10; + background: rgba(255, 255, 255, 0.6); + color: $gray-900; + border: 0; + border-radius: 999px; + cursor: pointer; + transition: background-color ease 0.1s; + box-shadow: 0 2px 4px rgba($black, 0.1); + + &:hover { + background-color: $gray-100; + } + } + + .edit-site-layout__edit-overlay-backdrop { + z-index: 5; + opacity: 0.7; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + } +} diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index 9c95755db2803..44ebcb14ab88e 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -6,8 +6,12 @@ import classnames from 'classnames'; /** * WordPress dependencies */ -import { useSelect } from '@wordpress/data'; -import { Notice } from '@wordpress/components'; +import { useSelect, useDispatch } from '@wordpress/data'; +import { + Notice, + __unstableMotion as motion, + __unstableAnimatePresence as AnimatePresence, +} from '@wordpress/components'; import { useInstanceId, useViewportMatch } from '@wordpress/compose'; import { store as preferencesStore } from '@wordpress/preferences'; import { @@ -20,6 +24,7 @@ import { import { InterfaceSkeleton, ComplementaryArea, + NavigableRegion, store as interfaceStore, } from '@wordpress/interface'; import { @@ -55,6 +60,8 @@ import { POST_TYPE_LABELS, TEMPLATE_POST_TYPE } from '../../utils/constants'; import SiteEditorCanvas from '../block-editor/site-editor-canvas'; import TemplatePartConverter from '../template-part-converter'; import { useSpecificEditorSettings } from '../block-editor/use-site-editor-settings'; +import Header from '../header-edit-mode'; +import EditOverlay from '../edit-overlay'; const { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis ); const { @@ -151,6 +158,8 @@ export default function Editor( { isLoading } ) { }; }, [] ); + const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); + const isViewMode = canvasMode === 'view'; const isEditMode = canvasMode === 'edit'; const showVisualEditor = isViewMode || editorMode === 'visual'; @@ -195,6 +204,27 @@ export default function Editor( { isLoading } ) { return ( <> + { ! isLoading && canvasMode !== 'edit' && ( + setCanvasMode( 'edit' ) } + /> + ) } + + { ! isLoading && ( + +
+ + ) } + { ! isReady ? : null } { isEditMode && } { hasLoadedPost && ! editedPost && ( diff --git a/packages/edit-site/src/components/header-edit-mode/index.js b/packages/edit-site/src/components/header-edit-mode/index.js index 5b8b44f63efe7..b981451374953 100644 --- a/packages/edit-site/src/components/header-edit-mode/index.js +++ b/packages/edit-site/src/components/header-edit-mode/index.js @@ -18,8 +18,8 @@ import { __ } from '@wordpress/i18n'; import { next, previous } from '@wordpress/icons'; import { Button, - __unstableMotion as motion, Popover, + __unstableMotion as motion, } from '@wordpress/components'; import { store as preferencesStore } from '@wordpress/preferences'; import { @@ -92,6 +92,14 @@ export default function HeaderEditMode() { const hasBlockSelected = !! blockSelectionStart; + const { canvasMode } = useSelect( ( select ) => { + const { getCanvasMode } = unlock( select( editSiteStore ) ); + + return { + canvasMode: getCanvasMode(), + }; + }, [] ); + useEffect( () => { // If we have a new block selection, show the block tools if ( blockSelectionStart ) { @@ -124,46 +132,54 @@ export default function HeaderEditMode() { variants={ toolbarVariants } transition={ toolbarTransition } > - - { isTopToolbar && ( - <> -
- -
- - { hasBlockSelected && ( - + + + + div { border-radius: $radius-block-ui * 4; // Not sure why this is necessary. @@ -136,10 +108,6 @@ } .edit-site-layout.is-full-canvas & { - top: 0; - bottom: 0; - width: 100%; - & > div { border-radius: 0; } @@ -157,61 +125,37 @@ height: 100%; } -.edit-site-layout__view-mode-toggle.components-button { - position: relative; - color: $white; - border-radius: 0; +.edit-site-layout__view-mode-toggle { + position: fixed; + top: $canvas-padding; height: $header-height; width: $header-height; - overflow: hidden; - padding: 0; - display: flex; - align-items: center; - justify-content: center; - border-bottom: 1px solid transparent; - - .edit-site-layout.is-full-canvas & { - border-bottom-color: $gray-200; - transition: border-bottom-color 0.15s 0.4s ease-out; - } - - &:hover, - &:active { + z-index: 100; + .components-button { color: $white; - } - - &:focus { - box-shadow: none; - } - - &::before { - transition: box-shadow 0.1s ease; - @include reduce-motion("transition"); - content: ""; - display: block; - position: absolute; - top: 9px; - right: 9px; - bottom: 9px; - left: 9px; - border-radius: $radius-block-ui + $border-width + $border-width; - box-shadow: none; - } + height: 100%; + width: 100%; + border-radius: 0; + overflow: hidden; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + &:hover, + &:active { + color: $white; + } - // Lightened spot color focus. - &:focus::before { - box-shadow: - inset 0 0 0 var(--wp-admin-border-width-focus) rgba($white, 0.1), - inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color); + &:focus { + box-shadow: none; + } } .edit-site-layout__view-mode-toggle-icon { - display: flex; - border-radius: $radius-block-ui; - height: $grid-unit-80; - width: $grid-unit-80; - justify-content: center; - align-items: center; + svg, + img { + display: block; + } } } @@ -268,19 +212,12 @@ } } - .edit-site-site-hub, .edit-site-layout__header { position: absolute; top: 0; z-index: z-index(".edit-site-layout__header"); - } - .edit-site-site-hub { - z-index: z-index(".edit-site-layout__hub"); - } - .edit-site-layout__header { width: 100%; } - } .edit-site-layout__area { diff --git a/packages/edit-site/src/components/resizable-frame/style.scss b/packages/edit-site/src/components/resizable-frame/style.scss index 3247525cc2e16..98d367726f9bd 100644 --- a/packages/edit-site/src/components/resizable-frame/style.scss +++ b/packages/edit-site/src/components/resizable-frame/style.scss @@ -23,6 +23,7 @@ .edit-site-resizable-frame__inner-content { position: absolute; + overflow: hidden; z-index: 0; inset: 0; } diff --git a/packages/edit-site/src/components/sidebar-navigation-item/style.scss b/packages/edit-site/src/components/sidebar-navigation-item/style.scss index 908056d52af48..8cb5181fb30dd 100644 --- a/packages/edit-site/src/components/sidebar-navigation-item/style.scss +++ b/packages/edit-site/src/components/sidebar-navigation-item/style.scss @@ -1,7 +1,7 @@ .edit-site-sidebar-navigation-item.components-item { color: $gray-600; // 6px right padding to align with + button - padding: $grid-unit-10 6px $grid-unit-10 $grid-unit-20; + padding: $grid-unit-10 $grid-unit-20; border: none; min-height: $grid-unit-50; border-radius: $radius-block-ui; diff --git a/packages/edit-site/src/components/sidebar-navigation-screen/style.scss b/packages/edit-site/src/components/sidebar-navigation-screen/style.scss index 44e266cdf6011..be6ce56f5c8a2 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen/style.scss +++ b/packages/edit-site/src/components/sidebar-navigation-screen/style.scss @@ -16,8 +16,6 @@ } .edit-site-sidebar-navigation-screen__content { - padding: 0 $grid-unit-20; - .components-item-group { margin-left: -$grid-unit-20; margin-right: -$grid-unit-20; @@ -60,7 +58,7 @@ position: sticky; top: 0; background: $gray-900; - padding-top: $grid-unit-60 + $header-height; + padding-top: $grid-unit-40; margin-bottom: $grid-unit-10; padding-bottom: $grid-unit-10; z-index: z-index(".edit-site-sidebar-navigation-screen__title-icon"); diff --git a/packages/edit-site/src/components/sidebar/index.js b/packages/edit-site/src/components/sidebar/index.js index 19cd55ae6fac2..0c99d3632d474 100644 --- a/packages/edit-site/src/components/sidebar/index.js +++ b/packages/edit-site/src/components/sidebar/index.js @@ -33,6 +33,7 @@ import { unlock } from '../../lock-unlock'; import SidebarNavigationScreenPages from '../sidebar-navigation-screen-pages'; import SidebarNavigationScreenPagesDataViews from '../sidebar-navigation-screen-pages-dataviews'; import SidebarNavigationScreenPage from '../sidebar-navigation-screen-page'; +import SiteHub from '../site-hub'; const { useLocation } = unlock( routerPrivateApis ); @@ -99,6 +100,7 @@ function Sidebar() { return ( <> + { - const { canvasMode, dashboardLink, homeUrl, siteTitle } = useSelect( - ( select ) => { - const { getCanvasMode, getSettings } = unlock( - select( editSiteStore ) - ); - - const { - getSite, - getUnstableBase, // Site index. - } = select( coreStore ); + const { homeUrl, siteTitle } = useSelect( ( select ) => { + const { + getSite, + getUnstableBase, // Site index. + } = select( coreStore ); - return { - canvasMode: getCanvasMode(), - dashboardLink: - getSettings().__experimentalDashboardLink || 'index.php', - homeUrl: getUnstableBase()?.home, - siteTitle: getSite()?.title, - }; - }, - [] - ); + return { + homeUrl: getUnstableBase()?.home, + siteTitle: getSite()?.title, + }; + }, [] ); const { open: openCommandCenter } = useDispatch( commandsStore ); - const disableMotion = useReducedMotion(); - const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); - const { clearSelectedBlock } = useDispatch( blockEditorStore ); - const { setDeviceType } = useDispatch( editorStore ); - const isBackToDashboardButton = canvasMode === 'view'; - const siteIconButtonProps = isBackToDashboardButton - ? { - href: dashboardLink, - label: __( 'Go to the Dashboard' ), - } - : { - href: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a ` - - - - - { decodeEntities( siteTitle ) } - - - { canvasMode === 'view' && ( -