Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "show template" to preview dropdown. #66514

Merged
merged 8 commits into from
Nov 5, 2024
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
Show icon in document bar when template preview is selected
  • Loading branch information
tellthemachines committed Oct 29, 2024
commit 29de67d0897dd67196f675aa75f4fece2b5b644c
11 changes: 10 additions & 1 deletion packages/editor/src/components/document-bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
__unstableAnimatePresence as AnimatePresence,
} from '@wordpress/components';
import { BlockIcon } from '@wordpress/block-editor';
import { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';
import { chevronLeftSmall, chevronRightSmall, layout } from '@wordpress/icons';
import { displayShortcut } from '@wordpress/keycodes';
import { store as coreStore } from '@wordpress/core-data';
import { store as commandsStore } from '@wordpress/commands';
Expand Down Expand Up @@ -58,12 +58,14 @@ export default function DocumentBar( props ) {
isNotFound,
templateTitle,
onNavigateToPreviousEntityRecord,
isTemplatePreview,
} = useSelect( ( select ) => {
const {
getCurrentPostType,
getCurrentPostId,
getEditorSettings,
__experimentalGetTemplateInfo: getTemplateInfo,
getRenderingMode,
} = select( editorStore );
const {
getEditedEntityRecord,
Expand Down Expand Up @@ -95,6 +97,7 @@ export default function DocumentBar( props ) {
templateTitle: _templateInfo.title,
onNavigateToPreviousEntityRecord:
getEditorSettings().onNavigateToPreviousEntityRecord,
isTemplatePreview: getRenderingMode() === 'template-locked',
};
}, [] );

Expand Down Expand Up @@ -142,6 +145,12 @@ export default function DocumentBar( props ) {
{ __( 'Back' ) }
</MotionButton>
) }
{ ! isTemplate && isTemplatePreview && (
<BlockIcon
icon={ layout }
className="editor-document-bar__icon-layout"
/>
) }
</AnimatePresence>
{ isNotFound ? (
<Text>{ __( 'Document not found' ) }</Text>
Expand Down
4 changes: 4 additions & 0 deletions packages/editor/src/components/document-bar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@
background-color: transparent;
}
}

.editor-document-bar__icon-layout {
position: absolute;
}