-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Editor: Update post excerpt panel with new designs #60894
Changes from 3 commits
8a52cbc
3a07113
3e6e0a3
2cac534
2101509
acbebc3
906ef93
9ad36cb
60f697f
069c8a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,40 +28,53 @@ import { store as editorStore } from '../../store'; | |
import { | ||
TEMPLATE_POST_TYPE, | ||
TEMPLATE_PART_POST_TYPE, | ||
PATTERN_POST_TYPE, | ||
} from '../../store/constants'; | ||
import { PrivatePostExcerptPanel } from '../post-excerpt/panel'; | ||
import { unlock } from '../../lock-unlock'; | ||
import TemplateAreas from '../template-areas'; | ||
|
||
export default function PostCardPanel( { className, actions } ) { | ||
const { modified, title, templateInfo, icon, postType, isPostsPage } = | ||
useSelect( ( select ) => { | ||
const { | ||
getEditedPostAttribute, | ||
getCurrentPostType, | ||
getCurrentPostId, | ||
__experimentalGetTemplateInfo, | ||
} = select( editorStore ); | ||
const { getEditedEntityRecord, getEntityRecord } = | ||
select( coreStore ); | ||
const siteSettings = getEntityRecord( 'root', 'site' ); | ||
const _type = getCurrentPostType(); | ||
const _id = getCurrentPostId(); | ||
const _record = getEditedEntityRecord( 'postType', _type, _id ); | ||
const _templateInfo = __experimentalGetTemplateInfo( _record ); | ||
return { | ||
title: | ||
_templateInfo?.title || getEditedPostAttribute( 'title' ), | ||
modified: getEditedPostAttribute( 'modified' ), | ||
id: _id, | ||
postType: _type, | ||
templateInfo: _templateInfo, | ||
icon: unlock( select( editorStore ) ).getPostIcon( _type, { | ||
area: _record?.area, | ||
} ), | ||
isPostsPage: +_id === siteSettings?.page_for_posts, | ||
}; | ||
}, [] ); | ||
const description = templateInfo?.description; | ||
const { | ||
modified, | ||
title, | ||
showPostExcerptPanel, | ||
icon, | ||
postType, | ||
isPostsPage, | ||
} = useSelect( ( select ) => { | ||
const { | ||
getEditedPostAttribute, | ||
getCurrentPostType, | ||
getCurrentPostId, | ||
__experimentalGetTemplateInfo, | ||
} = select( editorStore ); | ||
const { getEditedEntityRecord, getEntityRecord } = select( coreStore ); | ||
const siteSettings = getEntityRecord( 'root', 'site' ); | ||
const _type = getCurrentPostType(); | ||
const _id = getCurrentPostId(); | ||
const _record = getEditedEntityRecord( 'postType', _type, _id ); | ||
const _templateInfo = | ||
[ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes( _type ) && | ||
__experimentalGetTemplateInfo( _record ); | ||
return { | ||
title: _templateInfo?.title || getEditedPostAttribute( 'title' ), | ||
modified: getEditedPostAttribute( 'modified' ), | ||
id: _id, | ||
postType: _type, | ||
icon: unlock( select( editorStore ) ).getPostIcon( _type, { | ||
area: _record?.area, | ||
} ), | ||
isPostsPage: +_id === siteSettings?.page_for_posts, | ||
// Post excerpt panel is rendered in different place depending on the post type. | ||
// So we cannot make this check inside the PostExcerpt component based on the current edited entity. | ||
showPostExcerptPanel: [ | ||
TEMPLATE_POST_TYPE, | ||
TEMPLATE_PART_POST_TYPE, | ||
PATTERN_POST_TYPE, | ||
].includes( _type ), | ||
}; | ||
}, [] ); | ||
const lastEditedText = | ||
modified && | ||
sprintf( | ||
|
@@ -98,20 +111,14 @@ export default function PostCardPanel( { className, actions } ) { | |
{ actions } | ||
</HStack> | ||
<VStack className="editor-post-card-panel__content"> | ||
{ ( description || | ||
lastEditedText || | ||
showPostContentInfo ) && ( | ||
<VStack | ||
className="editor-post-card-panel__description" | ||
spacing={ 2 } | ||
> | ||
{ description && <Text>{ description }</Text> } | ||
{ showPostContentInfo && <PostContentInfo /> } | ||
{ lastEditedText && ( | ||
<Text>{ lastEditedText }</Text> | ||
) } | ||
</VStack> | ||
) } | ||
<VStack | ||
className="editor-post-card-panel__description" | ||
spacing={ 2 } | ||
> | ||
{ showPostExcerptPanel && <PrivatePostExcerptPanel /> } | ||
{ showPostContentInfo && <PostContentInfo /> } | ||
{ lastEditedText && <Text>{ lastEditedText }</Text> } | ||
</VStack> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this rendered so I can test it? If I'm not wrong it's the top of the inspector no? I didn't see the excerpt there in my testing, so I'm missing something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's in the top of the inspector yes, but for patterns, templates and template parts. Then it will be shown if there is a description/excerpt and if it's a user create entity it will be editable too.. |
||
{ postType === TEMPLATE_POST_TYPE && <TemplateAreas /> } | ||
</VStack> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this check should probably move within the component itself like the other PostSomething components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think there is a better way by adding some kind of flag or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the post excerpt rendered in different places depending on the post type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the designs: #59689 (comment). I think the main reason is that in the entities that we treat excerpt as a
description
feels better above in the card where we essentially describe the entity. In regular post types excerpt is more of part of the entity with a different functionality - describe the content.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we really helping ourselves by creating these inconsistencies?