-
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.
Chrome: Adding the post excerpt panel
- Loading branch information
1 parent
3b2d42f
commit 99cc1f0
Showing
5 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* 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)' ) } | ||
/> | ||
<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 { | ||
onUpdateExcerpt( excerpt ) { | ||
dispatch( editPost( { excerpt } ) ); | ||
}, | ||
}; | ||
} | ||
)( PostExcerpt ); | ||
|
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,6 @@ | ||
.editor-post-excerpt__textarea { | ||
width: 100%; | ||
height: 80px; | ||
margin-top: 20px; | ||
margin-bottom: 10px; | ||
} |
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