Skip to content

Commit

Permalink
Add support for blocks icon and title
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Nov 8, 2019
1 parent 58f2f64 commit 81e6313
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/block-library/src/media-text/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import icon from './icon';
import MediaContainer from './media-container';

/**
Expand Down Expand Up @@ -251,18 +250,20 @@ class MediaTextEdit extends Component {
const MediaTextEditWithColors = withColors( 'backgroundColor' )( MediaTextEdit );

const MediaTextEditPatternPicker = ( props ) => {
const blockName = 'core/media-text';
const { defaultPattern, patterns } = useSelect( ( select ) => {
const { name } = props;
const { blockType, defaultPattern, patterns } = useSelect( ( select ) => {
const {
__experimentalGetBlockPatterns,
getBlockType,
__experimentalGetDefaultBlockPattern,
} = select( 'core/blocks' );

return {
patterns: __experimentalGetBlockPatterns( blockName ),
defaultPattern: __experimentalGetDefaultBlockPattern( blockName ),
blockType: getBlockType( name ),
defaultPattern: __experimentalGetDefaultBlockPattern( name ),
patterns: __experimentalGetBlockPatterns( name ),
};
} );
}, [ name ] );

const [ pattern, setPattern ] = useState( null );

Expand All @@ -274,8 +275,8 @@ const MediaTextEditPatternPicker = ( props ) => {

return (
<__experimentalBlockPatternPicker
icon={ icon }
label={ __( 'Media & Text' ) }
icon={ get( blockType, [ 'icon', 'src' ] ) }
label={ get( blockType, [ 'title' ] ) }
patterns={ patterns }
onSelect={ ( nextPattern = defaultPattern ) => {
if ( nextPattern.attributes ) {
Expand Down

0 comments on commit 81e6313

Please sign in to comment.