Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
151f9e9
Show tags in the pre-publish panel
oandregal Aug 1, 2018
4d8af26
Extract to MaybeTagsPanel
oandregal Aug 1, 2018
1becfb8
Tags panel: control visibility
oandregal Aug 1, 2018
ed9753b
Tags panel: control visibility
oandregal Aug 1, 2018
dfb60da
Prevent crash if tags werent fetched yet
oandregal Aug 1, 2018
870b5e7
Remove unused code
oandregal Aug 1, 2018
7218b33
MaybeTagsPanel visibility
oandregal Aug 1, 2018
b0c1464
Suggest post format
oandregal Aug 2, 2018
c98522c
Do not open panels by default
oandregal Aug 2, 2018
83635bc
Do not mount component until taxonomy has been fetched
oandregal Aug 2, 2018
0a0cd18
Refactor for code clarity
oandregal Aug 2, 2018
9f53604
Tweak icon and copy text
oandregal Aug 2, 2018
ac4e132
Refactor to use ifCondition HOC
oandregal Aug 2, 2018
f8d386d
Make a more conversational post format
oandregal Aug 2, 2018
ab0bf56
Update text copy
oandregal Aug 2, 2018
9ef07b3
Update copy text
oandregal Aug 2, 2018
b2073e8
Update copy text for transations
oandregal Aug 2, 2018
603c7a1
Remove icons
oandregal Aug 3, 2018
e40d773
Improve copy text for tags panel
oandregal Aug 3, 2018
620dbbd
Add section title
oandregal Aug 3, 2018
1baa309
Update copy
oandregal Aug 3, 2018
053038d
chore: Make some tweaks to copy
tofumatt Aug 7, 2018
5d18b23
Shorten hasTags check
oandregal Aug 8, 2018
ed42917
Update to use suggestion
oandregal Aug 8, 2018
52ab3d3
Refactor logic for get suggestion
oandregal Aug 8, 2018
e230479
Update copy
oandregal Aug 8, 2018
713d5a6
Update copy
oandregal Aug 8, 2018
c1ac898
chore: Use clearer suggeston text
tofumatt Aug 8, 2018
afffd27
Refactor for clarity
oandregal Aug 9, 2018
dc3d61a
chore: Tweak name of component for readability
tofumatt Aug 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make a more conversational post format
  • Loading branch information
oandregal committed Aug 13, 2018
commit f8d386dfc7e8af5eda99eebf482811fcd825d5fd
2 changes: 1 addition & 1 deletion packages/editor/src/components/post-format/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { withInstanceId, compose } from '@wordpress/compose';
*/
import PostFormatCheck from './check';

const POST_FORMATS = [
export const POST_FORMATS = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems odd to replicate this here when it's likely in the API (single source of truth is good), but I get it's from before your commit. 🤷‍♂️

{ id: 'aside', caption: __( 'Aside' ) },
{ id: 'gallery', caption: __( 'Gallery' ) },
{ id: 'link', caption: __( 'Link' ) },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
/**
* External dependencies
*/
import { find, get, includes, union } from 'lodash';

/**
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';
import { ifCondition, compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { Dashicon, PanelBody } from '@wordpress/components';
import { withDispatch, withSelect } from '@wordpress/data';
import { Button, Dashicon, PanelBody } from '@wordpress/components';

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

const PostFormatSuggested = ( { suggestion, onUpdatePostFormat } ) => <Button isLink onClick={ () => onUpdatePostFormat( suggestion.id ) }>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised we don't have a lint rule to catch this but this is quite an unreadable line; it looks like it's an implicit return of a <Button /> component but it's returning multiple lines without parenthesis. It makes it hard to understand; I'll push a tweak.

{ suggestion.caption }
</Button>;

const PostFormatPanel = ( ) => <PanelBody initialOpen={ false } title={ [
const PostFormatPanel = ( { suggestion, onUpdatePostFormat } ) => <PanelBody initialOpen={ false } title={ [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a few of these are implicit multi-line returns. We should really have an ESLint rule preventing that...

<Dashicon
key={ 'dashicon-lightbulb' }
icon={ 'lightbulb' }
Expand All @@ -23,16 +32,30 @@ const PostFormatPanel = ( ) => <PanelBody initialOpen={ false } title={ [
}</span>,
] } >
<p>Post formats are used to display different types of content differently.</p>
<PostFormat />
<p>It looks like you may want to use the <PostFormatSuggested suggestion={ suggestion } onUpdatePostFormat={ onUpdatePostFormat } /> post format type for this post.</p>
</PanelBody>;

export default compose(
withSelect( ( select ) => {
const { getEditedPostAttribute, getSuggestedPostFormat } = select( 'core/editor' );
const suggestedPostFormat = getSuggestedPostFormat();
const currentPostFormat = getEditedPostAttribute( 'format' );
const themeSupports = select( 'core' ).getThemeSupports();
// Ensure current format is always in the set.
// The current format may not be a format supported by the theme.
const supportedFormats = union( [ currentPostFormat ], get( themeSupports, [ 'formats' ], [] ) );
const formats = POST_FORMATS.filter( ( format ) => includes( supportedFormats, format.id ) );
const suggestion = find( formats, ( format ) => format.id === suggestedPostFormat );
return {
suggestedPostFormat: getSuggestedPostFormat(),
currentPostFormat: getEditedPostAttribute( 'format' ),
currentPostFormat,
suggestedPostFormat,
suggestion,
};
} ),
withDispatch( ( dispatch ) => ( {
onUpdatePostFormat( postFormat ) {
dispatch( 'core/editor' ).editPost( { format: postFormat } );
},
} ) ),
ifCondition( ( { suggestedPostFormat, currentPostFormat } ) => suggestedPostFormat && suggestedPostFormat !== currentPostFormat ),
)( PostFormatPanel );