-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: Add the featured image panel (#57053)
- Loading branch information
1 parent
939c19f
commit 0ddd43e
Showing
6 changed files
with
63 additions
and
67 deletions.
There are no files selected for viewing
64 changes: 0 additions & 64 deletions
64
packages/edit-post/src/components/sidebar/featured-image/index.js
This file was deleted.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
packages/editor/src/components/post-featured-image/panel.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,55 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { PanelBody } from '@wordpress/components'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editorStore } from '../../store'; | ||
import PostFeaturedImage from './index'; | ||
import PostFeaturedImageCheck from './check'; | ||
|
||
const PANEL_NAME = 'featured-image'; | ||
|
||
function FeaturedImage() { | ||
const { postType, isEnabled, isOpened } = useSelect( ( select ) => { | ||
const { | ||
getEditedPostAttribute, | ||
isEditorPanelEnabled, | ||
isEditorPanelOpened, | ||
} = select( editorStore ); | ||
const { getPostType } = select( coreStore ); | ||
|
||
return { | ||
postType: getPostType( getEditedPostAttribute( 'type' ) ), | ||
isEnabled: isEditorPanelEnabled( PANEL_NAME ), | ||
isOpened: isEditorPanelOpened( PANEL_NAME ), | ||
}; | ||
}, [] ); | ||
|
||
const { toggleEditorPanelOpened } = useDispatch( editorStore ); | ||
|
||
if ( ! isEnabled ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<PostFeaturedImageCheck> | ||
<PanelBody | ||
title={ | ||
postType?.labels?.featured_image ?? __( 'Featured image' ) | ||
} | ||
opened={ isOpened } | ||
onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) } | ||
> | ||
<PostFeaturedImage /> | ||
</PanelBody> | ||
</PostFeaturedImageCheck> | ||
); | ||
} | ||
|
||
export default FeaturedImage; |