-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Document Settings]: Add summary panel version 1 (#39973)
* [Document Settings]: Add summary panel version 1 * Polish featured image. * Tweak excerpt. * Fix focus styles for edit and trash. * Fix focus styles. * Improve thumbnail resolution and appearance. * update FeaturedImage in inspector controls + remove the previous panel. The preference for displaying the previous panel is still respected and will show/hide the featured image from `post summary` now. * add a `minimal` version of PostSummary editor component and remove the `excerpt panel` from inspector controls * remove obsolete export * fix postExcerpt callback * remove obsolete styles import * remove PostAuthor from status panel * make post title a `span` * Polish heading. * fix tests and add a new one * Spacing and focus styles. * add post-type support checks for title and author Co-authored-by: jasmussen <[email protected]>
- Loading branch information
1 parent
6f204e3
commit ae657f3
Showing
17 changed files
with
385 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/edit-post/src/components/sidebar/post-summary/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { PanelBody, PanelRow } from '@wordpress/components'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { PostAuthor, PostTypeSupportCheck } from '@wordpress/editor'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import PostTitle from '../post-title'; | ||
import FeaturedImage from '../featured-image'; | ||
import PostExcerpt from '../post-excerpt'; | ||
import { store as editPostStore } from '../../../store'; | ||
|
||
/** | ||
* Module Constants | ||
*/ | ||
const PANEL_NAME = 'post-summary'; | ||
|
||
function PostSummary() { | ||
const isOpened = useSelect( | ||
( select ) => select( editPostStore ).isEditorPanelOpened( PANEL_NAME ), | ||
[] | ||
); | ||
const { toggleEditorPanelOpened } = useDispatch( editPostStore ); | ||
return ( | ||
<PanelBody | ||
className="edit-post-post-summary" | ||
title={ __( 'Summary' ) } | ||
opened={ isOpened } | ||
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) } | ||
> | ||
<FeaturedImage /> | ||
<PostTypeSupportCheck supportKeys="title"> | ||
<PanelRow> | ||
<PostTitle /> | ||
</PanelRow> | ||
</PostTypeSupportCheck> | ||
<PostExcerpt isMinimal /> | ||
<PostTypeSupportCheck supportKeys="author"> | ||
<PanelRow> | ||
<PostAuthor labelPosition="side" /> | ||
</PanelRow> | ||
</PostTypeSupportCheck> | ||
</PanelBody> | ||
); | ||
} | ||
|
||
export default PostSummary; |
27 changes: 27 additions & 0 deletions
27
packages/edit-post/src/components/sidebar/post-title/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { PlainText } from '@wordpress/block-editor'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { store as editorStore } from '@wordpress/editor'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
|
||
function PostTitle() { | ||
const { editPost } = useDispatch( editorStore ); | ||
const postTitle = useSelect( | ||
( select ) => select( editorStore ).getEditedPostAttribute( 'title' ), | ||
[] | ||
); | ||
return ( | ||
<PlainText | ||
className="edit-post-post-title" | ||
tagName="span" | ||
placeholder={ __( 'Add title' ) } | ||
value={ postTitle } | ||
onChange={ ( title ) => editPost( { title } ) } | ||
__experimentalVersion={ 2 } | ||
/> | ||
); | ||
} | ||
|
||
export default PostTitle; |
Oops, something went wrong.