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
Next Next commit
Only show background in focus mode
  • Loading branch information
kevin940726 committed Sep 24, 2021
commit 34ce49b26d94b4e1301c4839e44be6da75460f2b
14 changes: 1 addition & 13 deletions packages/edit-site/src/components/block-editor/back-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ import { __, sprintf } from '@wordpress/i18n';
import { store as editSiteStore } from '../../store';
import useTemplateTitle from '../use-template-title';

function getTemplateTypeName( templateType ) {
switch ( templateType ) {
case 'wp_template_part':
return __( 'template part' );
case 'wp_template':
return __( 'template' );
default:
throw new Error( 'Unknown template type' );
}
}

function BackButton() {
const {
isTemplatePart,
Expand Down Expand Up @@ -62,8 +51,7 @@ function BackButton() {
{ sprintf(
/* translators: Template name. */
__( 'Back to %s' ),
previousTemplateTitle,
getTemplateTypeName( previousTemplateType )
previousTemplateTitle
) }
</Button>
);
Expand Down
14 changes: 10 additions & 4 deletions packages/edit-site/src/components/block-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,28 @@ const LAYOUT = {
};

export default function BlockEditor( { setIsInserterOpen } ) {
const { settings, templateType, page, deviceType } = useSelect(
const {
settings,
templateType,
page,
deviceType,
hasPreviousPage,
} = useSelect(
( select ) => {
const {
getSettings,
getEditedPostType,
getPage,
__experimentalGetPreviewDeviceType,
getPreviousEditedPostId,
} = select( editSiteStore );

return {
settings: getSettings( setIsInserterOpen ),
templateType: getEditedPostType(),
page: getPage(),
deviceType: __experimentalGetPreviewDeviceType(),
hasPreviousPage: !! getPreviousEditedPostId(),
};
},
[ setIsInserterOpen ]
Expand All @@ -70,8 +78,6 @@ export default function BlockEditor( { setIsInserterOpen } ) {
const contentRef = useRef();
const mergedRefs = useMergeRefs( [ contentRef, useTypingObserver() ] );

const isTemplatePart = templateType === 'wp_template_part';

return (
<BlockEditorProvider
settings={ settings }
Expand Down Expand Up @@ -99,7 +105,7 @@ export default function BlockEditor( { setIsInserterOpen } ) {
</SidebarInspectorFill>
<BlockTools
className={ classnames( 'edit-site-visual-editor', {
'is-template-part': isTemplatePart,
'is-focus-mode': hasPreviousPage,
} ) }
__unstableContentRef={ contentRef }
>
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/block-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
position: relative;
background-color: $gray-800;

&.is-template-part {
&.is-focus-mode {
padding: 48px 48px 0;
}
}
Expand Down