Skip to content

Commit

Permalink
Suggest post format
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Aug 2, 2018
1 parent e7f8ea2 commit cd57766
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';
import { withSelect } from '@wordpress/data';
import { Dashicon, PanelBody } from '@wordpress/components';

/**
* Internal dependencies.
*/
import PostFormat from '../post-format';

const MaybePostFormatPanel = ( { currentPostFormat, suggestedPostFormat } ) => suggestedPostFormat &&
suggestedPostFormat !== currentPostFormat &&
<PanelBody initialOpen={ true } title={ [
<Dashicon key={ 'dashicon-lightbulb' } icon={ 'lightbulb' } />,
__( 'Tip:' ),
<span className="editor-post-publish-panel__link" key="label">{
__( 'Choose a fitting post format' )
}</span>,
] } >
<PostFormat />
</PanelBody>;

export default withSelect(
( select ) => {
const { getEditedPostAttribute, getSuggestedPostFormat } = select( 'core/editor' );
return {
suggestedPostFormat: getSuggestedPostFormat(),
currentPostFormat: getEditedPostAttribute( 'format' ),
};
}
)( MaybePostFormatPanel );
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import PostVisibilityLabel from '../post-visibility/label';
import PostSchedule from '../post-schedule';
import PostScheduleLabel from '../post-schedule/label';
import MaybeTagsPanel from './maybe-tags-panel';
import MaybePostFormatPanel from './maybe-post-format-panel';

function PostPublishPanelPrepublish( {
hasPublishAction,
Expand All @@ -42,6 +43,7 @@ function PostPublishPanelPrepublish( {
] }>
<PostSchedule />
</PanelBody>
<MaybePostFormatPanel />
<MaybeTagsPanel />
{ children }
</Fragment>
Expand Down

0 comments on commit cd57766

Please sign in to comment.