From b5d5a820cb3ef491b869cf3be65e25b25fa91720 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 18 May 2020 10:03:23 +0100 Subject: [PATCH] User the inserter panel for the edit-site screen --- .../edit-site/src/components/editor/index.js | 46 +++++++++++++++++++ .../src/components/editor/style.scss | 26 +++++++++++ .../edit-site/src/components/header/index.js | 26 +++++++---- 3 files changed, 90 insertions(+), 8 deletions(-) diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js index 849bd6e44f87f3..41f037ed2be03f 100644 --- a/packages/edit-site/src/components/editor/index.js +++ b/packages/edit-site/src/components/editor/index.js @@ -23,12 +23,14 @@ import { BlockBreadcrumb, __unstableEditorStyles as EditorStyles, __experimentalUseResizeCanvas as useResizeCanvas, + __experimentalLibrary as Library, } from '@wordpress/block-editor'; import { useViewportMatch } from '@wordpress/compose'; import { FullscreenMode, InterfaceSkeleton } from '@wordpress/interface'; import { EntitiesSavedStates } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; import { PluginArea } from '@wordpress/plugins'; +import { close } from '@wordpress/icons'; /** * Internal dependencies @@ -44,7 +46,12 @@ export function useEditorContext() { return useContext( Context ); } +const interfaceLabels = { + leftSidebar: __( 'Block Library' ), +}; + function Editor( { settings: _settings } ) { + const [ isInserterOpen, setIsInserterOpen ] = useState( false ); const isMobile = useViewportMatch( 'medium', '<' ); const [ settings, setSettings ] = useState( _settings ); const template = useSelect( @@ -131,6 +138,37 @@ function Editor( { settings: _settings } ) { +
+
+
+ { + if ( + isMobile + ) { + setIsInserterOpen( + false + ); + } + } } + /> +
+ + ) + } sidebar={ ! isMobile && } @@ -139,6 +177,14 @@ function Editor( { settings: _settings } ) { openEntitiesSavedStates={ openEntitiesSavedStates } + isInserterOpen={ + isInserterOpen + } + onToggleInserter={ () => + setIsInserterOpen( + ! isInserterOpen + ) + } /> } content={ diff --git a/packages/edit-site/src/components/editor/style.scss b/packages/edit-site/src/components/editor/style.scss index 297f13138a75c6..64d20d01606d48 100644 --- a/packages/edit-site/src/components/editor/style.scss +++ b/packages/edit-site/src/components/editor/style.scss @@ -25,3 +25,29 @@ .edit-site-visual-editor { background-color: $white; } + +.edit-site-editor__inserter-panel { + height: 100%; + display: flex; + flex-direction: column; +} + +.edit-site-editor__inserter-panel-header { + padding-top: $grid-unit-10; + padding-right: $grid-unit-10; + display: flex; + justify-content: flex-end; + + @include break-medium() { + display: none; + } +} + +.edit-site-editor__inserter-panel-content { + // Leave space for the close button + height: calc(100% - #{$button-size} - #{$grid-unit-10}); + + @include break-medium() { + height: 100%; + } +} diff --git a/packages/edit-site/src/components/header/index.js b/packages/edit-site/src/components/header/index.js index c4a453e74fad2c..496278dba75fc7 100644 --- a/packages/edit-site/src/components/header/index.js +++ b/packages/edit-site/src/components/header/index.js @@ -6,7 +6,6 @@ import { addQueryArgs } from '@wordpress/url'; import { BlockNavigationDropdown, ToolSelector, - Inserter, __experimentalPreviewOptions as PreviewOptions, } from '@wordpress/block-editor'; import { @@ -18,6 +17,9 @@ import { PinnedItems, __experimentalMainDashboardButton as MainDashboardButton, } from '@wordpress/interface'; +import { _x } from '@wordpress/i18n'; +import { plus } from '@wordpress/icons'; +import { Button } from '@wordpress/components'; /** * Internal dependencies @@ -36,9 +38,11 @@ import FullscreenModeClose from './fullscreen-mode-close'; */ const { fetch } = window; -const inserterToggleProps = { isPrimary: true }; - -export default function Header( { openEntitiesSavedStates } ) { +export default function Header( { + openEntitiesSavedStates, + isInserterOpen, + onToggleInserter, +} ) { const { settings, setSettings } = useEditorContext(); const setActiveTemplateId = useCallback( ( newTemplateId ) => @@ -109,10 +113,16 @@ export default function Header( { openEntitiesSavedStates } ) {
-