diff --git a/packages/edit-site/src/components/layout/index.js b/packages/edit-site/src/components/layout/index.js index cd7890649c60a..43415ce08b867 100644 --- a/packages/edit-site/src/components/layout/index.js +++ b/packages/edit-site/src/components/layout/index.js @@ -11,6 +11,7 @@ import { __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence, __unstableUseNavigateRegions as useNavigateRegions, + ResizableBox, } from '@wordpress/components'; import { useReducedMotion, @@ -41,7 +42,7 @@ import getIsListPage from '../../utils/get-is-list-page'; import Header from '../header-edit-mode'; import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url'; import SiteHub from '../site-hub'; -import ResizableFrame from '../resizable-frame'; +import ResizeHandle from '../block-editor/resize-handle'; import useSyncCanvasModeWithURL from '../sync-state-with-url/use-sync-canvas-mode-with-url'; import { unlock } from '../../lock-unlock'; import SavePanel from '../save-panel'; @@ -58,6 +59,17 @@ const { useLocation } = unlock( routerPrivateApis ); const { useGlobalStyle } = unlock( blockEditorPrivateApis ); const ANIMATION_DURATION = 0.5; +const emptyResizeHandleStyles = { + position: undefined, + userSelect: undefined, + cursor: undefined, + width: undefined, + height: undefined, + top: undefined, + right: undefined, + bottom: undefined, + left: undefined, +}; export default function Layout() { // This ensures the edited entity id and type are initialized properly. @@ -108,6 +120,7 @@ export default function Layout() { next: nextShortcut, } ); const disableMotion = useReducedMotion(); + const canvasPadding = isMobileViewport ? 0 : 24; const showSidebar = ( isMobileViewport && ! isListPage ) || ( ! isMobileViewport && ( canvasMode === 'view' || ! isEditorPage ) ); @@ -115,11 +128,22 @@ export default function Layout() { ( isMobileViewport && isEditorPage && isEditing ) || ! isMobileViewport || ! isEditorPage; + const showFrame = + ( ! isEditorPage && ! isMobileViewport ) || + ( ! isMobileViewport && isEditorPage && canvasMode === 'view' ); const isFullCanvas = ( isMobileViewport && isListPage ) || ( isEditorPage && isEditing ); const [ canvasResizer, canvasSize ] = useResizeObserver(); - const [ fullResizer ] = useResizeObserver(); - const [ isResizing ] = useState( false ); + const isResizingEnabled = ! isMobileViewport && canvasMode === 'view'; + const defaultSidebarWidth = isMobileViewport ? '100vw' : 360; + const [ isResizing, setIsResizing ] = useState( false ); + const [ fullResizer, fullSize ] = useResizeObserver(); + const [ forcedWidth, setForcedWidth ] = useState( null ); + let canvasWidth = isResizing ? '100%' : fullSize.width; + if ( showFrame && ! isResizing ) { + canvasWidth = canvasSize.width - canvasPadding; + } + const isEditorLoading = useIsSiteEditorLoading(); // This determines which animation variant should apply to the header. @@ -257,28 +281,94 @@ export default function Layout() {