Skip to content

Commit

Permalink
Rename pattern label to patter title to align with block types
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jan 24, 2020
1 parent 7509931 commit d56e687
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function BlockPatternPicker( {
iconSize={ 48 }
onClick={ () => onSelect( pattern ) }
className="block-editor-block-pattern-picker__pattern"
label={ pattern.label }
label={ pattern.title }
/>
</li>
) ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function BlockTypesList( { items = [], onSelect, onHover = () => {}, children }
...item,
id: `${ item.id }-${ pattern.name }`,
icon: pattern.icon || item.icon,
title: pattern.label || item.title,
title: pattern.title || item.title,
description: pattern.description || item.description,
// If `example` is explicitly undefined for the pattern, the preview will not be shown.
example: pattern.hasOwnProperty( 'example' ) ? pattern.example : item.example,
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inserter/search-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const searchItems = ( items, categories, collections, searchTerm ) => {

unmatchedTerms = removeMatchingTerms(
unmatchedTerms,
patterns.map( ( { label } ) => label ).join( ' ' ),
patterns.map( ( pattern ) => pattern.title ).join( ' ' ),
);

return unmatchedTerms.length === 0;
Expand All @@ -110,7 +110,7 @@ export const searchItems = ( items, categories, collections, searchTerm ) => {
const matchedPatterns = item.patterns.filter( ( pattern ) => {
return intersectionWith(
normalizedSearchTerms,
normalizeSearchTerm( pattern.label ),
normalizeSearchTerm( pattern.title ),
( termToMatch, labelTerm ) => labelTerm.includes( termToMatch )
).length > 0;
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export const withPatternsItem = {
patterns: [
{
name: 'pattern-one',
label: 'Pattern One',
title: 'Pattern One',
},
{
name: 'pattern-two',
label: 'Pattern Two',
title: 'Pattern Two',
},
{
name: 'pattern-three',
label: 'Pattern Three',
title: 'Pattern Three',
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe( 'searchItems', () => {

expect( filteredItems ).toHaveLength( 1 );
expect( filteredItems[ 0 ].patterns ).toHaveLength( 2 );
expect( filteredItems[ 0 ].patterns[ 0 ].label ).toBe( 'Pattern Two' );
expect( filteredItems[ 0 ].patterns[ 1 ].label ).toBe( 'Pattern Three' );
expect( filteredItems[ 0 ].patterns[ 0 ].title ).toBe( 'Pattern Two' );
expect( filteredItems[ 0 ].patterns[ 1 ].title ).toBe( 'Pattern Three' );
} );
} );
10 changes: 5 additions & 5 deletions packages/block-library/src/columns/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { __ } from '@wordpress/i18n';
const patterns = [
{
name: 'two-columns-equal',
label: __( 'Two columns; equal split' ),
title: __( 'Two columns; equal split' ),
icon: <SVG width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><Path fillRule="evenodd" clipRule="evenodd" d="M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H25V34H39ZM23 34H9V14H23V34Z" /></SVG>,
isDefault: true,
innerBlocks: [
Expand All @@ -23,7 +23,7 @@ const patterns = [
},
{
name: 'two-columns-one-third-two-thirds',
label: __( 'Two columns; one-third, two-thirds split' ),
title: __( 'Two columns; one-third, two-thirds split' ),
icon: <SVG width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><Path fillRule="evenodd" clipRule="evenodd" d="M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H20V34H39ZM18 34H9V14H18V34Z" /></SVG>,
innerBlocks: [
[ 'core/column', { width: 33.33 } ],
Expand All @@ -33,7 +33,7 @@ const patterns = [
},
{
name: 'two-columns-two-thirds-one-third',
label: __( 'Two columns; two-thirds, one-third split' ),
title: __( 'Two columns; two-thirds, one-third split' ),
icon: <SVG width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><Path fillRule="evenodd" clipRule="evenodd" d="M39 12C40.1046 12 41 12.8954 41 14V34C41 35.1046 40.1046 36 39 36H9C7.89543 36 7 35.1046 7 34V14C7 12.8954 7.89543 12 9 12H39ZM39 34V14H30V34H39ZM28 34H9V14H28V34Z" /></SVG>,
innerBlocks: [
[ 'core/column', { width: 66.66 } ],
Expand All @@ -43,7 +43,7 @@ const patterns = [
},
{
name: 'three-columns-equal',
label: __( 'Three columns; equal split' ),
title: __( 'Three columns; equal split' ),
icon: <SVG width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><Path fillRule="evenodd" d="M41 14a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h30a2 2 0 0 0 2-2V14zM28.5 34h-9V14h9v20zm2 0V14H39v20h-8.5zm-13 0H9V14h8.5v20z" /></SVG>,
innerBlocks: [
[ 'core/column' ],
Expand All @@ -54,7 +54,7 @@ const patterns = [
},
{
name: 'three-columns-wider-center',
label: __( 'Three columns; wide center column' ),
title: __( 'Three columns; wide center column' ),
icon: <SVG width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><Path fillRule="evenodd" d="M41 14a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h30a2 2 0 0 0 2-2V14zM31 34H17V14h14v20zm2 0V14h6v20h-6zm-18 0H9V14h6v20z" /></SVG>,
innerBlocks: [
[ 'core/column', { width: 25 } ],
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import { DEPRECATED_ENTRY_KEYS } from './constants';
* @typedef {Object} WPBlockPattern
*
* @property {string} name The unique and machine-readable name.
* @property {string} label A human-readable label.
* @property {string} title A human-readable pattern title.
* @property {string} description A detailed pattern description.
* @property {WPIcon} [icon] An icon helping to visualize the pattern.
* @property {boolean} [isDefault] Indicates whether the current pattern is
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( 'actions', () => {
it( 'should return the ADD_BLOCK_PATTERNS action', () => {
const pattern = {
name: patternName,
label: 'My Pattern',
title: 'My Pattern',
attributes: {
example: 'foo',
},
Expand Down

0 comments on commit d56e687

Please sign in to comment.