Skip to content

Commit

Permalink
Update PostExcerpt component to use TextareaControl (#4997)
Browse files Browse the repository at this point in the history
* Update PostExcerpt component to use TextareaControl.

* Fix build error.

* Fix spacing between 'Learn more about manual excerpts' link and textarea.

* Add missing ) after failed rebase
  • Loading branch information
paulwilde authored and gziolo committed May 10, 2018
1 parent 2729474 commit a528611
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 6 additions & 11 deletions editor/components/post-excerpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { ExternalLink, withInstanceId } from '@wordpress/components';
import { ExternalLink, TextareaControl } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/element';

Expand All @@ -11,17 +11,13 @@ import { compose } from '@wordpress/element';
*/
import './style.scss';

function PostExcerpt( { excerpt, onUpdateExcerpt, instanceId } ) {
const id = `editor-post-excerpt-${ instanceId }`;
const onChange = ( event ) => onUpdateExcerpt( event.target.value );

function PostExcerpt( { excerpt, onUpdateExcerpt } ) {
return (
<div>
<label key="label" htmlFor={ id }>{ __( 'Write an excerpt (optional)' ) }</label>
<textarea
id={ id }
<div className="editor-post-excerpt">
<TextareaControl
label={ __( 'Write an excerpt (optional)' ) }
className="editor-post-excerpt__textarea"
onChange={ onChange }
onChange={ ( value ) => onUpdateExcerpt( value ) }
value={ excerpt }
/>
<ExternalLink href="https://codex.wordpress.org/Excerpt">
Expand All @@ -42,5 +38,4 @@ export default compose( [
dispatch( 'core/editor' ).editPost( { excerpt } );
},
} ) ),
withInstanceId,
] )( PostExcerpt );
4 changes: 4 additions & 0 deletions editor/components/post-excerpt/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.editor-post-excerpt > .blocks-base-control {
margin-bottom: 0;
}

.editor-post-excerpt__textarea {
width: 100%;
height: 80px;
Expand Down

0 comments on commit a528611

Please sign in to comment.