-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Chrome: Adding the post excerpt panel #871
Changes from 3 commits
99cc1f0
c251345
061937f
58b90a8
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { connect } from 'react-redux'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from 'i18n'; | ||
import PanelBody from 'components/panel/body'; | ||
|
||
/** | ||
* Internal Dependencies | ||
*/ | ||
import './style.scss'; | ||
import { getEditedPostExcerpt } from '../../selectors'; | ||
import { editPost } from '../../actions'; | ||
|
||
function PostExcerpt( { excerpt, onUpdateExcerpt } ) { | ||
const onChange = ( event ) => onUpdateExcerpt( event.target.value ); | ||
|
||
return ( | ||
<PanelBody title={ __( 'Excerpt' ) } initialOpen={ false }> | ||
<textarea | ||
className="editor-post-excerpt__textarea" | ||
onChange={ onChange } | ||
value={ excerpt } | ||
placeholder={ __( 'Write an excerpt (optional)' ) } | ||
aria-label={ __( 'Excerpt' ) } | ||
/> | ||
<a href="https://codex.wordpress.org/Excerpt" target="_blank"> | ||
{ __( 'Learn more about manual excerpts' ) } | ||
</a> | ||
</PanelBody> | ||
); | ||
/* eslint-enable jsx-a11y/label-has-for */ | ||
} | ||
|
||
export default connect( | ||
( state ) => ( { | ||
excerpt: getEditedPostExcerpt( state ), | ||
} ), | ||
( dispatch ) => { | ||
return { | ||
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. Minor: Should we be consistent with how we're creating object return values between ( dispatch ) => ( {
onUpdateExcerpt( excerpt ) {
dispatch( editPost( { excerpt } ) );
},
} ) 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. Right! do you have a preference. I'm leaning towards the explicit return (less magic) but I'm ok with both 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. I don't feel strongly. I personally prefer the compact version, but understand that it can be a bit more difficult to interpret (largely because of the need to wrap parentheses for an implicit object return value). |
||
onUpdateExcerpt( excerpt ) { | ||
dispatch( editPost( { excerpt } ) ); | ||
}, | ||
}; | ||
} | ||
)( PostExcerpt ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.editor-post-excerpt__textarea { | ||
width: 100%; | ||
height: 80px; | ||
margin-top: 20px; | ||
margin-bottom: 10px; | ||
} |
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.
Is this needed?
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.
Good catch (Ah copy/paste)