diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index de1dc9ffca493a..676435995b9b60 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -35,6 +35,7 @@ import { useRef } from '@wordpress/element'; * Internal dependencies */ import TemplateTitle from '../template-title'; +import PostTitle from '../post-title'; import { store as editPostStore } from '../../../store'; function HeaderToolbar() { @@ -220,7 +221,9 @@ characters. */ ) } - +
+ { isTemplateMode ? : } +
{ displayBlockToolbar && (
( { + entityTitle: select( editorStore ).getEditedPostAttribute( + 'title' + ), + entityLabel: select( editorStore ).getEditedPostAttribute( 'type' ), + } ), + [] + ); + + const titleRef = useRef(); + + if ( ! entityTitle ) { + return ( +
{ __( 'Loading…' ) }
+ ); + } + + return ( +
+
+ + + { sprintf( + /* translators: %s: the entity being edited, like "template"*/ + __( 'Editing %s:' ), + entityLabel + ) } + + + + + { entityTitle.length === 0 + ? __( 'No Title' ) + : entityTitle } + + + ( +
+
+ ); +} + +export default PostTitle; diff --git a/packages/edit-post/src/components/header/post-title/style.scss b/packages/edit-post/src/components/header/post-title/style.scss new file mode 100644 index 00000000000000..d6a1717943365e --- /dev/null +++ b/packages/edit-post/src/components/header/post-title/style.scss @@ -0,0 +1,57 @@ +.edit-post-title-actions { + display: flex; + flex-direction: column; + justify-content: center; + height: 100%; + // Flex items will, by default, refuse to shrink below a minimum + // intrinsic width. In order to shrink this flexbox item, and + // subsequently truncate child text, we set an explicit min-width. + // See https://dev.w3.org/csswg/css-flexbox/#min-size-auto + min-width: 0; + + .edit-post-title-actions__title-wrapper { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + + // See comment above about min-width + min-width: 0; + + .components-dropdown { + display: inline-flex; + margin-left: $grid-unit-05; + + .components-button { + min-width: 0; + padding: 0; + } + } + } + + .edit-post-title-actions__title-wrapper > h1 { + margin: 0; + + // See comment above about min-width + min-width: 0; + } + + .edit-post-title-actions__title { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 120px; + + @include break-medium() { + max-width: 75px; + } + + @include break-xlarge() { + max-width: 180px; + } + } +} +.edit-post-title-actions__info-dropdown > .components-popover__content > div { + padding: 0; + min-width: 240px; +} diff --git a/packages/edit-post/src/style.scss b/packages/edit-post/src/style.scss index c9dc8e01aa26ed..07f69a6de94789 100644 --- a/packages/edit-post/src/style.scss +++ b/packages/edit-post/src/style.scss @@ -3,7 +3,7 @@ @import "./components/header/fullscreen-mode-close/style.scss"; @import "./components/header/header-toolbar/style.scss"; @import "./components/header/more-menu/style.scss"; -@import "./components/header/template-title/style.scss"; +@import "./components/header/post-title/style.scss"; @import "./components/keyboard-shortcut-help-modal/style.scss"; @import "./components/layout/style.scss"; @import "./components/manage-blocks-modal/style.scss";