diff --git a/packages/base-styles/_mixins.scss b/packages/base-styles/_mixins.scss index 65f98bf6f15bfc..e2f953e5787814 100644 --- a/packages/base-styles/_mixins.scss +++ b/packages/base-styles/_mixins.scss @@ -18,25 +18,25 @@ @mixin heading-small() { @include _text-heading(); font-size: $font-size-x-small; - line-height: $line-height-x-small; + line-height: $font-line-height-x-small; } @mixin heading-medium() { @include _text-heading(); font-size: $font-size-medium; - line-height: $line-height-small; + line-height: $font-line-height-small; } @mixin heading-large() { @include _text-heading(); font-size: $font-size-large; - line-height: $line-height-small; + line-height: $font-line-height-small; } @mixin heading-x-large() { @include _text-heading(); font-size: $font-size-x-large; - line-height: $line-height-medium; + line-height: $font-line-height-medium; } @mixin heading-2x-large() { @@ -48,25 +48,25 @@ @mixin body-small() { @include _text-body(); font-size: $font-size-small; - line-height: $line-height-x-small; + line-height: $font-line-height-x-small; } @mixin body-medium() { @include _text-body(); font-size: $font-size-medium; - line-height: $line-height-small; + line-height: $font-line-height-small; } @mixin body-large() { @include _text-body(); font-size: $font-size-large; - line-height: $line-height-medium; + line-height: $font-line-height-medium; } @mixin body-x-large() { @include _text-body(); font-size: $font-size-x-large; - line-height: $line-height-x-large; + line-height: $font-line-height-x-large; } /** diff --git a/packages/edit-site/src/components/post-edit/header.js b/packages/edit-site/src/components/post-edit/header.js new file mode 100644 index 00000000000000..305589d0cc22bf --- /dev/null +++ b/packages/edit-site/src/components/post-edit/header.js @@ -0,0 +1,88 @@ +/** + * WordPress dependencies + */ +import { + __experimentalHStack as HStack, + __experimentalVStack as VStack, + Icon, + __experimentalText as Text, +} from '@wordpress/components'; +import { useMemo } from '@wordpress/element'; +import { + privateApis as editorPrivateApis, + store as editorStore, +} from '@wordpress/editor'; +import { store as coreStore } from '@wordpress/core-data'; +import { useSelect } from '@wordpress/data'; +import { sprintf, __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import { unlock } from '../../lock-unlock'; + +const { PostCardPanel } = unlock( editorPrivateApis ); + +export default function PostEditHeader( { postType, postId } ) { + const ids = useMemo( () => postId.split( ',' ), [ postId ] ); + const { icon, labels } = useSelect( + ( select ) => { + const { getEditedEntityRecord, getPostType } = select( coreStore ); + const { getPostIcon } = unlock( select( editorStore ) ); + const _record = getEditedEntityRecord( + 'postType', + postType, + ids[ 0 ] + ); + + return { + icon: getPostIcon( postType, { + area: _record?.area, + } ), + labels: getPostType( postType )?.labels, + }; + }, + [ ids, postType ] + ); + + if ( ids.length === 1 ) { + return ( + + ); + } + + return ( + + + + + { labels?.name && + sprintf( + // translators: %i number of selected items %s: Name of the plural post type e.g: "Posts". + __( '%i %s' ), + ids.length, + labels?.name + ) } + + + + { sprintf( + // translators: %s: Name of the plural post type e.g: "Posts". + __( 'Changes will be applied to all selected %s.' ), + labels?.name.toLowerCase() + ) } + + + ); +} diff --git a/packages/edit-site/src/components/post-edit/index.js b/packages/edit-site/src/components/post-edit/index.js index 9a99a987089c1a..b3954e4ddbdeaf 100644 --- a/packages/edit-site/src/components/post-edit/index.js +++ b/packages/edit-site/src/components/post-edit/index.js @@ -18,11 +18,12 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor'; * Internal dependencies */ import Page from '../page'; +import PostEditHeader from '../post-edit/header'; import { unlock } from '../../lock-unlock'; import usePatternSettings from '../page-patterns/use-pattern-settings'; import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; -const { PostCardPanel, usePostFields } = unlock( editorPrivateApis ); +const { usePostFields } = unlock( editorPrivateApis ); const fieldsWithBulkEditSupport = [ 'title', @@ -76,7 +77,6 @@ function PostEditForm( { postType, postId } ) { id: 'featured_media', layout: 'regular', }, - 'title', { id: 'status', label: __( 'Status & Visibility' ), @@ -159,9 +159,7 @@ function PostEditForm( { postType, postId } ) { return ( - { ids.length === 1 && ( - - ) } + { diff --git a/packages/editor/src/components/post-card-panel/index.js b/packages/editor/src/components/post-card-panel/index.js index 8fcca6c6bd6d40..e347d3c79fc521 100644 --- a/packages/editor/src/components/post-card-panel/index.js +++ b/packages/editor/src/components/post-card-panel/index.js @@ -64,7 +64,7 @@ export default function PostCardPanel( { [ postId, postType ] ); - const pageTypeBadge = usePageTypeBadge(); + const pageTypeBadge = usePageTypeBadge( postId ); return (
@@ -78,9 +78,7 @@ export default function PostCardPanel( { numberOfLines={ 2 } truncate className="editor-post-card-panel__title" - weight={ 500 } as="h2" - lineHeight="20px" > { title ? decodeEntities( title ) : __( 'No title' ) } { pageTypeBadge && ( diff --git a/packages/editor/src/components/post-card-panel/style.scss b/packages/editor/src/components/post-card-panel/style.scss index d8a2a4628e6f9c..d9ecfc58304e85 100644 --- a/packages/editor/src/components/post-card-panel/style.scss +++ b/packages/editor/src/components/post-card-panel/style.scss @@ -7,6 +7,7 @@ width: 100%; &.editor-post-card-panel__title { + @include heading-medium(); margin: 0; padding: 2px 0; display: flex; diff --git a/packages/editor/src/utils/pageTypeBadge.js b/packages/editor/src/utils/pageTypeBadge.js index 321b9caa17769e..bc787b12284222 100644 --- a/packages/editor/src/utils/pageTypeBadge.js +++ b/packages/editor/src/utils/pageTypeBadge.js @@ -5,19 +5,14 @@ import { __ } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; import { store as coreStore } from '@wordpress/core-data'; -/** - * Internal dependencies - */ -import { store as editorStore } from '../store'; - /** * Custom hook to get the page type badge for the current post on edit site view. + * + * @param {number} postId postId of the current post being edited. */ -export default function usePageTypeBadge() { +export default function usePageTypeBadge( postId ) { const { isFrontPage, isPostsPage } = useSelect( ( select ) => { - const { getCurrentPostId } = select( editorStore ); const { canUser, getEditedEntityRecord } = select( coreStore ); - const postId = getCurrentPostId(); const siteSettings = canUser( 'read', { kind: 'root', name: 'site',